diff options
| -rw-r--r-- | core/java/android/os/Process.java | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 2 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 7 | ||||
| -rwxr-xr-x | core/res/res/values/strings.xml | 5 | ||||
| -rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 14 |
5 files changed, 26 insertions, 4 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 851b8df..d5fca4d 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -584,6 +584,8 @@ public class Process { } if (mountExternal == Zygote.MOUNT_EXTERNAL_MULTIUSER) { argsForZygote.add("--mount-external-multiuser"); + } else if (mountExternal == Zygote.MOUNT_EXTERNAL_MULTIUSER_ALL) { + argsForZygote.add("--mount-external-multiuser-all"); } argsForZygote.add("--target-sdk-version=" + targetSdkVersion); diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index d6f1807..d24513a 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -529,6 +529,8 @@ class ZygoteConnection { niceName = arg.substring(arg.indexOf('=') + 1); } else if (arg.equals("--mount-external-multiuser")) { mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER; + } else if (arg.equals("--mount-external-multiuser-all")) { + mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER_ALL; } else { break; } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 96eb54a..abb9c0f 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -725,6 +725,13 @@ android:description="@string/permdesc_mediaStorageWrite" android:protectionLevel="signature|system" /> + <!-- Allows an application to access all multi-user external storage @hide --> + <permission android:name="android.permission.ACCESS_ALL_EXTERNAL_STORAGE" + android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS" + android:label="@string/permlab_sdcardAccessAll" + android:description="@string/permdesc_sdcardAccessAll" + android:protectionLevel="signature" /> + <!-- ============================================ --> <!-- Permissions for low-level system interaction --> <!-- ============================================ --> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index b0437a2..3178af0 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1616,6 +1616,11 @@ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=NONE] --> <string name="permdesc_mediaStorageWrite" product="default">Allows the app to modify the contents of the internal media storage.</string> + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] --> + <string name="permlab_sdcardAccessAll">access external storage of all users</string> + <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> + <string name="permdesc_sdcardAccessAll">Allows the app to access external storage for all users.</string> + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_cache_filesystem">access the cache filesystem</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 20be15e..a061d58 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -1991,13 +1991,19 @@ public final class ActivityManagerService extends ActivityManagerNative try { final PackageManager pm = mContext.getPackageManager(); gids = pm.getPackageGids(app.info.packageName); + + if (Environment.isExternalStorageEmulated()) { + if (pm.checkPermission( + android.Manifest.permission.ACCESS_ALL_EXTERNAL_STORAGE, + app.info.packageName) == PERMISSION_GRANTED) { + mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER_ALL; + } else { + mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER; + } + } } catch (PackageManager.NameNotFoundException e) { Slog.w(TAG, "Unable to retrieve gids", e); } - - if (Environment.isExternalStorageEmulated()) { - mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER; - } } if (mFactoryTest != SystemServer.FACTORY_TEST_OFF) { if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL |
