diff --git a/api/current.txt b/api/current.txt index 3ae5372c0db0c..0c61e35fffef7 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9469,6 +9469,7 @@ package android.content.pm { field public static final int PROTECTION_DANGEROUS = 1; // 0x1 field public static final int PROTECTION_FLAG_APPOP = 64; // 0x40 field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20 + 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_MASK_BASE = 15; // 0xf field public static final int PROTECTION_MASK_FLAGS = 240; // 0xf0 diff --git a/api/system-current.txt b/api/system-current.txt index 8a633df519add..ec81c094e86c0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9809,6 +9809,7 @@ package android.content.pm { field public static final int PROTECTION_DANGEROUS = 1; // 0x1 field public static final int PROTECTION_FLAG_APPOP = 64; // 0x40 field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20 + 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_MASK_BASE = 15; // 0xf field public static final int PROTECTION_MASK_FLAGS = 240; // 0xf0 diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java index 04dbff24b143c..0a1f148f9ebff 100644 --- a/core/java/android/content/pm/PermissionInfo.java +++ b/core/java/android/content/pm/PermissionInfo.java @@ -75,6 +75,13 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { */ public static final int PROTECTION_FLAG_APPOP = 0x40; + /** + * Additional flag for {@link #protectionLevel}, corresponding + * to the pre23 value of + * {@link android.R.attr#protectionLevel}. + */ + public static final int PROTECTION_FLAG_PRE23 = 0x80; + /** * Mask for {@link #protectionLevel}: the basic protection type. */ @@ -171,6 +178,9 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { if ((level&PermissionInfo.PROTECTION_FLAG_APPOP) != 0) { protLevel += "|appop"; } + if ((level&PermissionInfo.PROTECTION_FLAG_PRE23) != 0) { + protLevel += "|pre23"; + } return protLevel; } diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java index bb4a9482664b4..c54b28d097df6 100644 --- a/core/java/android/widget/AppSecurityPermissions.java +++ b/core/java/android/widget/AppSecurityPermissions.java @@ -553,7 +553,8 @@ public class AppSecurityPermissions { int existingReqFlags) { final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE; final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL); - final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS); + final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS) + || ((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_PRE23) != 0); final boolean isRequired = ((newReqFlags&PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 0); final boolean isDevelopment = diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index bd9b0145d168c..c40ae60e262dd 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1414,7 +1414,7 @@ + android:protectionLevel="signature|system|appop|pre23" /> diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 3cb4d7cd2cc81..70f9db9b1108c 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -215,6 +215,11 @@ + + diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 138544054c259..7ce2e17036c55 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -8354,6 +8354,14 @@ 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_DEVELOPMENT) != 0) { // For development permissions, a development permission diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml index dae7cc518bd46..73cb432f896b9 100644 --- a/tests/ActivityTests/AndroidManifest.xml +++ b/tests/ActivityTests/AndroidManifest.xml @@ -24,6 +24,7 @@ +