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
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
index 1e19786..ec445d4 100644
--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -160,7 +160,7 @@
final int userId = UserHandle.myUserId();
final List<VolumeInfo> 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 @@
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;