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

Commit aaa4abf1 authored by Darrell Shi's avatar Darrell Shi
Browse files

Allow keyguard to be locked while dreaming

Currently when a device is folded in the unlocked state, keyguard is
forced to be in the unlocked state. This change resets this state when
dream starts to keep the device secure.

Test: atest KeyguardUpdateMonitorTest
Test: verified after dream starts in the folded, unlocked state, the
      device gets locked 5 seconds after dream starts, based on the
      default lock after screen timeout setting
Fix: 415210679
Flag: EXEMPT bug fix
Change-Id: I5f6eacee32b8c245e91583d9edcf1a2ba1332ae1
parent 64380516
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2104,6 +2104,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
    private void handleDreamingStateChanged(int dreamStart) {
        Assert.isMainThread();
        mIsDreaming = dreamStart == 1;

        // Allow keyguard to be locked once dream starts.
        if (mIsDreaming) {
            setForceIsDismissibleKeyguard(false);
        }

        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
+8 −0
Original line number Diff line number Diff line
@@ -2469,6 +2469,14 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        Assert.assertFalse(mKeyguardUpdateMonitor.forceIsDismissibleIsKeepingDeviceUnlocked());
    }

    @Test
    public void forceIsDismissibleKeyguard_respectsDream() {
        mKeyguardUpdateMonitor.tryForceIsDismissibleKeyguard();
        mKeyguardUpdateMonitor.dispatchDreamingStarted();
        mTestableLooper.processAllMessages();
        Assert.assertFalse(mKeyguardUpdateMonitor.forceIsDismissibleIsKeepingDeviceUnlocked());
    }

    private Intent defaultSimStateChangedIntent() {
        Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        intent.putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0);