From a1798ca96079a3d910e2f63acf06949b892ab340 Mon Sep 17 00:00:00 2001 From: Himanshu Dagar Date: Fri, 10 Sep 2021 09:49:01 +0000 Subject: [PATCH] Avoid skipping creation of emulated volume for cloned profile user As of now, emulated volume is not getting created for the user if media provider instance is not running in that user space. But, in case of cloned profile user, where media provider instance is not running and media queries get redirected to the owner user space, we need to facilitate the creation of emulated volume. This CL takes care of this usecase. Bug: 197310110 Test: manual on Pixel5 Change-Id: I52cd40ed47df84a71c9c17cb2b51dc4a23d0d56d --- .../com/android/server/StorageManagerService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 3510501358121..fd78031c60f50 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -1541,7 +1541,18 @@ class StorageManagerService extends IStorageManager.Stub } if (vol.type == VolumeInfo.TYPE_EMULATED) { - if (!mStorageSessionController.supportsExternalStorage(vol.mountUserId)) { + final Context volumeUserContext = mContext.createContextAsUser( + UserHandle.of(vol.mountUserId), 0); + + boolean isMediaSharedWithParent = + (volumeUserContext != null) ? volumeUserContext.getSystemService( + UserManager.class).isMediaSharedWithParent() : false; + + // For all the users where media is shared with parent, creation of emulated volume + // should not be skipped even if media provider instance is not running in that user + // space + if (!isMediaSharedWithParent + && !mStorageSessionController.supportsExternalStorage(vol.mountUserId)) { Slog.d(TAG, "Ignoring volume " + vol.getId() + " because user " + Integer.toString(vol.mountUserId) + " does not support external storage.");