diff --git a/api/current.txt b/api/current.txt
index 824998362705a..97792529cae87 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9462,13 +9462,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 c58cf0fc22865..07cdfaa96e11f 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -9797,13 +9797,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 28f236878e4dc..0ad5240291902 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -795,31 +795,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" />
@@ -867,19 +867,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" />
@@ -1012,22 +1012,22 @@
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1115,13 +1115,13 @@
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1149,19 +1149,19 @@
@hide This should only be used by OEM's TvInputService's.
-->
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1176,7 +1176,7 @@
+ android:protectionLevel="signature|privileged" />
@@ -1187,12 +1187,12 @@
a camera is in use by an application.
@hide -->
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1203,17 +1203,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" />
@@ -1372,7 +1372,7 @@
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1414,7 +1414,7 @@
+ android:protectionLevel="signature|preinstalled|appop|pre23" />
@@ -1445,7 +1445,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" />
@@ -1647,7 +1647,7 @@
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged" />
@@ -1693,7 +1693,7 @@
it off to the various individual installer components
@hide -->
+ android:protectionLevel="signature|privileged" />
@@ -1703,40 +1703,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" />
@@ -1752,7 +1752,7 @@
and its icons.
Not for use by third-party applications. -->
+ android:protectionLevel="signature|privileged" />
@@ -1770,16 +1770,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" />
@@ -2091,40 +2091,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" />
@@ -2358,7 +2358,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" />
@@ -2524,11 +2524,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 60b19bb9f67ae..60ccbdb682140 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -8428,7 +8428,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.
@@ -8465,31 +8465,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;
}