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

Commit 28245729 authored by Matt Pietal's avatar Matt Pietal
Browse files

Move onDrawn callback earlier

The new remote animation flow is waiting for the onDrawn callback to
be issues before triggering the exit animation. This means for
wakeAndUnlock flows, onDrawn cannot wait for the exit animation to
begin. Remove all code that put this callback into a pending state.

Also remove BiometricUnlockController delay. This causes a poor
animation experience when unlocking with devices (sunfish) that delay
the unlock.

Fixes: 220340156
Test: atest KeyguardViewMediatorTest ScreenOnCoordinatorTest &&
Use rear FPS devices with AoD on/off

Change-Id: I6129c9d1fea76f8dded2a8d567c75fb21085a5dd
(cherry picked from commit e2608c01)
parent 19e584cf
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1372,10 +1372,6 @@
    <integer name="config_screenBrightnessDoze">1</integer>
    <item name="config_screenBrightnessDozeFloat" format="float" type="dimen">0.0</item>

    <!-- Delay that allows some content to arrive at the display before switching
         from DOZE to ON. -->
    <integer name="config_wakeUpDelayDoze">0</integer>

    <!-- Whether or not to skip the initial brightness ramps when the display transitions to
         STATE_ON. Setting this to true will skip the brightness ramp to the last stored active
         brightness value and will repeat for the following ramp if autobrightness is enabled. -->
+0 −1
Original line number Diff line number Diff line
@@ -3972,7 +3972,6 @@
  <java-symbol type="string" name="config_misprovisionedBrandValue" />

  <java-symbol type="integer" name="db_wal_truncate_size" />
  <java-symbol type="integer" name="config_wakeUpDelayDoze" />

  <!-- For Bluetooth AbsoluteVolume -->
  <java-symbol type="fraction" name="config_prescaleAbsoluteVolume_index1" />
+0 −20
Original line number Diff line number Diff line
@@ -48,18 +48,6 @@ class ScreenOnCoordinator @Inject constructor(
        SysUIUnfoldComponent::getFoldAodAnimationController).getOrNull()
    private val pendingTasks = PendingTasksContainer()

    private var wakeAndUnlockingTask: Runnable? = null
    var wakeAndUnlocking = false
        set(value) {
            if (!value && field) {
                // When updating the value back to false, mark the task complete in order to
                // callback onDrawn
                wakeAndUnlockingTask?.run()
                wakeAndUnlockingTask = null
            }
            field = value
        }

    init {
        screenLifecycle.addObserver(this)
    }
@@ -76,10 +64,6 @@ class ScreenOnCoordinator @Inject constructor(
        unfoldLightRevealAnimation?.onScreenTurningOn(pendingTasks.registerTask("unfold-reveal"))
        foldAodAnimationController?.onScreenTurningOn(pendingTasks.registerTask("fold-to-aod"))

        if (wakeAndUnlocking) {
            wakeAndUnlockingTask = pendingTasks.registerTask("wake-and-unlocking")
        }

        pendingTasks.onTasksComplete { onDrawn.run() }
        Trace.endSection()
    }
@@ -91,8 +75,4 @@ class ScreenOnCoordinator @Inject constructor(

        pendingTasks.reset()
    }

    override fun onScreenTurnedOff() {
        wakeAndUnlockingTask = null
    }
}
+10 −21
Original line number Diff line number Diff line
@@ -309,6 +309,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
    // true if the keyguard is hidden by another window
    private boolean mOccluded = false;

    private boolean mWakeAndUnlocking = false;

    /**
     * Helps remember whether the screen has turned on since the last time
     * it turned off due to timeout. see {@link #onScreenTurnedOff(int)}
@@ -443,7 +445,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
    private boolean mLockLater;
    private boolean mShowHomeOverLockscreen;
    private boolean mInGestureNavigationMode;

    private CharSequence mCustomMessage;

    /**
@@ -1201,7 +1202,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        synchronized (this) {
            mDeviceInteractive = false;
            mGoingToSleep = false;
            mScreenOnCoordinator.setWakeAndUnlocking(false);
            mWakeAndUnlocking = false;
            mAnimatingScreenOff = mDozeParameters.shouldAnimateDozingChange();

            resetKeyguardDonePendingLocked();
@@ -2215,7 +2216,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,

            mHiding = false;
            mKeyguardExitAnimationRunner = null;
            mScreenOnCoordinator.setWakeAndUnlocking(false);
            mWakeAndUnlocking = false;
            mPendingLock = false;
            setShowingLocked(true);
            mKeyguardViewControllerLazy.get().show(options);
@@ -2247,14 +2248,12 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,

            int flags = 0;
            if (mKeyguardViewControllerLazy.get().shouldDisableWindowAnimationsForUnlock()
                    || mScreenOnCoordinator.getWakeAndUnlocking()
                            && !mWallpaperSupportsAmbientMode) {
                    || mWakeAndUnlocking && !mWallpaperSupportsAmbientMode) {
                flags |= WindowManagerPolicyConstants
                        .KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS;
            }
            if (mKeyguardViewControllerLazy.get().isGoingToNotificationShade()
                    || mScreenOnCoordinator.getWakeAndUnlocking()
                            && mWallpaperSupportsAmbientMode) {
                    || mWakeAndUnlocking && mWallpaperSupportsAmbientMode) {
                // When the wallpaper supports ambient mode, the scrim isn't fully opaque during
                // wake and unlock, and we should fade in the app on top of the wallpaper
                flags |= WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
@@ -2367,16 +2366,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
            IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner;
            mKeyguardExitAnimationRunner = null;

            if (mScreenOnCoordinator.getWakeAndUnlocking()) {

                // Hack level over 9000: To speed up wake-and-unlock sequence, force it to report
                // the next draw from here, so we don't have to wait for window manager to signal
                // this to our ViewRootImpl.
                mKeyguardViewControllerLazy.get().getViewRootImpl().setReportNextDraw(
                        false /* syncBuffer */);
                mScreenOnCoordinator.setWakeAndUnlocking(false);
            }

            LatencyTracker.getInstance(mContext)
                    .onActionEnd(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);

