diff --git a/api/current.txt b/api/current.txt index 2e2cae692c9f6..399c1df7e8ece 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9443,13 +9443,15 @@ package android.content.pm { field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20 field public static final int PROTECTION_FLAG_INSTALLER = 256; // 0x100 field public static final int PROTECTION_FLAG_PRE23 = 128; // 0x80 - field public static final int PROTECTION_FLAG_SYSTEM = 16; // 0x10 + field public static final int PROTECTION_FLAG_PREINSTALLED = 1024; // 0x400 + field public static final int PROTECTION_FLAG_PRIVILEGED = 16; // 0x10 + field public static final deprecated int PROTECTION_FLAG_SYSTEM = 16; // 0x10 field public static final int PROTECTION_FLAG_VERIFIER = 512; // 0x200 field public static final int PROTECTION_MASK_BASE = 15; // 0xf field public static final int PROTECTION_MASK_FLAGS = 4080; // 0xff0 field public static final int PROTECTION_NORMAL = 0; // 0x0 field public static final int PROTECTION_SIGNATURE = 2; // 0x2 - field public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3; // 0x3 + field public static final deprecated int PROTECTION_SIGNATURE_OR_SYSTEM = 3; // 0x3 field public int descriptionRes; field public int flags; field public java.lang.String group; diff --git a/api/system-current.txt b/api/system-current.txt index e84ad3d21eb89..e64567cd18cf1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9778,13 +9778,15 @@ package android.content.pm { field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20 field public static final int PROTECTION_FLAG_INSTALLER = 256; // 0x100 field public static final int PROTECTION_FLAG_PRE23 = 128; // 0x80 - field public static final int PROTECTION_FLAG_SYSTEM = 16; // 0x10 + field public static final int PROTECTION_FLAG_PREINSTALLED = 1024; // 0x400 + field public static final int PROTECTION_FLAG_PRIVILEGED = 16; // 0x10 + field public static final deprecated int PROTECTION_FLAG_SYSTEM = 16; // 0x10 field public static final int PROTECTION_FLAG_VERIFIER = 512; // 0x200 field public static final int PROTECTION_MASK_BASE = 15; // 0xf field public static final int PROTECTION_MASK_FLAGS = 4080; // 0xff0 field public static final int PROTECTION_NORMAL = 0; // 0x0 field public static final int PROTECTION_SIGNATURE = 2; // 0x2 - field public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3; // 0x3 + field public static final deprecated int PROTECTION_SIGNATURE_OR_SYSTEM = 3; // 0x3 field public int descriptionRes; field public int flags; field public java.lang.String group; diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java index 1857ecfa53bb7..2828d83bcdae0 100644 --- a/core/java/android/content/pm/PermissionInfo.java +++ b/core/java/android/content/pm/PermissionInfo.java @@ -48,17 +48,25 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { public static final int PROTECTION_SIGNATURE = 2; /** - * System-level value for {@link #protectionLevel}, corresponding - * to the signatureOrSystem value of - * {@link android.R.attr#protectionLevel}. + * @deprecated Use {@link #PROTECTION_SIGNATURE}|{@link #PROTECTION_FLAG_PRIVILEGED} + * instead. */ + @Deprecated public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3; /** * Additional flag for {@link #protectionLevel}, corresponding - * to the system value of + * to the privileged value of * {@link android.R.attr#protectionLevel}. */ + public static final int PROTECTION_FLAG_PRIVILEGED = 0x10; + + /** + * @deprecated Old name for {@link #PROTECTION_FLAG_PRIVILEGED}, which + * is now very confusing because it only applies to privileged apps, not all + * apps on the system image. + */ + @Deprecated public static final int PROTECTION_FLAG_SYSTEM = 0x10; /** @@ -96,6 +104,13 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { */ public static final int PROTECTION_FLAG_VERIFIER = 0x200; + /** + * Additional flag for {@link #protectionLevel}, corresponding + * to the preinstalled value of + * {@link android.R.attr#protectionLevel}. + */ + public static final int PROTECTION_FLAG_PREINSTALLED = 0x400; + /** * Mask for {@link #protectionLevel}: the basic protection type. */ @@ -161,7 +176,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { /** @hide */ public static int fixProtectionLevel(int level) { if (level == PROTECTION_SIGNATURE_OR_SYSTEM) { - level = PROTECTION_SIGNATURE | PROTECTION_FLAG_SYSTEM; + level = PROTECTION_SIGNATURE | PROTECTION_FLAG_PRIVILEGED; } return level; } @@ -183,8 +198,8 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { protLevel = "signatureOrSystem"; break; } - if ((level&PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) { - protLevel += "|system"; + if ((level&PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0) { + protLevel += "|privileged"; } if ((level&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) { protLevel += "|development"; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e18e44cf316c4..074d1bd0394e9 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -785,31 +785,31 @@ to handle the respond-via-message action during incoming calls.

Not for use by third-party applications. --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -857,19 +857,19 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1002,22 +1002,22 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1105,13 +1105,13 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1139,19 +1139,19 @@ @hide This should only be used by OEM's TvInputService's. --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1166,7 +1166,7 @@ + android:protectionLevel="signature|privileged" /> @@ -1177,12 +1177,12 @@ a camera is in use by an application. @hide --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1193,17 +1193,17 @@ Does not include placing calls.

Not for use by third-party applications. --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged" /> @@ -1362,7 +1362,7 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1404,7 +1404,7 @@ + android:protectionLevel="signature|preinstalled|appop|pre23" /> @@ -1435,7 +1435,7 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged|development" /> Not for use by third-party applications. --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged|development" /> @@ -1637,7 +1637,7 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -1683,7 +1683,7 @@ it off to the various individual installer components @hide --> + android:protectionLevel="signature|privileged" /> @@ -1693,40 +1693,40 @@ + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|development" /> @@ -1742,7 +1742,7 @@ and its icons.

Not for use by third-party applications. --> + android:protectionLevel="signature|privileged" /> @@ -1760,16 +1760,16 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged|installer" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -2081,40 +2081,40 @@

Not for use by third-party applications.

@hide --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> Not for use by third-party applications. @hide --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged|development|appop" /> + android:protectionLevel="signature|privileged|development" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -2348,7 +2348,7 @@ by system services like download manager and media server. Not for use by third party apps. @hide --> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> @@ -2514,11 +2514,11 @@ + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" /> diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index c501329b6ab3c..1515703ec08b7 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -200,7 +200,7 @@ together. --> + + @@ -226,6 +228,10 @@ + + diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 9c0d408c7aff4..124214c84b5f2 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -8430,7 +8430,7 @@ public class PackageManagerService extends IPackageManager.Stub { || (compareSignatures(mPlatformPackage.mSignatures, pkg.mSignatures) == PackageManager.SIGNATURE_MATCH); if (!allowed && (bp.protectionLevel - & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) { + & PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0) { if (isSystemApp(pkg)) { // For updated system applications, a system permission // is granted only if it had been defined by the original application. @@ -8467,31 +8467,39 @@ public class PackageManagerService extends IPackageManager.Stub { } } } - if (!allowed && (bp.protectionLevel - & PermissionInfo.PROTECTION_FLAG_PRE23) != 0 - && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.MNC) { - // If this was a previously normal/dangerous permission that got moved - // to a system permission as part of the runtime permission redesign, then - // we still want to blindly grant it to old apps. - allowed = true; - } - if (!allowed && (bp.protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTALLER) != 0 - && pkg.packageName.equals(mRequiredInstallerPackage)) { - // If this permission is to be granted to the system installer and - // this app is an installer, then it gets the permission. - allowed = true; - } - if (!allowed && (bp.protectionLevel & PermissionInfo.PROTECTION_FLAG_VERIFIER) != 0 - && pkg.packageName.equals(mRequiredVerifierPackage)) { - // If this permission is to be granted to the system verifier and - // this app is a verifier, then it gets the permission. - allowed = true; - } - if (!allowed && (bp.protectionLevel - & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) { - // For development permissions, a development permission - // is granted only if it was already granted. - allowed = origPermissions.hasInstallPermission(perm); + if (!allowed) { + if (!allowed && (bp.protectionLevel + & PermissionInfo.PROTECTION_FLAG_PRE23) != 0 + && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.MNC) { + // If this was a previously normal/dangerous permission that got moved + // to a system permission as part of the runtime permission redesign, then + // we still want to blindly grant it to old apps. + allowed = true; + } + if (!allowed && (bp.protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTALLER) != 0 + && pkg.packageName.equals(mRequiredInstallerPackage)) { + // If this permission is to be granted to the system installer and + // this app is an installer, then it gets the permission. + allowed = true; + } + if (!allowed && (bp.protectionLevel & PermissionInfo.PROTECTION_FLAG_VERIFIER) != 0 + && pkg.packageName.equals(mRequiredVerifierPackage)) { + // If this permission is to be granted to the system verifier and + // this app is a verifier, then it gets the permission. + allowed = true; + } + if (!allowed && (bp.protectionLevel + & PermissionInfo.PROTECTION_FLAG_PREINSTALLED) != 0 + && isSystemApp(pkg)) { + // Any pre-installed system app is allowed to get this permission. + allowed = true; + } + if (!allowed && (bp.protectionLevel + & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) { + // For development permissions, a development permission + // is granted only if it was already granted. + allowed = origPermissions.hasInstallPermission(perm); + } } return allowed; }