From b887d1903822d8b56f81c62a6c3f54e36c2cb3af Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Mon, 6 Feb 2023 15:21:25 +0000 Subject: [PATCH] Fix getStorageVolumes to return public volumes visible to userIdSharingMedia with. In ag/16708639, getStorageVolumes was modified to return volumes mounted on the calling user. Clone profile is an exception to this rule, as by definition, it should access the public volumes available to its parent user. To fix this we allow a volume to be returned if: 1. Its a public volume and 2. Its visible to the userId the calling user shares media with. Bug: b/265772860 b/265724297 b/260950918 Test: atest AppCloningHostTest Change-Id: I84a57ea13b08a5f1cd0095e944aeacc3434df4de --- .../core/java/com/android/server/StorageManagerService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index fdfcfa3b43c95..723df0e25ddf5 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -3851,8 +3851,12 @@ class StorageManagerService extends IStorageManager.Stub // Return both read only and write only volumes. When includeSharedProfile is // true, all the volumes of userIdSharingMedia should be returned when queried // from the user it shares media with + // Public Volumes will be also be returned if visible to the + // userIdSharingMedia with. match = vol.isVisibleForUser(userId) || (!vol.isVisible() && includeInvisible && vol.getPath() != null) + || (vol.getType() == VolumeInfo.TYPE_PUBLIC + && vol.isVisibleForUser(userIdSharingMedia)) || (includeSharedProfile && vol.isVisibleForUser(userIdSharingMedia)); } if (!match) continue;