diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-08-11 16:28:14 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-08-11 17:07:44 -0700 |
commit | 1abdb7123025e52512b2ed7a518f8c754c35f50a (patch) | |
tree | c6ee8a4b4b4f8cf7b865d2d537823d6a59dca441 /services/java/com/android/server/MountService.java | |
parent | 09335703572db7d6a9b43f3aba32074e473d6a0f (diff) |
APIs for multiple external storage devices.
Provide developer APIs to discover application-specific paths on
secondary external storage devices. Covers files, cache, and OBB
directories. Apps will not have write access outside their package-
specific directories on secondary devices, so only primary storage is
exposed through Environment.
Creation of .nomedia files will be handled by FUSE daemon in future
change.
Change-Id: Ifcce6201a686d80269d7285adb597c008cf8fa7c
Diffstat (limited to 'services/java/com/android/server/MountService.java')
-rw-r--r-- | services/java/com/android/server/MountService.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 83739f55e000..1facb8093625 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -190,6 +190,8 @@ class MountService extends IMountService.Stub /** When defined, base template for user-specific {@link StorageVolume}. */ private StorageVolume mEmulatedTemplate; + // TODO: separate storage volumes on per-user basis + @GuardedBy("mVolumesLock") private final ArrayList<StorageVolume> mVolumes = Lists.newArrayList(); /** Map from path to {@link StorageVolume} */ @@ -2605,6 +2607,7 @@ class MountService extends IMountService.Stub @VisibleForTesting public static String buildObbPath(final String canonicalPath, int userId, boolean forVold) { // TODO: allow caller to provide Environment for full testing + // TODO: extend to support OBB mounts on secondary external storage // Only adjust paths when storage is emulated if (!Environment.isExternalStorageEmulated()) { @@ -2617,10 +2620,10 @@ class MountService extends IMountService.Stub final UserEnvironment userEnv = new UserEnvironment(userId); // /storage/emulated/0 - final String externalPath = userEnv.getExternalStorageDirectory().toString(); + final String externalPath = userEnv.getExternalStorageDirectory().getAbsolutePath(); // /storage/emulated_legacy final String legacyExternalPath = Environment.getLegacyExternalStorageDirectory() - .toString(); + .getAbsolutePath(); if (path.startsWith(externalPath)) { path = path.substring(externalPath.length() + 1); @@ -2636,18 +2639,19 @@ class MountService extends IMountService.Stub path = path.substring(obbPath.length() + 1); if (forVold) { - return new File(Environment.getEmulatedStorageObbSource(), path).toString(); + return new File(Environment.getEmulatedStorageObbSource(), path).getAbsolutePath(); } else { final UserEnvironment ownerEnv = new UserEnvironment(UserHandle.USER_OWNER); - return new File(ownerEnv.getExternalStorageObbDirectory(), path).toString(); + return new File(ownerEnv.buildExternalStorageAndroidObbDirs()[0], path) + .getAbsolutePath(); } } // Handle normal external storage paths if (forVold) { - return new File(Environment.getEmulatedStorageSource(userId), path).toString(); + return new File(Environment.getEmulatedStorageSource(userId), path).getAbsolutePath(); } else { - return new File(userEnv.getExternalStorageDirectory(), path).toString(); + return new File(userEnv.getExternalDirs()[0], path).getAbsolutePath(); } } |