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

Commit 5e2c6fc0 authored by Lyn's avatar Lyn
Browse files

Fix IndexOutOfBoundsException in AvalancheController.getDurationMs

Fixes: 334151639
Test: BaseHeadsUpManagerTest
Flag: ACONFIG notification_throttle_hun STAGING

Change-Id: I14beb61fedecd28b5ccc95073fab7906e196b28c
parent 804f0c04
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