Skip to content

Commit 2bd8d04

Browse files
author
Dianne Hackborn
committed
Fix issue #6641368: can't launch gallery
This is a revert of 1db3652, but with comments added so I don't make this mistake again. :) Change-Id: I053216279e3721f08f32f561bb989736ef619f82
1 parent a7e3a1e commit 2bd8d04

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/java/android/content/pm/PackageParser.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,13 @@ public SplitPermissionInfo(String rootPerm, String[] newPerms, int targetSdk) {
127127
*/
128128
public static final PackageParser.SplitPermissionInfo SPLIT_PERMISSIONS[] =
129129
new PackageParser.SplitPermissionInfo[] {
130+
// READ_EXTERNAL_STORAGE is always required when an app requests
131+
// WRITE_EXTERNAL_STORAGE, because we can't have an app that has
132+
// write access without read access. The hack here with the target
133+
// target SDK version ensures that this grant is always done.
130134
new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
131135
new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE },
132-
android.os.Build.VERSION_CODES.JELLY_BEAN),
136+
android.os.Build.VERSION_CODES.CUR_DEVELOPMENT+1),
133137
new PackageParser.SplitPermissionInfo(android.Manifest.permission.READ_CONTACTS,
134138
new String[] { android.Manifest.permission.READ_CALL_LOG },
135139
android.os.Build.VERSION_CODES.JELLY_BEAN),

tools/aapt/Command.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,9 @@ int doDump(Bundle* bundle)
12041204
}
12051205

12061206
// If the application has requested WRITE_EXTERNAL_STORAGE, we will
1207-
// force them to always take READ_EXTERNAL_STORAGE as well.
1207+
// force them to always take READ_EXTERNAL_STORAGE as well. We always
1208+
// do this (regardless of target API version) because we can't have
1209+
// an app with write permission but not read permission.
12081210
if (!hasReadExternalStoragePermission && hasWriteExternalStoragePermission) {
12091211
printf("uses-permission:'android.permission.READ_EXTERNAL_STORAGE'\n");
12101212
printf("uses-implied-permission:'android.permission.READ_EXTERNAL_STORAGE'," \

0 commit comments

Comments
 (0)