diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-04-06 11:11:32 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-06 11:11:32 -0700 |
commit | 29d6fa9d8b651b6940e6f3f9182f5b72c404c739 (patch) | |
tree | 87c56ad1fb531a82f86f81b7622e8dd95f4a1ecc | |
parent | dc0dbbd4a005f16624978b95817b33156acac526 (diff) | |
parent | 31b0e0e86ad061cd8005e80817bcad017e2d56dd (diff) | |
download | frameworks_base-29d6fa9d8b651b6940e6f3f9182f5b72c404c739.zip frameworks_base-29d6fa9d8b651b6940e6f3f9182f5b72c404c739.tar.gz frameworks_base-29d6fa9d8b651b6940e6f3f9182f5b72c404c739.tar.bz2 |
Merge "Implement call log permission compatibility."
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 16 | ||||
-rw-r--r-- | tools/aapt/Command.cpp | 24 |
2 files changed, 37 insertions, 3 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 15ccda3..7ff9bfa 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -94,10 +94,12 @@ public class PackageParser { public static class SplitPermissionInfo { public final String rootPerm; public final String[] newPerms; + public final int targetSdk; - public SplitPermissionInfo(String rootPerm, String[] newPerms) { + public SplitPermissionInfo(String rootPerm, String[] newPerms, int targetSdk) { this.rootPerm = rootPerm; this.newPerms = newPerms; + this.targetSdk = targetSdk; } } @@ -126,7 +128,14 @@ public class PackageParser { public static final PackageParser.SplitPermissionInfo SPLIT_PERMISSIONS[] = new PackageParser.SplitPermissionInfo[] { new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, - new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }) + new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, + android.os.Build.VERSION_CODES.CUR_DEVELOPMENT+1), + new PackageParser.SplitPermissionInfo(android.Manifest.permission.READ_CONTACTS, + new String[] { android.Manifest.permission.READ_CALL_LOG }, + android.os.Build.VERSION_CODES.JELLY_BEAN), + new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_CONTACTS, + new String[] { android.Manifest.permission.WRITE_CALL_LOG }, + android.os.Build.VERSION_CODES.JELLY_BEAN) }; private String mArchiveSourcePath; @@ -1293,7 +1302,8 @@ public class PackageParser { for (int is=0; is<NS; is++) { final PackageParser.SplitPermissionInfo spi = PackageParser.SPLIT_PERMISSIONS[is]; - if (!pkg.requestedPermissions.contains(spi.rootPerm)) { + if (pkg.applicationInfo.targetSdkVersion >= spi.targetSdk + || !pkg.requestedPermissions.contains(spi.rootPerm)) { break; } for (int in=0; in<spi.newPerms.length; in++) { diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 198fce4..689aa8e 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -639,6 +639,12 @@ int doDump(Bundle* bundle) // If an app requests write storage, they will also get read storage. bool hasReadExternalStoragePermission = false; + // Implement transition to read and write call log. + bool hasReadContactsPermission = false; + bool hasWriteContactsPermission = false; + bool hasReadCallLogPermission = false; + bool hasWriteCallLogPermission = false; + // This next group of variables is used to implement a group of // backward-compatibility heuristics necessitated by the addition of // some new uses-feature constants in 2.1 and 2.2. In most cases, the @@ -1006,6 +1012,14 @@ int doDump(Bundle* bundle) hasReadExternalStoragePermission = true; } else if (name == "android.permission.READ_PHONE_STATE") { hasReadPhoneStatePermission = true; + } else if (name == "android.permission.READ_CONTACTS") { + hasReadContactsPermission = true; + } else if (name == "android.permission.WRITE_CONTACTS") { + hasWriteContactsPermission = true; + } else if (name == "android.permission.READ_CALL_LOG") { + hasReadCallLogPermission = true; + } else if (name == "android.permission.WRITE_CALL_LOG") { + hasWriteCallLogPermission = true; } printf("uses-permission:'%s'\n", name.string()); } else { @@ -1181,6 +1195,16 @@ int doDump(Bundle* bundle) printf("uses-permission:'android.permission.READ_EXTERNAL_STORAGE'\n"); } + // Pre-JellyBean call log permission compatibility. + if (targetSdk < 16) { + if (!hasReadCallLogPermission && hasReadContactsPermission) { + printf("uses-permission:'android.permission.READ_CALL_LOG'\n"); + } + if (!hasWriteCallLogPermission && hasWriteContactsPermission) { + printf("uses-permission:'android.permission.WRITE_CALL_LOG'\n"); + } + } + /* The following blocks handle printing "inferred" uses-features, based * on whether related features or permissions are used by the app. * Note that the various spec*Feature variables denote whether the |