From 2dca320fbbf917165b75468b80cea951ad959c7e Mon Sep 17 00:00:00 2001 From: Zim Date: Tue, 26 Nov 2019 11:36:04 +0000 Subject: [PATCH] Fix volumes registered in ExternalStorageProvider Now that emulated volumes are per user, ESP should not register any volume that does not match it's running user. Bug: 144936488 Test: On device with secondary user, Files > Show internal storage displays "internal storage" Change-Id: If4820c684a0a8ef52cc97ae9087b1a0884f9cee7 --- .../android/externalstorage/ExternalStorageProvider.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java index 1e19786f5d415..ec445d4dcbee1 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java @@ -160,7 +160,7 @@ public class ExternalStorageProvider extends FileSystemProvider { final int userId = UserHandle.myUserId(); final List volumes = mStorageManager.getVolumes(); for (VolumeInfo volume : volumes) { - if (!volume.isMountedReadable()) continue; + if (!volume.isMountedReadable() || volume.getMountUserId() != userId) continue; final String rootId; final String title; @@ -192,9 +192,8 @@ public class ExternalStorageProvider extends FileSystemProvider { title = mStorageManager.getBestVolumeDescription(privateVol); storageUuid = StorageManager.convert(privateVol.fsUuid); } - } else if ((volume.getType() == VolumeInfo.TYPE_PUBLIC - || volume.getType() == VolumeInfo.TYPE_STUB) - && volume.getMountUserId() == userId) { + } else if (volume.getType() == VolumeInfo.TYPE_PUBLIC + || volume.getType() == VolumeInfo.TYPE_STUB) { rootId = volume.getFsUuid(); title = mStorageManager.getBestVolumeDescription(volume); storageUuid = null;