diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index c9ba988000e04..2b2a6edb55bd5 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -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); } diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java index b98bb0831b0ef..8ad3e9df8bdf5 100644 --- a/services/core/java/com/android/server/pm/Installer.java +++ b/services/core/java/com/android/server/pm/Installer.java @@ -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); }