@@ -2499,7 +2488,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        }

        setShowingLocked(false);
        mScreenOnCoordinator.setWakeAndUnlocking(false);
        mWakeAndUnlocking = false;
        mDismissCallbackRegistry.notifyDismissSucceeded();
        resetKeyguardDonePendingLocked();
        mHideAnimationRun = false;
@@ -2743,7 +2732,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,

    public void onWakeAndUnlocking() {
        Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking");
        mScreenOnCoordinator.setWakeAndUnlocking(true);
        mWakeAndUnlocking = true;
        keyguardDone();
        Trace.endSection();
    }
@@ -2879,7 +2868,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        pw.print("  mHideAnimationRun: "); pw.println(mHideAnimationRun);
        pw.print("  mPendingReset: "); pw.println(mPendingReset);
        pw.print("  mPendingLock: "); pw.println(mPendingLock);
        pw.print("  wakeAndUnlocking: "); pw.println(mScreenOnCoordinator.getWakeAndUnlocking());
        pw.print("  wakeAndUnlocking: "); pw.println(mWakeAndUnlocking);
    }

    /**
@@ -2953,7 +2942,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
    }

    private void setShowingLocked(boolean showing, boolean forceCallbacks) {
        final boolean aodShowing = mDozing && !mScreenOnCoordinator.getWakeAndUnlocking();
        final boolean aodShowing = mDozing && !mWakeAndUnlocking;
        final boolean notifyDefaultDisplayCallbacks = showing != mShowing || forceCallbacks;
        final boolean updateActivityLockScreenState = showing != mShowing
                || aodShowing != mAodShowing || forceCallbacks;
+2 −12
Original line number Diff line number Diff line
@@ -166,7 +166,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final SessionTracker mSessionTracker;
    private final int mConsecutiveFpFailureThreshold;
    private final int mWakeUpDelay;
    private int mMode;
    private BiometricSourceType mBiometricType;
    private KeyguardViewController mKeyguardViewController;
@@ -302,7 +301,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        mScrimController = scrimController;
        mKeyguardStateController = keyguardStateController;
        mHandler = handler;
        mWakeUpDelay = resources.getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze);
        mConsecutiveFpFailureThreshold = resources.getInteger(
                R.integer.fp_consecutive_failure_time_ms);
        mKeyguardBypassController = keyguardBypassController;
@@ -433,7 +431,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        // During wake and unlock, we need to draw black before waking up to avoid abrupt
        // brightness changes due to display state transitions.
        boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
        boolean delayWakeUp = mode == MODE_WAKE_AND_UNLOCK && alwaysOnEnabled && mWakeUpDelay > 0;
        Runnable wakeUp = ()-> {
            if (!wasDeviceInteractive) {
                if (DEBUG_BIO_WAKELOCK) {
@@ -442,15 +439,12 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
                mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                        "android.policy:BIOMETRIC");
            }
            if (delayWakeUp) {
                mKeyguardViewMediator.onWakeAndUnlocking();
            }
            Trace.beginSection("release wake-and-unlock");
            releaseBiometricWakeLock();
            Trace.endSection();
        };

        if (!delayWakeUp && mMode != MODE_NONE) {
        if (mMode != MODE_NONE) {
            wakeUp.run();
        }
        switch (mMode) {
@@ -504,11 +498,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
                    mUpdateMonitor.awakenFromDream();
                }
                mNotificationShadeWindowController.setNotificationShadeFocusable(false);
                if (delayWakeUp) {
                    mHandler.postDelayed(wakeUp, mWakeUpDelay);
                } else {
                mKeyguardViewMediator.onWakeAndUnlocking();
                }
                Trace.endSection();
                break;
            case MODE_ONLY_WAKE:
Loading