diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-06-19 23:09:43 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-19 23:09:43 +0000 |
| commit | 6531d27cc087b89fbe3fd9252627e33ff679b40e (patch) | |
| tree | bdd0e968d3573164de7cdf3d7c0b86bfa731d1d8 /core/java | |
| parent | 9ea3a32e3c8ce46d57911bee4c56ab83c5011347 (diff) | |
| parent | 4a6dff091141e40df747f37203fb0fc17e16a39a (diff) | |
Merge "Allow permissions to have background permissions"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 21 | ||||
| -rw-r--r-- | core/java/android/content/pm/PermissionGroupInfo.java | 45 | ||||
| -rw-r--r-- | core/java/android/content/pm/PermissionInfo.java | 18 |
3 files changed, 84 insertions, 0 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index a58db6450f57..033d2eef3cf3 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3100,6 +3100,14 @@ public class PackageParser { 0); perm.info.requestRes = sa.getResourceId( com.android.internal.R.styleable.AndroidManifestPermissionGroup_request, 0); + perm.info.requestDetailResourceId = sa.getResourceId( + com.android.internal.R.styleable.AndroidManifestPermissionGroup_requestDetail, 0); + perm.info.backgroundRequestResourceId = sa.getResourceId( + com.android.internal.R.styleable.AndroidManifestPermissionGroup_backgroundRequest, + 0); + perm.info.backgroundRequestDetailResourceId = sa.getResourceId( + com.android.internal.R.styleable + .AndroidManifestPermissionGroup_backgroundRequestDetail, 0); perm.info.flags = sa.getInt( com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0); perm.info.priority = sa.getInt( @@ -3154,6 +3162,19 @@ public class PackageParser { perm.info.requestRes = sa.getResourceId( com.android.internal.R.styleable.AndroidManifestPermission_request, 0); + if (sa.hasValue( + com.android.internal.R.styleable.AndroidManifestPermission_backgroundPermission)) { + if ("android".equals(owner.packageName)) { + perm.info.backgroundPermission = sa.getNonResourceString( + com.android.internal.R.styleable + .AndroidManifestPermission_backgroundPermission); + } else { + Slog.w(TAG, owner.packageName + " defines permission '" + perm.info.name + + "' with a background permission. Only the 'android' package can do " + + "that."); + } + } + perm.info.protectionLevel = sa.getInt( com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel, PermissionInfo.PROTECTION_NORMAL); diff --git a/core/java/android/content/pm/PermissionGroupInfo.java b/core/java/android/content/pm/PermissionGroupInfo.java index 7c4478d0b689..8cf66d81972f 100644 --- a/core/java/android/content/pm/PermissionGroupInfo.java +++ b/core/java/android/content/pm/PermissionGroupInfo.java @@ -45,6 +45,42 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable { public @StringRes int requestRes; /** + * A string resource identifier (in the package's resources) used as subtitle when requesting + * only access while in the foreground. + * + * From the "requestDetail" attribute or, if not set, {@link + * android.content.res.ResourceId#ID_NULL}. + * + * @hide + */ + @SystemApi + public @StringRes int requestDetailResourceId; + + /** + * A string resource identifier (in the package's resources) used when requesting background + * access. Also used when requesting both foreground and background access. + * + * From the "backgroundRequest" attribute or, if not set, {@link + * android.content.res.ResourceId#ID_NULL}. + * + * @hide + */ + @SystemApi + public @StringRes int backgroundRequestResourceId; + + /** + * A string resource identifier (in the package's resources) used as subtitle when requesting + * background access. + * + * From the "backgroundRequestDetail" attribute or, if not set, {@link + * android.content.res.ResourceId#ID_NULL}. + * + * @hide + */ + @SystemApi + public @StringRes int backgroundRequestDetailResourceId; + + /** * The description string provided in the AndroidManifest file, if any. You * probably don't want to use this, since it will be null if the description * is in a resource. You probably want @@ -76,6 +112,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable { super(orig); descriptionRes = orig.descriptionRes; requestRes = orig.requestRes; + requestDetailResourceId = orig.requestDetailResourceId; + backgroundRequestResourceId = orig.backgroundRequestResourceId; + backgroundRequestDetailResourceId = orig.backgroundRequestDetailResourceId; nonLocalizedDescription = orig.nonLocalizedDescription; flags = orig.flags; priority = orig.priority; @@ -119,6 +158,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable { super.writeToParcel(dest, parcelableFlags); dest.writeInt(descriptionRes); dest.writeInt(requestRes); + dest.writeInt(requestDetailResourceId); + dest.writeInt(backgroundRequestResourceId); + dest.writeInt(backgroundRequestDetailResourceId); TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags); dest.writeInt(flags); dest.writeInt(priority); @@ -138,6 +180,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable { super(source); descriptionRes = source.readInt(); requestRes = source.readInt(); + requestDetailResourceId = source.readInt(); + backgroundRequestResourceId = source.readInt(); + backgroundRequestDetailResourceId = source.readInt(); nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); flags = source.readInt(); priority = source.readInt(); diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java index 938409af90e9..535ef00d58a1 100644 --- a/core/java/android/content/pm/PermissionInfo.java +++ b/core/java/android/content/pm/PermissionInfo.java @@ -285,6 +285,21 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { public int requestRes; /** + * Some permissions only grant access while the app is in foreground. Some of these permissions + * allow to add background capabilities by adding another permission. + * + * If this is such a permission, this is the name of the permission adding the background + * access. + * + * From the "backgroundPermission" attribute or, if not set null + * + * @hide + */ + @SystemApi + @TestApi + public String backgroundPermission; + + /** * The description string provided in the AndroidManifest file, if any. You * probably don't want to use this, since it will be null if the description * is in a resource. You probably want @@ -373,6 +388,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { protectionLevel = orig.protectionLevel; flags = orig.flags; group = orig.group; + backgroundPermission = orig.backgroundPermission; descriptionRes = orig.descriptionRes; requestRes = orig.requestRes; nonLocalizedDescription = orig.nonLocalizedDescription; @@ -436,6 +452,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { dest.writeInt(protectionLevel); dest.writeInt(flags); dest.writeString(group); + dest.writeString(backgroundPermission); dest.writeInt(descriptionRes); dest.writeInt(requestRes); TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags); @@ -475,6 +492,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { protectionLevel = source.readInt(); flags = source.readInt(); group = source.readString(); + backgroundPermission = source.readString(); descriptionRes = source.readInt(); requestRes = source.readInt(); nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); |
