From 123a0e712eabcfec5987f9423e4b5db67231a31a Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Fri, 10 Jun 2016 11:09:11 -0700 Subject: [PATCH] Check for valid paths when getVolumeList() returns invisible volumes. The FLAG_INCLUDE_INVISIBLE was created to let SM.getStorageVolumes() return mounted volumes (like USB drives), but in the current form it might return invalid volumes. For example, when a SD Card is adopted as an internal storage, it will return 2 volumes instead of one, the "bad" one being: VolumeInfo{emulated}: type=EMULATED diskId=null partGuid=null mountFlags=0 mountUserId=-1 state=UNMOUNTED fsType=null fsUuid=null fsLabel=null path=null internalPath=null As such, we need to filter out those volumes that don't have a path. BUG: 29250241 Change-Id: I3f84b53eac98f31f918d843c70f9d42983e2a438 --- services/core/java/com/android/server/MountService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java index c89b6ea4f18d7..9c75a009d7af9 100644 --- a/services/core/java/com/android/server/MountService.java +++ b/services/core/java/com/android/server/MountService.java @@ -3031,7 +3031,8 @@ class MountService extends IMountService.Stub if (forWrite) { match = vol.isVisibleForWrite(userId); } else { - match = vol.isVisibleForRead(userId) || includeInvisible; + match = vol.isVisibleForRead(userId) + || (includeInvisible && vol.getPath() != null); } if (!match) continue;