From 5b341d8532ddf9f9ffa88032bdbee0602aca83fa Mon Sep 17 00:00:00 2001 From: Saumya Pathak Date: Fri, 29 Apr 2022 17:44:01 +0000 Subject: [PATCH] Fix bug in getStorageVolumesIncludingSharedProfiles The API currently doesn't return clone profile volumes correctly because it only looks for volumes visible to the clone for read. Changed it to include writable volumes as well Test: atest AppCloningHostTest#testGetStorageVolumesIncludingSharedProfiles Bug: 230828743 Change-Id: I4db128027e622ab807c1fbee664dfa7d9a3a26aa --- .../core/java/com/android/server/StorageManagerService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index bc40170d39b72..5eec6e58e9250 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -3880,9 +3880,12 @@ class StorageManagerService extends IStorageManager.Stub match = vol.isVisibleForWrite(userId) || (includeSharedProfile && vol.isVisibleForWrite(userIdSharingMedia)); } else { + // 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 match = vol.isVisibleForUser(userId) || (!vol.isVisible() && includeInvisible && vol.getPath() != null) - || (includeSharedProfile && vol.isVisibleForRead(userIdSharingMedia)); + || (includeSharedProfile && vol.isVisibleForUser(userIdSharingMedia)); } if (!match) continue;