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

Commit 0f8dab21 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Limit ordering unlock and wake by configuration." into udc-qpr-dev

parents dc2ea290 95ac41ac
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6566,6 +6566,9 @@
         Off by default, since OEMs may have had a similar feature on their devices. -->
    <bool name="config_repairModeSupported">false</bool>

    <!-- Whether unlocking and waking a device are sequenced -->
    <bool name="config_orderUnlockAndWake">false</bool>

    <!-- Enables or disables the "Share" action item shown in the context menu that appears upon
        long-pressing on selected text. Enabled by default. -->
    <bool name="config_textShareSupported">true</bool>
+3 −0
Original line number Diff line number Diff line
@@ -5160,4 +5160,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
@@ -479,6 +479,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.
@@ -1455,6 +1460,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        mDreamingToLockscreenTransitionViewModel = dreamingToLockscreenTransitionViewModel;
        mWmLockscreenVisibilityManager = wmLockscreenVisibilityManager;
        mMainDispatcher = mainDispatcher;

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

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

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

        if (updatedValue == mUnlockingAndWakingFromDream) {
            return;
        }
@@ -2917,6 +2929,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 || mUpdateMonitor.isDreaming()) && !mOrderUnlockAndWake) {
                mPM.wakeUp(mSystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                        "com.android.systemui:UNLOCK_DREAMING");
            }
        }
        Trace.endSection();
    }
+8 −4
Original line number Diff line number Diff line
@@ -177,6 +177,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;
@@ -316,6 +317,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        mLogger = biometricUnlockLogger;
        mSystemClock = systemClock;
        mFeatureFlags = featureFlags;
        mOrderUnlockAndWake = resources.getBoolean(
                com.android.internal.R.bool.config_orderUnlockAndWake);

        dumpManager.registerDumpable(getClass().getName(), this);
    }
@@ -470,10 +473,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) {
@@ -509,7 +513,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:
+38 −1
Original line number Diff line number Diff line
@@ -334,10 +334,34 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    public void wakeupFromDreamingWhenKeyguardHides() {
    public void wakeupFromDreamingWhenKeyguardHides_orderUnlockAndWakeOff() {
        createAndStartViewMediator(false);

        mViewMediator.onSystemReady();
        TestableLooper.get(this).processAllMessages();

        // Given device is dreaming
        when(mUpdateMonitor.isDreaming()).thenReturn(true);

        // When keyguard is going away
        mKeyguardStateController.notifyKeyguardGoingAway(true);

        // And keyguard is disabled which will call #handleHide
        mViewMediator.setKeyguardEnabled(false);
        TestableLooper.get(this).processAllMessages();

        // Then dream should wake up
        verify(mPowerManager).wakeUp(anyLong(), anyInt(),
                eq("com.android.systemui:UNLOCK_DREAMING"));
    }

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    public void wakeupFromDreamingWhenKeyguardHides_orderUnlockAndWakeOn() {
        createAndStartViewMediator(true);

        mViewMediator.onSystemReady();
        TestableLooper.get(this).processAllMessages();
        when(mPowerManager.isInteractive()).thenReturn(true);

        // Given device is dreaming
@@ -727,6 +751,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);

@@ -756,6 +783,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);

@@ -915,6 +945,13 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        verify(mStatusBarKeyguardViewManager).reset(true);
    }
    private void createAndStartViewMediator() {
        createAndStartViewMediator(false);
    }

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

        mViewMediator = new KeyguardViewMediator(
                mContext,
                mUiEventLogger,
Loading