diff options
author | Svet Ganov <svetoslavganov@google.com> | 2015-07-06 15:51:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-06 15:52:01 +0000 |
commit | 10c111ed35a0282ddf5dda540c53e3831bc9b0ec (patch) | |
tree | fa36db1f01c29be0681e63992431973bb6648b1a | |
parent | cb8d2e21564ec749696dc3095524dafffa915c38 (diff) | |
parent | 77ab6a888afaeb9010c7c3884adcd4819dbcee66 (diff) | |
download | frameworks_base-10c111ed35a0282ddf5dda540c53e3831bc9b0ec.zip frameworks_base-10c111ed35a0282ddf5dda540c53e3831bc9b0ec.tar.gz frameworks_base-10c111ed35a0282ddf5dda540c53e3831bc9b0ec.tar.bz2 |
Merge "Show basic feature warning for default granted permissions" into mnc-dev
-rw-r--r-- | api/system-current.txt | 5 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 32 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java | 11 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/Settings.java | 17 |
4 files changed, 48 insertions, 17 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index e3f003c..f7955dd 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9675,11 +9675,6 @@ package android.content.pm { field public static final java.lang.String FEATURE_WEBVIEW = "android.software.webview"; field public static final java.lang.String FEATURE_WIFI = "android.hardware.wifi"; field public static final java.lang.String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; - field public static final int FLAG_PERMISSION_POLICY_FIXED = 4; // 0x4 - field public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 8; // 0x8 - field public static final int FLAG_PERMISSION_SYSTEM_FIXED = 16; // 0x10 - field public static final int FLAG_PERMISSION_USER_FIXED = 2; // 0x2 - field public static final int FLAG_PERMISSION_USER_SET = 1; // 0x1 field public static final int GET_ACTIVITIES = 1; // 0x1 field public static final int GET_CONFIGURATIONS = 16384; // 0x4000 field public static final int GET_DISABLED_COMPONENTS = 512; // 0x200 diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index dd1c5c2..538007a 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -1924,7 +1924,6 @@ public abstract class PackageManager { * * @hide */ - @SystemApi public static final int FLAG_PERMISSION_USER_SET = 1 << 0; /** @@ -1934,7 +1933,6 @@ public abstract class PackageManager { * * @hide */ - @SystemApi public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; /** @@ -1944,7 +1942,6 @@ public abstract class PackageManager { * * @hide */ - @SystemApi public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; /** @@ -1957,7 +1954,6 @@ public abstract class PackageManager { * * @hide */ - @SystemApi public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; /** @@ -1966,9 +1962,19 @@ public abstract class PackageManager { * * @hide */ - @SystemApi public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; + + /** + * Permission flag: The permission is granted by default because it + * enables app functionality that is expected to work out-of-the-box + * for providing a smooth user experience. For example, the phone app + * is expected to have the phone permission. + * + * @hide + */ + public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; + /** * Mask for all permission flags. * @@ -2474,7 +2480,8 @@ public abstract class PackageManager { FLAG_PERMISSION_USER_FIXED, FLAG_PERMISSION_POLICY_FIXED, FLAG_PERMISSION_REVOKE_ON_UPGRADE, - FLAG_PERMISSION_SYSTEM_FIXED}) + FLAG_PERMISSION_SYSTEM_FIXED, + FLAG_PERMISSION_GRANTED_BY_DEFAULT}) @Retention(RetentionPolicy.SOURCE) public @interface PermissionFlags {} @@ -4634,6 +4641,19 @@ public abstract class PackageManager { } /** {@hide} */ + public static String permissionFlagToString(int flag) { + switch (flag) { + case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "FLAG_PERMISSION_GRANTED_BY_DEFAULT"; + case FLAG_PERMISSION_POLICY_FIXED: return "FLAG_PERMISSION_POLICY_FIXED"; + case FLAG_PERMISSION_SYSTEM_FIXED: return "FLAG_PERMISSION_SYSTEM_FIXED"; + case FLAG_PERMISSION_USER_SET: return "FLAG_PERMISSION_USER_SET"; + case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "FLAG_PERMISSION_REVOKE_ON_UPGRADE"; + case FLAG_PERMISSION_USER_FIXED: return "FLAG_PERMISSION_USER_FIXED"; + default: return Integer.toString(flag); + } + } + + /** {@hide} */ public static class LegacyPackageInstallObserver extends PackageInstallObserver { private final IPackageInstallObserver mLegacy; diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java index e459e26..8678d9a 100644 --- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java +++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java @@ -202,7 +202,8 @@ final class DefaultPermissionGrantPolicy { mService.grantRuntimePermission(pkg.packageName, permission, userId); mService.updatePermissionFlags(permission, pkg.packageName, PackageManager.MASK_PERMISSION_FLAGS, - PackageManager.FLAG_PERMISSION_SYSTEM_FIXED, userId); + PackageManager.FLAG_PERMISSION_SYSTEM_FIXED + | PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT, userId); if (DEBUG) { Log.i(TAG, "Granted " + permission + " to system component " + pkg.packageName); @@ -768,11 +769,13 @@ final class DefaultPermissionGrantPolicy { + pkg.packageName); } + int newFlags = PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT; if (systemFixed) { - mService.updatePermissionFlags(permission, pkg.packageName, - PackageManager.FLAG_PERMISSION_SYSTEM_FIXED, - PackageManager.FLAG_PERMISSION_SYSTEM_FIXED, userId); + newFlags |= PackageManager.FLAG_PERMISSION_SYSTEM_FIXED; } + + mService.updatePermissionFlags(permission, pkg.packageName, + newFlags, newFlags, userId); } } } diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 0ad2b4a..8ca8331 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -4333,12 +4333,25 @@ final class Settings { } pw.print(prefix); pw.print(" "); pw.print(permissionState.getName()); pw.print(", granted="); pw.print(permissionState.isGranted()); - pw.print(", flags=0x"); pw.println(Integer.toHexString( + pw.print(", flags="); pw.println(permissionFlagsToString( permissionState.getFlags())); } } } + private static String permissionFlagsToString(int flags) { + StringBuilder flagsString = new StringBuilder(); + flagsString.append("[ "); + while (flags != 0) { + final int flag = 1 << Integer.numberOfTrailingZeros(flags); + flags &= ~flag; + flagsString.append(PackageManager.permissionFlagToString(flag)); + flagsString.append(' '); + } + flagsString.append(']'); + return flagsString.toString(); + } + void dumpInstallPermissionsLPr(PrintWriter pw, String prefix, ArraySet<String> permissionNames, PermissionsState permissionsState) { List<PermissionState> permissionStates = permissionsState.getInstallPermissionStates(); @@ -4351,7 +4364,7 @@ final class Settings { } pw.print(prefix); pw.print(" "); pw.print(permissionState.getName()); pw.print(", granted="); pw.print(permissionState.isGranted()); - pw.print(", flags=0x"); pw.println(Integer.toHexString( + pw.print(", flags="); pw.println(permissionFlagsToString( permissionState.getFlags())); } } |