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,13 +135,19 @@ public class StorageDashboardFragment extends DashboardFragment
|
|||||||
mStorageEntries.removeIf(storageEntry -> {
|
mStorageEntries.removeIf(storageEntry -> {
|
||||||
return storageEntry.equals(changedStorageEntry);
|
return storageEntry.equals(changedStorageEntry);
|
||||||
});
|
});
|
||||||
if (volumeState != VolumeInfo.STATE_REMOVED
|
if (volumeState == VolumeInfo.STATE_MOUNTED
|
||||||
&& volumeState != VolumeInfo.STATE_BAD_REMOVAL) {
|
|| volumeState == VolumeInfo.STATE_MOUNTED_READ_ONLY
|
||||||
|
|| volumeState == VolumeInfo.STATE_UNMOUNTABLE) {
|
||||||
mStorageEntries.add(changedStorageEntry);
|
mStorageEntries.add(changedStorageEntry);
|
||||||
}
|
|
||||||
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
||||||
mSelectedStorageEntry = changedStorageEntry;
|
mSelectedStorageEntry = changedStorageEntry;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (changedStorageEntry.equals(mSelectedStorageEntry)) {
|
||||||
|
mSelectedStorageEntry =
|
||||||
|
StorageEntry.getDefaultInternalStorageEntry(getContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
refreshUi();
|
refreshUi();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user