From 8575da1cc0e3c9449e21bae270b489b8e815fccb Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 7 Apr 2016 17:56:06 +0000 Subject: [PATCH] Revert "Remove old FUSE bypass now that we have sdcardfs." This reverts commit feef8b62ee60c8418bd7238522c06098e61eecff. Change-Id: I90a3b8edf95cb5b631a85168671cf8b5a406d9ea --- .../android/os/storage/StorageManager.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index f2e316cf214f2..720d3f7b860ae 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -1178,7 +1178,23 @@ public class StorageManager { /** {@hide} */ public static File maybeTranslateEmulatedPathToInternal(File path) { - // Disabled now that FUSE has been replaced by sdcardfs + final IMountService mountService = IMountService.Stub.asInterface( + ServiceManager.getService("mount")); + try { + final VolumeInfo[] vols = mountService.getVolumes(0); + for (VolumeInfo vol : vols) { + if ((vol.getType() == VolumeInfo.TYPE_EMULATED + || vol.getType() == VolumeInfo.TYPE_PUBLIC) && vol.isMountedReadable()) { + final File internalPath = FileUtils.rewriteAfterRename(vol.getPath(), + vol.getInternalPath(), path); + if (internalPath != null && internalPath.exists()) { + return internalPath; + } + } + } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } return path; }