Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa766200 authored by ot904699's avatar ot904699 Committed by chuanghua zhao
Browse files

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
parent 594002e2
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -135,13 +135,19 @@ 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;
                        }
                    } else {
                        if (changedStorageEntry.equals(mSelectedStorageEntry)) {
                            mSelectedStorageEntry =
                                    StorageEntry.getDefaultInternalStorageEntry(getContext());
                        }
                    }
                    refreshUi();
                    break;
                default: