Skip to content

Commit

Permalink
Fix for reboot due to Volume State not updated in callback
Browse files Browse the repository at this point in the history
When repeatedly formatting external sdcard as portable & internal
storage there is a possibility of state mismatch in App listener
volume state and actual volume state maintained by vold. This
results in reboot when try to create User directory in package-
manager when the volume is unmounted

The change verifies current volume state as well when volume state
change callback is received in package-manager. This avoids the
problem of volume state mismatch

Change-Id: I018a1a15dec72e86950293819d4e8481029b6dd2
Issue-Id: http://code.google.com/p/android/issues/detail?id=203886
Signed-off-by: Shasidhar Ganiga <sganig@codeaurora.org>
  • Loading branch information
Shasidhar Ganiga authored and nychitman1 committed Jan 23, 2017
1 parent 6595830 commit 75552a6
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -1818,8 +1818,18 @@ private void grantRuntimePermissionsGrantedToDisabledPrivSysPackageParentLPw(
@Override
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
if (vol.type == VolumeInfo.TYPE_PRIVATE) {
if (vol.state == VolumeInfo.STATE_MOUNTED) {
final String volumeUuid = vol.getFsUuid();
final String volumeUuid = vol.getFsUuid();
boolean volCurStateMounted = false;
// To handle a case where the onVolumeStateChanged callback is called with
// volume state MOUNTED, but the current state of volume is changed to
// UNMOUNTED/EJECTED state due to asynchronous behaviour of vold.
if(volumeUuid != null) {
StorageManager storage = mContext.getSystemService(StorageManager.class);
VolumeInfo currentVol = storage.findVolumeByUuid(volumeUuid);
if(currentVol != null && currentVol.state == VolumeInfo.STATE_MOUNTED)
volCurStateMounted = true;
}
if (vol.state == VolumeInfo.STATE_MOUNTED && volCurStateMounted) {

// Clean up any users or apps that were removed or recreated
// while this volume was missing
Expand Down

0 comments on commit 75552a6

Please sign in to comment.