Fix USB OTG hot plug out nndexOutOfBoundsException
Open Settings, then open Storage , plug in USB OTG with Disk, select Disk, open Files, play a video, press the back key, hot plug out USB OTG, the IndexOutOfBoundsException will happen The root cause is when received the onVolumeStateChanged in StorageEventListener in StorageDashboardFragment, the volumeInfo status is VolumeInfo.STATE_UNMOUNTED or VolumeInfo.STATE_EJECTING, mSelectedStorageEntry set to changedStorageEntry, cause the fail. This is a fix for CL 225095144 bug. Bug: 247737688 Test: Manual Change-Id: I9535c49d65c42a8dfa8ccf4e271ae973d944d4b9
This commit is contained in:
@@ -135,12 +135,18 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
mStorageEntries.removeIf(storageEntry -> {
|
||||
return storageEntry.equals(changedStorageEntry);
|
||||
});
|
||||
if (volumeState != VolumeInfo.STATE_REMOVED
|
||||
&& volumeState != VolumeInfo.STATE_BAD_REMOVAL) {
|
||||
if (volumeState == VolumeInfo.STATE_MOUNTED
|
||||
|| volumeState == VolumeInfo.STATE_MOUNTED_READ_ONLY
|
||||
|| volumeState == VolumeInfo.STATE_UNMOUNTABLE) {
|
||||
mStorageEntries.add(changedStorageEntry);
|
||||
}
|
||||
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
||||
mSelectedStorageEntry = changedStorageEntry;
|
||||
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
||||
mSelectedStorageEntry = changedStorageEntry;
|
||||
}
|
||||
} else {
|
||||
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
||||
mSelectedStorageEntry =
|
||||
StorageEntry.getDefaultInternalStorageEntry(getContext());
|
||||
}
|
||||
}
|
||||
refreshUi();
|
||||
break;
|
||||
|
Reference in New Issue
Block a user