From 7924512aa12c6af37d90e8ccfcdf04eb78a294a3 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 12 Mar 2012 10:51:26 -0700 Subject: [PATCH] Add new READ_EXTERNAL_STORAGE permission. Also adds some initial compatibility code for dealing with it. Change-Id: I104bff11798349e4aaa6da9b7be787b257daa1bb --- api/current.txt | 1 + .../android/content/pm/PackageParser.java | 45 ++++++++++++++++++- core/res/AndroidManifest.xml | 7 +++ core/res/res/values/strings.xml | 9 ++++ data/etc/platform.xml | 4 ++ tools/aapt/Command.cpp | 12 +++++ 6 files changed, 76 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index f7d6bce5c5627..e677eb2683275 100644 --- a/api/current.txt +++ b/api/current.txt @@ -76,6 +76,7 @@ package android { field public static final java.lang.String PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS"; field public static final java.lang.String READ_CALENDAR = "android.permission.READ_CALENDAR"; field public static final java.lang.String READ_CONTACTS = "android.permission.READ_CONTACTS"; + field public static final java.lang.String READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE"; field public static final java.lang.String READ_FRAME_BUFFER = "android.permission.READ_FRAME_BUFFER"; field public static final java.lang.String READ_HISTORY_BOOKMARKS = "com.android.browser.permission.READ_HISTORY_BOOKMARKS"; field public static final java.lang.String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE"; diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index e88ee02eb6857..207f077eff353 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -89,11 +89,25 @@ public class PackageParser { this.fileVersion = fileVersion; } } - + + /** @hide */ + public static class SplitPermissionInfo { + public final String rootPerm; + public final String[] newPerms; + + public SplitPermissionInfo(String rootPerm, String[] newPerms) { + this.rootPerm = rootPerm; + this.newPerms = newPerms; + } + } + /** * List of new permissions that have been added since 1.0. * NOTE: These must be declared in SDK version order, with permissions * added to older SDKs appearing before those added to newer SDKs. + * If sdkVersion is 0, then this is not a permission that we want to + * automatically add to older apps, but we do want to allow it to be + * granted during a platform update. * @hide */ public static final PackageParser.NewPermissionInfo NEW_PERMISSIONS[] = @@ -104,6 +118,17 @@ public class PackageParser { android.os.Build.VERSION_CODES.DONUT, 0) }; + /** + * List of permissions that have been split into more granular or dependent + * permissions. + * @hide + */ + 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 }) + }; + private String mArchiveSourcePath; private String[] mSeparateProcesses; private boolean mOnlyCoreApps; @@ -1245,7 +1270,23 @@ public class PackageParser { if (implicitPerms != null) { Slog.i(TAG, implicitPerms.toString()); } - + + final int NS = PackageParser.SPLIT_PERMISSIONS.length; + for (int is=0; is 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.DONUT)) { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 17d2212de4ede..8f03fe0eb842e 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -639,6 +639,13 @@ android:label="@string/permgrouplab_storage" android:description="@string/permgroupdesc_storage" /> + + + Allows the app to write new words into the user dictionary. + + read USB storage contents + + read SD card contents + + Allows the app to read contents of USB storage. + + Allows the app to read contents of SD card. + modify/delete USB storage contents diff --git a/data/etc/platform.xml b/data/etc/platform.xml index 8be1db2bb1f6d..4b93e74bf0141 100644 --- a/data/etc/platform.xml +++ b/data/etc/platform.xml @@ -54,6 +54,10 @@ + + + + diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index c79e243828c42..198fce40ec8c4 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -636,6 +636,9 @@ int doDump(Bundle* bundle) bool hasWriteExternalStoragePermission = false; bool hasReadPhoneStatePermission = false; + // If an app requests write storage, they will also get read storage. + bool hasReadExternalStoragePermission = 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 @@ -999,6 +1002,8 @@ int doDump(Bundle* bundle) hasTelephonyPermission = true; } else if (name == "android.permission.WRITE_EXTERNAL_STORAGE") { hasWriteExternalStoragePermission = true; + } else if (name == "android.permission.READ_EXTERNAL_STORAGE") { + hasReadExternalStoragePermission = true; } else if (name == "android.permission.READ_PHONE_STATE") { hasReadPhoneStatePermission = true; } @@ -1163,12 +1168,19 @@ int doDump(Bundle* bundle) if (targetSdk < 4) { if (!hasWriteExternalStoragePermission) { printf("uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE'\n"); + hasWriteExternalStoragePermission = true; } if (!hasReadPhoneStatePermission) { printf("uses-permission:'android.permission.READ_PHONE_STATE'\n"); } } + // If the application has requested WRITE_EXTERNAL_STORAGE, we will + // force them to always take READ_EXTERNAL_STORAGE as well. + if (!hasReadExternalStoragePermission && hasWriteExternalStoragePermission) { + printf("uses-permission:'android.permission.READ_EXTERNAL_STORAGE'\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