diff options
| author | 2021-02-01 17:26:53 +0000 | |
|---|---|---|
| committer | 2021-02-01 17:26:53 +0000 | |
| commit | 6c1e915306ff5220e5e28b15ac1eb0ada0b15d65 (patch) | |
| tree | 873853fa9345afe88a72d8677fbf0c03d04783d9 | |
| parent | b72db4c52fde1396869a67540cddd5588f8425ef (diff) | |
| parent | 2d062e56f1d2e6f7340b53feea107a3f50d88f13 (diff) | |
Merge "Change setPrimaryStorageUuid to handle it for the current user" into rvc-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/StorageManagerService.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 391923324d0c..392894616bf4 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -58,6 +58,7 @@ import static org.xmlpull.v1.XmlPullParser.START_TAG; import android.Manifest; import android.annotation.Nullable; +import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.AppOpsManager; @@ -511,14 +512,21 @@ class StorageManagerService extends IStorageManager.Stub } } - private @Nullable VolumeInfo findStorageForUuid(String volumeUuid) { + private @Nullable VolumeInfo findStorageForUuidAsUser(String volumeUuid, + @UserIdInt int userId) { final StorageManager storage = mContext.getSystemService(StorageManager.class); if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, volumeUuid)) { - return storage.findVolumeById(VolumeInfo.ID_EMULATED_INTERNAL + ";" + 0); + return storage.findVolumeById(VolumeInfo.ID_EMULATED_INTERNAL + ";" + userId); } else if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, volumeUuid)) { return storage.getPrimaryPhysicalVolume(); } else { - return storage.findEmulatedForPrivate(storage.findVolumeByUuid(volumeUuid)); + VolumeInfo info = storage.findVolumeByUuid(volumeUuid); + if (info == null) { + Slog.w(TAG, "findStorageForUuidAsUser cannot find volumeUuid:" + volumeUuid); + return null; + } + String emulatedUuid = info.getId().replace("private", "emulated") + ";" + userId; + return storage.findVolumeById(emulatedUuid); } } @@ -2763,8 +2771,9 @@ class StorageManagerService extends IStorageManager.Stub return; } else { - from = findStorageForUuid(mPrimaryStorageUuid); - to = findStorageForUuid(volumeUuid); + int currentUserId = mCurrentUserId; + from = findStorageForUuidAsUser(mPrimaryStorageUuid, currentUserId); + to = findStorageForUuidAsUser(volumeUuid, currentUserId); if (from == null) { Slog.w(TAG, "Failing move due to missing from volume " + mPrimaryStorageUuid); |