Loading services/core/java/com/android/server/StorageManagerService.java +25 −11 Original line number Diff line number Diff line Loading @@ -1615,6 +1615,23 @@ class StorageManagerService extends IStorageManager.Stub } private void onVolumeStateChangedAsync(VolumeInfo vol, int oldState, int newState) { if (newState == VolumeInfo.STATE_MOUNTED) { // Private volumes can be unmounted and re-mounted even after a user has // been unlocked; on devices that support encryption keys tied to the filesystem, // this requires setting up the keys again. try { prepareUserStorageIfNeeded(vol); } catch (Exception e) { // Unusable partition, unmount. try { mVold.unmount(vol.id); } catch (Exception ee) { Slog.wtf(TAG, ee); } return; } } synchronized (mLock) { // Remember that we saw this volume so we're ready to accept user // metadata, or so we can annoy them when a private volume is ejected Loading @@ -1640,13 +1657,6 @@ class StorageManagerService extends IStorageManager.Stub } } if (newState == VolumeInfo.STATE_MOUNTED) { // Private volumes can be unmounted and re-mounted even after a user has // been unlocked; on devices that support encryption keys tied to the filesystem, // this requires setting up the keys again. prepareUserStorageIfNeeded(vol); } // This is a blocking call to Storage Service which needs to process volume state changed // before notifying other listeners. // Intentionally called without the mLock to avoid deadlocking from the Storage Service. Loading Loading @@ -3239,7 +3249,7 @@ class StorageManagerService extends IStorageManager.Stub } } private void prepareUserStorageIfNeeded(VolumeInfo vol) { private void prepareUserStorageIfNeeded(VolumeInfo vol) throws Exception { if (vol.type != VolumeInfo.TYPE_PRIVATE) { return; } Loading @@ -3266,11 +3276,15 @@ class StorageManagerService extends IStorageManager.Stub public void prepareUserStorage(String volumeUuid, int userId, int serialNumber, int flags) { enforcePermission(android.Manifest.permission.STORAGE_INTERNAL); try { prepareUserStorageInternal(volumeUuid, userId, serialNumber, flags); } catch (Exception e) { throw new RuntimeException(e); } } private void prepareUserStorageInternal(String volumeUuid, int userId, int serialNumber, int flags) { int flags) throws Exception { try { mVold.prepareUserStorage(volumeUuid, userId, serialNumber, flags); // After preparing user storage, we should check if we should mount data mirror again, Loading @@ -3297,7 +3311,7 @@ class StorageManagerService extends IStorageManager.Stub + "; device may be insecure!"); return; } throw new RuntimeException(e); throw e; } } Loading Loading
services/core/java/com/android/server/StorageManagerService.java +25 −11 Original line number Diff line number Diff line Loading @@ -1615,6 +1615,23 @@ class StorageManagerService extends IStorageManager.Stub } private void onVolumeStateChangedAsync(VolumeInfo vol, int oldState, int newState) { if (newState == VolumeInfo.STATE_MOUNTED) { // Private volumes can be unmounted and re-mounted even after a user has // been unlocked; on devices that support encryption keys tied to the filesystem, // this requires setting up the keys again. try { prepareUserStorageIfNeeded(vol); } catch (Exception e) { // Unusable partition, unmount. try { mVold.unmount(vol.id); } catch (Exception ee) { Slog.wtf(TAG, ee); } return; } } synchronized (mLock) { // Remember that we saw this volume so we're ready to accept user // metadata, or so we can annoy them when a private volume is ejected Loading @@ -1640,13 +1657,6 @@ class StorageManagerService extends IStorageManager.Stub } } if (newState == VolumeInfo.STATE_MOUNTED) { // Private volumes can be unmounted and re-mounted even after a user has // been unlocked; on devices that support encryption keys tied to the filesystem, // this requires setting up the keys again. prepareUserStorageIfNeeded(vol); } // This is a blocking call to Storage Service which needs to process volume state changed // before notifying other listeners. // Intentionally called without the mLock to avoid deadlocking from the Storage Service. Loading Loading @@ -3239,7 +3249,7 @@ class StorageManagerService extends IStorageManager.Stub } } private void prepareUserStorageIfNeeded(VolumeInfo vol) { private void prepareUserStorageIfNeeded(VolumeInfo vol) throws Exception { if (vol.type != VolumeInfo.TYPE_PRIVATE) { return; } Loading @@ -3266,11 +3276,15 @@ class StorageManagerService extends IStorageManager.Stub public void prepareUserStorage(String volumeUuid, int userId, int serialNumber, int flags) { enforcePermission(android.Manifest.permission.STORAGE_INTERNAL); try { prepareUserStorageInternal(volumeUuid, userId, serialNumber, flags); } catch (Exception e) { throw new RuntimeException(e); } } private void prepareUserStorageInternal(String volumeUuid, int userId, int serialNumber, int flags) { int flags) throws Exception { try { mVold.prepareUserStorage(volumeUuid, userId, serialNumber, flags); // After preparing user storage, we should check if we should mount data mirror again, Loading @@ -3297,7 +3311,7 @@ class StorageManagerService extends IStorageManager.Stub + "; device may be insecure!"); return; } throw new RuntimeException(e); throw e; } } Loading