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

Commit 7c2fe1a3 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Fix IndexOutOfBoundsException in AvalancheController.getDurationMs" into main

parents 578848e1 5e2c6fc0
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -153,18 +153,20 @@ class AvalancheController @Inject constructor(
            // Use default duration, like we did before AvalancheController existed
            return autoDismissMs
        }

        val showingList: MutableList<HeadsUpEntry> = mutableListOf()
        headsUpEntryShowing?.let { showingList.add(it) }

        nextList.sort()
        val entryList = showingList + nextList
        if (entryList.indexOf(entry) == entryList.size - 1) {
            // Use default duration if last entry
        val thisEntryIndex = entryList.indexOf(entry)
        val nextEntryIndex = thisEntryIndex + 1

        // If last entry, use default duration
        if (nextEntryIndex >= entryList.size) {
            return autoDismissMs
        }

        nextList.sort()
        val nextEntry = nextList[0]

        val nextEntry = entryList[nextEntryIndex]
        if (nextEntry.compareNonTimeFields(entry) == -1) {
            // Next entry is higher priority
            return 500