From c247fa136639dd07278b1954e5fba78ade60614c Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Fri, 2 Jun 2017 10:29:22 -0700 Subject: [PATCH] Change protection level from ephemeral to instant Change-Id: If4b01e5f0728f1d1d7e6903b362dcbedc67a9b3f Fixes: 62264194 Test: Manual. install an instant app and see that it still works --- api/current.txt | 1 + api/system-current.txt | 2 +- api/test-current.txt | 2 +- .../android/content/pm/PackageParser.java | 4 ++-- .../android/content/pm/PermissionInfo.java | 11 ++++------ core/res/AndroidManifest.xml | 20 +++++++++---------- core/res/res/values/attrs_manifest.xml | 4 ++-- .../com/android/server/pm/BasePermission.java | 2 +- .../server/pm/PackageManagerService.java | 4 ++-- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/api/current.txt b/api/current.txt index 80fdb30c8e476..be8954a68a867 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10887,6 +10887,7 @@ package android.content.pm { 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_INSTALLER = 256; // 0x100 + field public static final int PROTECTION_FLAG_INSTANT = 4096; // 0x1000 field public static final int PROTECTION_FLAG_PRE23 = 128; // 0x80 field public static final int PROTECTION_FLAG_PREINSTALLED = 1024; // 0x400 field public static final int PROTECTION_FLAG_PRIVILEGED = 16; // 0x10 diff --git a/api/system-current.txt b/api/system-current.txt index 0ca5af603155b..d5cc853acaf11 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11674,8 +11674,8 @@ 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_EPHEMERAL = 4096; // 0x1000 field public static final int PROTECTION_FLAG_INSTALLER = 256; // 0x100 + field public static final int PROTECTION_FLAG_INSTANT = 4096; // 0x1000 field public static final int PROTECTION_FLAG_PRE23 = 128; // 0x80 field public static final int PROTECTION_FLAG_PREINSTALLED = 1024; // 0x400 field public static final int PROTECTION_FLAG_PRIVILEGED = 16; // 0x10 diff --git a/api/test-current.txt b/api/test-current.txt index cba0dfdf27137..a5c74f21c07f8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -10928,8 +10928,8 @@ 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_EPHEMERAL = 4096; // 0x1000 field public static final int PROTECTION_FLAG_INSTALLER = 256; // 0x100 + field public static final int PROTECTION_FLAG_INSTANT = 4096; // 0x1000 field public static final int PROTECTION_FLAG_PRE23 = 128; // 0x80 field public static final int PROTECTION_FLAG_PREINSTALLED = 1024; // 0x400 field public static final int PROTECTION_FLAG_PRIVILEGED = 16; // 0x10 diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 7cc02b4f16686..9b9499cd602d6 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3235,11 +3235,11 @@ public class PackageParser { perm.info.protectionLevel = PermissionInfo.fixProtectionLevel(perm.info.protectionLevel); if ((perm.info.protectionLevel&PermissionInfo.PROTECTION_MASK_FLAGS) != 0) { - if ( (perm.info.protectionLevel&PermissionInfo.PROTECTION_FLAG_EPHEMERAL) == 0 + if ( (perm.info.protectionLevel&PermissionInfo.PROTECTION_FLAG_INSTANT) == 0 && (perm.info.protectionLevel&PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY) == 0 && (perm.info.protectionLevel&PermissionInfo.PROTECTION_MASK_BASE) != PermissionInfo.PROTECTION_SIGNATURE) { - outError[0] = " protectionLevel specifies a non-ephemeral flag but is " + outError[0] = " protectionLevel specifies a non-instnat flag but is " + "not based on signature type"; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java index 694e607815465..797db54973907 100644 --- a/core/java/android/content/pm/PermissionInfo.java +++ b/core/java/android/content/pm/PermissionInfo.java @@ -122,13 +122,10 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { /** * Additional flag for {@link #protectionLevel}, corresponding - * to the ephemeral value of + * to the instant value of * {@link android.R.attr#protectionLevel}. - * @hide */ - @SystemApi - @TestApi - public static final int PROTECTION_FLAG_EPHEMERAL = 0x1000; + public static final int PROTECTION_FLAG_INSTANT = 0x1000; /** * Additional flag for {@link #protectionLevel}, corresponding @@ -254,8 +251,8 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { if ((level&PermissionInfo.PROTECTION_FLAG_SETUP) != 0) { protLevel += "|setup"; } - if ((level&PermissionInfo.PROTECTION_FLAG_EPHEMERAL) != 0) { - protLevel += "|ephemeral"; + if ((level&PermissionInfo.PROTECTION_FLAG_INSTANT) != 0) { + protLevel += "|instant"; } if ((level&PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY) != 0) { protLevel += "|runtime"; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 5b0f8d53c0274..f294b98712c62 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -770,7 +770,7 @@ android:permissionGroup="android.permission-group.LOCATION" android:label="@string/permlab_accessFineLocation" android:description="@string/permdesc_accessFineLocation" - android:protectionLevel="dangerous|ephemeral" /> + android:protectionLevel="dangerous|instant" /> @@ -814,13 +814,13 @@ android:protectionLevel="dangerous" /> + android:protectionLevel="dangerous|instant" /> @@ -1242,7 +1242,7 @@ + android:protectionLevel="normal|instant" /> + android:protectionLevel="signature|development|instant|appop" /> - - + diff --git a/services/core/java/com/android/server/pm/BasePermission.java b/services/core/java/com/android/server/pm/BasePermission.java index 21000388e7464..30fda1e5665e9 100644 --- a/services/core/java/com/android/server/pm/BasePermission.java +++ b/services/core/java/com/android/server/pm/BasePermission.java @@ -96,7 +96,7 @@ final class BasePermission { } public boolean isInstant() { - return (protectionLevel & PermissionInfo.PROTECTION_FLAG_EPHEMERAL) != 0; + return (protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTANT) != 0; } public boolean isRuntimeOnly() { diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 2db162d4b918e..ce63a26ba171f 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -18492,12 +18492,12 @@ public class PackageManagerService extends IPackageManager.Stub BasePermission bp = mSettings.mPermissions.get(perm.info.name); // Don't allow anyone but the system to define ephemeral permissions. - if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_FLAG_EPHEMERAL) != 0 + if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTANT) != 0 && !systemApp) { Slog.w(TAG, "Non-System package " + pkg.packageName + " attempting to delcare ephemeral permission " + perm.info.name + "; Removing ephemeral."); - perm.info.protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_EPHEMERAL; + perm.info.protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_INSTANT; } // Check whether the newly-scanned package wants to define an already-defined perm if (bp != null) {