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

Commit 45c5e041 authored by Bryce Lee's avatar Bryce Lee Committed by William Xiao
Browse files

Limit ordering unlock and wake by configuration.

This change limits sequencing unlock and wake to only devices where
the configuration has been enabled.

Test: atest KeyguardViewMediatorTest
Test: atest BiometricsUnlockControllerTest
Bug: 289861878
Change-Id: I2bdf8bb16dba693c4afb824e861ab4b87783d61b
Merged-In: I2bdf8bb16dba693c4afb824e861ab4b87783d61b
parent ab6927cf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6459,4 +6459,7 @@
    <!-- Whether the AOSP support for app cloning building blocks is to be enabled for the
         device. -->
    <bool name="config_enableAppCloningBuildingBlocks">true</bool>

    <!-- Whether unlocking and waking a device are sequenced -->
    <bool name="config_orderUnlockAndWake">false</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -5132,4 +5132,7 @@

  <java-symbol type="drawable" name="focus_event_pressed_key_background" />
  <java-symbol type="string" name="lockscreen_too_many_failed_attempts_countdown" />

  <!-- Whether we order unlocking and waking -->
  <java-symbol type="bool" name="config_orderUnlockAndWake" />
</resources>
+19 −0
Original line number Diff line number Diff line
@@ -469,6 +469,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
     */
    private final int mDreamOpenAnimationDuration;

    /**
     * Whether unlock and wake should be sequenced.
     */
    private final boolean mOrderUnlockAndWake;

    /**
     * The animation used for hiding keyguard. This is used to fetch the animation timings if
     * WindowManager is not providing us with them.
@@ -1434,6 +1439,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

        mMainDispatcher = mainDispatcher;
        mDreamingToLockscreenTransitionViewModel = dreamingToLockscreenTransitionViewModel;

        mOrderUnlockAndWake = context.getResources().getBoolean(
                com.android.internal.R.bool.config_orderUnlockAndWake);
    }

    public void userActivity() {
@@ -2781,6 +2789,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

    private void setUnlockAndWakeFromDream(boolean updatedValue,
            @WakeAndUnlockUpdateReason int reason) {
        if (!mOrderUnlockAndWake) {
            return;
        }

        if (updatedValue == mUnlockingAndWakingFromDream) {
            return;
        }
@@ -2863,6 +2875,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                            null /* nonApps */, null /* finishedCallback */);
                });
            }

            // It's possible that the device was unlocked (via BOUNCER or Fingerprint) while
            // dreaming. It's time to wake up.
            if (mDreamOverlayShowing && !mOrderUnlockAndWake) {
                mPM.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                        "com.android.systemui:UNLOCK_DREAMING");
            }
        }
        Trace.endSection();
    }
+8 −4
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
    private final VibratorHelper mVibratorHelper;
    private final BiometricUnlockLogger mLogger;
    private final SystemClock mSystemClock;
    private final boolean mOrderUnlockAndWake;

    private long mLastFpFailureUptimeMillis;
    private int mNumConsecutiveFpFailures;
@@ -308,6 +309,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        mVibratorHelper = vibrator;
        mLogger = biometricUnlockLogger;
        mSystemClock = systemClock;
        mOrderUnlockAndWake = resources.getBoolean(
                com.android.internal.R.bool.config_orderUnlockAndWake);

        dumpManager.registerDumpable(getClass().getName(), this);
    }
@@ -462,10 +465,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
            Trace.endSection();
        };

        final boolean wakingFromDream = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM
                && mPowerManager.isInteractive();
        final boolean wakeInKeyguard = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM
                && mPowerManager.isInteractive() && mOrderUnlockAndWake
                && mOrderUnlockAndWake;

        if (mMode != MODE_NONE && !wakingFromDream) {
        if (mMode != MODE_NONE && !wakeInKeyguard) {
            wakeUp.run();
        }
        switch (mMode) {
@@ -501,7 +505,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
                    // later to awaken.
                }
                mNotificationShadeWindowController.setNotificationShadeFocusable(false);
                mKeyguardViewMediator.onWakeAndUnlocking(wakingFromDream);
                mKeyguardViewMediator.onWakeAndUnlocking(wakeInKeyguard);
                Trace.endSection();
                break;
            case MODE_ONLY_WAKE:
+15 −0
Original line number Diff line number Diff line
@@ -602,6 +602,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {

    @Test
    public void testWakeAndUnlockingOverDream() {
        // Ensure ordering unlock and wake is enabled.
        createAndStartViewMediator(true);

        // Send signal to wake
        mViewMediator.onWakeAndUnlocking(true);

@@ -631,6 +634,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {

    @Test
    public void testWakeAndUnlockingOverDream_signalAuthenticateIfStillShowing() {
        // Ensure ordering unlock and wake is enabled.
        createAndStartViewMediator(true);

        // Send signal to wake
        mViewMediator.onWakeAndUnlocking(true);

@@ -787,6 +793,15 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
    }

    private void createAndStartViewMediator() {
        createAndStartViewMediator(false);
    }

    private void createAndStartViewMediator(boolean orderUnlockAndWake) {
        if (orderUnlockAndWake) {
            mContext.getOrCreateTestableResources().addOverride(
                    com.android.internal.R.bool.config_orderUnlockAndWake, orderUnlockAndWake);
        }

        mViewMediator = new KeyguardViewMediator(
                mContext,
                mUiEventLogger,
Loading