Merge "UserDataPreparer: fix volume preparation order" into tm-dev am: 5815b8820e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18164350

Change-Id: I15f543744b43adabb7f241a364ef98b4d7f340b1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Eric Biggers
2022-05-11 21:10:28 +00:00
committed by Automerger Merge Worker

View File

@@ -70,12 +70,19 @@ class UserDataPreparer {
void prepareUserData(int userId, int userSerial, int flags) { void prepareUserData(int userId, int userSerial, int flags) {
synchronized (mInstallLock) { synchronized (mInstallLock) {
final StorageManager storage = mContext.getSystemService(StorageManager.class); final StorageManager storage = mContext.getSystemService(StorageManager.class);
/*
* Internal storage must be prepared before adoptable storage, since the user's volume
* keys are stored in their internal storage.
*/
prepareUserDataLI(null /* internal storage */, userId, userSerial, flags, true);
for (VolumeInfo vol : storage.getWritablePrivateVolumes()) { for (VolumeInfo vol : storage.getWritablePrivateVolumes()) {
final String volumeUuid = vol.getFsUuid(); final String volumeUuid = vol.getFsUuid();
if (volumeUuid != null) {
prepareUserDataLI(volumeUuid, userId, userSerial, flags, true); prepareUserDataLI(volumeUuid, userId, userSerial, flags, true);
} }
} }
} }
}
private void prepareUserDataLI(String volumeUuid, int userId, int userSerial, int flags, private void prepareUserDataLI(String volumeUuid, int userId, int userSerial, int flags,
boolean allowRecover) { boolean allowRecover) {
@@ -136,11 +143,18 @@ class UserDataPreparer {
void destroyUserData(int userId, int flags) { void destroyUserData(int userId, int flags) {
synchronized (mInstallLock) { synchronized (mInstallLock) {
final StorageManager storage = mContext.getSystemService(StorageManager.class); final StorageManager storage = mContext.getSystemService(StorageManager.class);
/*
* Volume destruction order isn't really important, but to avoid any weird issues we
* process internal storage last, the opposite of prepareUserData.
*/
for (VolumeInfo vol : storage.getWritablePrivateVolumes()) { for (VolumeInfo vol : storage.getWritablePrivateVolumes()) {
final String volumeUuid = vol.getFsUuid(); final String volumeUuid = vol.getFsUuid();
if (volumeUuid != null) {
destroyUserDataLI(volumeUuid, userId, flags); destroyUserDataLI(volumeUuid, userId, flags);
} }
} }
destroyUserDataLI(null /* internal storage */, userId, flags);
}
} }
void destroyUserDataLI(String volumeUuid, int userId, int flags) { void destroyUserDataLI(String volumeUuid, int userId, int flags) {