fix: stop switching between display modes with the same refresh rate (S26 lag and heat since 0.6.7) (#2192)

fix: stop switching between display modes with the same refresh rate
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-06 17:18:24 -05:00
1 parent 542bbf89c3
commit 250f80fbb5
2 files changed
+28 -1

No files matched your search

@@ -2,6 +2,8 @@ package com.droiddeck.launcher.session
import android.view.Display
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@@ -34,4 +36,24 @@ class PerfModeTest {
val otherResolution = mode(3, 60f, 720)
assertEquals(low, PerfMode.selectMode(arrayOf(low, high, otherResolution), high, 60, 60f))
}
@Test fun anotherModeWithTheRequestedRefreshRateKeepsTheRequestInsteadOfSwitchingBackAndForth() {
val sixty = mode(2, 60f)
val requested = mode(1, 120f)
val reported = mode(255, 120f, 1440)
val modes = arrayOf(sixty, requested, reported)
assertEquals(reported, PerfMode.selectMode(modes, reported, 0, Float.POSITIVE_INFINITY))
assertFalse(PerfMode.needsChange(modes, requested.modeId, reported))
assertFalse(PerfMode.needsChange(modes, reported.modeId, requested))
}
@Test fun aDifferentRefreshRateNoRequestOrAMissingModeStillChangesTheMode() {
val sixty = mode(2, 60f)
val oneTwenty = mode(1, 120f)
val modes = arrayOf(sixty, oneTwenty)
assertTrue(PerfMode.needsChange(modes, sixty.modeId, oneTwenty))
assertTrue(PerfMode.needsChange(modes, oneTwenty.modeId, sixty))
assertTrue(PerfMode.needsChange(modes, 0, oneTwenty))
assertTrue(PerfMode.needsChange(modes, 99, oneTwenty))
}
}