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
This commit is contained in:
Zim
2019-11-26 11:36:04 +00:00
committed by Zimuzo Ezeozue
parent 76a011ba2a
commit 2dca320fbb

View File

@@ -160,7 +160,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
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 @@ 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;