Mount private volume hook after prepareUserData
As CE and DE data directory may not be ready when volume is mounted (like a new volume). We try to mount data mirror after user data is prepared. It will skip mounting data mirror if it's already mounted. Bug: 149027213 Test: After reverting ag/10156695 and aosp/1218838, can see virtual disk is mounted correctly in adb shell mount, and test app works and mounted correctly after pm move-package. Change-Id: If433914a93f7e6154f31715869f52b387157b2dd
This commit is contained in:
@@ -1300,13 +1300,6 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
vol.state = newState;
|
||||
onVolumeStateChangedLocked(vol, oldState, newState);
|
||||
}
|
||||
try {
|
||||
if (vol.type == VolumeInfo.TYPE_PRIVATE && state == VolumeInfo.STATE_MOUNTED) {
|
||||
mInstaller.onPrivateVolumeMounted(vol.getFsUuid());
|
||||
}
|
||||
} catch (Installer.InstallerException e) {
|
||||
Slog.i(TAG, "Failed when private volume mounted " + vol, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3110,6 +3103,15 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
|
||||
try {
|
||||
mVold.prepareUserStorage(volumeUuid, userId, serialNumber, flags);
|
||||
// After preparing user storage, we should check if we should mount data mirror again,
|
||||
// and we do it for user 0 only as we only need to do once for all users.
|
||||
if (volumeUuid != null) {
|
||||
final StorageManager storage = mContext.getSystemService(StorageManager.class);
|
||||
VolumeInfo info = storage.findVolumeByUuid(volumeUuid);
|
||||
if (info != null && userId == 0 && info.type == VolumeInfo.TYPE_PRIVATE) {
|
||||
mInstaller.tryMountDataMirror(volumeUuid);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
}
|
||||
|
||||
@@ -611,10 +611,10 @@ public class Installer extends SystemService {
|
||||
/**
|
||||
* Bind mount private volume CE and DE mirror storage.
|
||||
*/
|
||||
public void onPrivateVolumeMounted(String volumeUuid) throws InstallerException {
|
||||
public void tryMountDataMirror(String volumeUuid) throws InstallerException {
|
||||
if (!checkBeforeRemote()) return;
|
||||
try {
|
||||
mInstalld.onPrivateVolumeMounted(volumeUuid);
|
||||
mInstalld.tryMountDataMirror(volumeUuid);
|
||||
} catch (Exception e) {
|
||||
throw InstallerException.from(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user