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

Commit 35fc36df authored by t-m-w's avatar t-m-w Committed by Michael Bestas
Browse files

Fix for Pixel Udfps to release peak refresh rate

The under-display fingerprint sensor's high-brightness mode (HBM)
implementation for Pixels was not calling onHbmDisabled under some
conditions, preventing DisplayModeDirector's HbmObserver from learning
that HBM has ended and a higher refresh rate is no longer required.

Test: `adb shell dumpsys display` should now show mLocalHbmEnabled
as disabled for Display 0 after successful fingerprint unlocks.

You can use `adb shell cmd display dmd-logging-enable` for logging
of DisplayModeDirector events if further troubleshooting is needed.

Issue: calyxos#1176
Change-Id: Ife66b62b2122a5958fcfc22e169df4b32841c69f
parent 5b67aee9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ class PixelUdfpsHbmProvider constructor(
    // Used by both main and UI background threads
    @Volatile private var pendingEnable = false
    @Volatile private var pendingEnableCallback: Runnable? = null
    @Volatile private var alreadyDisabled = true

    init {
        // Listen for refresh rate changes
@@ -82,6 +83,7 @@ class PixelUdfpsHbmProvider constructor(
    }

    private fun doPendingEnable(callback: Runnable? = null) {
        alreadyDisabled = false
        displayHal?.setLhbmState(true)
        // Make sure callback runs on main thread
        (callback ?: pendingEnableCallback)?.let { handler.post(it) }
@@ -102,10 +104,12 @@ class PixelUdfpsHbmProvider constructor(

        // Also bail out if HBM is already disabled *and* no enable is pending.
        // This can happen sometimes if the user spams taps on the UDFPS icon.
        if (!displayHal.getLhbmState()) {
        if (!displayHal.getLhbmState() && alreadyDisabled) {
            return
        }

        alreadyDisabled = true

        // Takes 10-20 ms, so switch to background
        bgExecutor.execute {
            displayHal?.setLhbmState(false)