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

Commit a566b9aa authored by electimon's avatar electimon Committed by Sahil Sonar
Browse files

UdfpsController/Overlay: Delay by frames rather than milliseconds



Co-authored-by: default avatarnift4 <nift4@protonmail.com>
Signed-off-by: default avatarelectimon <electimon@gmail.com>
Change-Id: Iea6082657d6c99cf1ecf25814759822d3d9de631
parent 0d288bc1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
    <!-- Brightness range max for UDFPS dimming -->
    <integer name="config_udfpsDimmingBrightnessMax">0</integer>

    <!-- The amount of delay to add when disabling the dimming.
    <!-- The amount of frames to delay by when disabling the dim layer.
         This is used to prevent flickers due to the dimming being disabled
         before the screen has had chance to switch out of HBM mode -->
    <integer name="config_udfpsDimmingDisableDelay">0</integer>
+19 −9
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;

import javax.inject.Inject;

@@ -1234,17 +1235,26 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        // Add a delay to ensure that the dim amount is updated after the display has had chance
        // to switch out of HBM mode. The delay, in ms is stored in config_udfpsDimmingDisableDelay.
        // If the delay is 0, the dim amount will be updated immediately.
        final int delay = mContext.getResources().getInteger(
        int delay = mContext.getResources().getInteger(
                com.android.systemui.res.R.integer.config_udfpsDimmingDisableDelay);
        if (delay > 0) {
        final AtomicInteger delayCounter = new AtomicInteger(delay);

        UdfpsControllerOverlay overlay = mOverlay;
            mFgExecutor.executeDelayed(() -> {
        final Runnable dimmingDisableRunnable = new Runnable() {
            @Override
            public void run() {
                if (delayCounter.getAndDecrement() <= 0) {
                    updateViewDimAmount(overlay);
            }, delay);
                } else {
            updateViewDimAmount(mOverlay);
                    View view = overlay.getFrame();
                    if (view != null) {
                        view.postOnAnimation(this);
                    }
                }
            }
        };
        dimmingDisableRunnable.run();
    }

    /**
     * Callback for fingerUp and fingerDown events.
+2 −1
Original line number Diff line number Diff line
@@ -126,7 +126,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor(
        private val powerInteractor: PowerInteractor,
        @Application private val scope: CoroutineScope,
) {
    private var frame: View? = null
    var frame: View? = null
        private set
    private var isDimmed = false
    private var hideOnUndim = false