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

Commit 862a19b7 authored by Jonathan Vonk's avatar Jonathan Vonk Committed by Steve Kondik
Browse files

Separate Timeout for Screen and Security Lock (Framework)

This allows the device to engage the slide-to-unlock lock screen after a delay followed by automatic transition to the security lock (ie. Pattern/PIN/Password) screen after a further delay.

Control is provided for distinct slide lock screen timeout and screen turned off delays. If the feature is disabled or the slide lock delay is equal to or greater than the corresponding security lock delay (the default case), the slide lock screen will never be encountered and only the security lock screen will be displayed.

This patchset attempts to maintain conventional behavior of the security lock screens. For example, in the case of Pattern lock screen security the slide lock screen will be replaced by the Pattern lock screen after the relevant delay for the security lock, so that only the pattern lock screen will be displayed once it is engaged. All other types of security lock screens are displayed after the slide lock screen has been disengaged. The same behavior holds for boot: the pattern lock screen will be displayed immediately, and all others will be presented as slide -> security.

Use of a stateful progressive delay prevents screen "flicker" on transition from slide lock to pattern lock when the screen is turned on.

Change-Id: I21d8e6346d1b245b67dd7b4af78cbd97505de998
parent 6a94bcf8
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -1906,20 +1906,39 @@ public final class Settings {
        public static final String POWER_DIALOG_PROMPT = "power_dialog_prompt";

        /**
         * How many ms to delay before enabling the screen lock when the screen
         * goes off due to timeout
         *
         * How many ms to delay before enabling the security screen lock when
         * the screen goes off due to timeout
         * @hide
         */
        public static final String SCREEN_LOCK_TIMEOUT_DELAY = "screen_lock_timeout_delay";
        public static final String SCREEN_LOCK_SECURITY_TIMEOUT_DELAY = "screen_lock_security_timeout_delay";

        /**
         * How many ms to delay before enabling the screen lock when the screen
         * is turned off by the user
         *
         * How many ms to delay before enabling the security screen lock when
         * the screen is turned off by the user
         * @hide
         */
        public static final String SCREEN_LOCK_SECURITY_SCREENOFF_DELAY = "screen_lock_security_screenoff_delay";

        /**
         * Whether to use a separate delay for "slide to unlock" and security
         * lock
         * @hide
         */
        public static final String SCREEN_LOCK_SLIDE_DELAY_TOGGLE = "lockscreen_custom_app_toggle";

        /**
         * How many ms to delay before enabling the "slide to unlock" screen
         * lock when the screen goes off due to timeout
         * @hide
         */
        public static final String SCREEN_LOCK_SLIDE_TIMEOUT_DELAY = "screen_lock_slide_timeout_delay";

        /**
         * How many ms to delay before enabling the "slide to unlock" screen
         * lock when the screen is turned off by the user
         * @hide
         */
        public static final String SCREEN_LOCK_SCREENOFF_DELAY = "screen_lock_screenoff_delay";
        public static final String SCREEN_LOCK_SLIDE_SCREENOFF_DELAY = "screen_lock_slide_screenoff_delay";

        /**
         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
+6 −0
Original line number Diff line number Diff line
@@ -66,6 +66,12 @@ public abstract class KeyguardViewBase extends FrameLayout {
     */
    abstract public void reset();

    /**
     * Called when entering/leaving an interstitial "locked but not yet secured"
     * mode.
     */
    abstract public void onLockedButNotSecured(boolean lockedButNotSecured);

    /**
     * Called when the screen turned off.
     */
+15 −3
Original line number Diff line number Diff line
@@ -87,12 +87,17 @@ public class KeyguardViewManager implements KeyguardWindowController {
        }
    }

    enum ShowMode {
        LockScreen, UnlockScreen, KeepCurrentState
    }

    /**
     * Show the keyguard.  Will handle creating and attaching to the view manager
     * lazily.
     */
    public synchronized void show() {
        if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView);
    public synchronized void show(ShowMode showMode) {
        if (DEBUG)
            Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView + "; showMode==" + showMode.name());

        if (mKeyguardHost == null) {
            if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");
@@ -137,6 +142,13 @@ public class KeyguardViewManager implements KeyguardWindowController {
            }
        }

        // If we have been explicitly given a keyguard display mode, invoke it.
        if (showMode == ShowMode.LockScreen) {
            mKeyguardView.onLockedButNotSecured(true);
        } else if (showMode == ShowMode.UnlockScreen) {
            mKeyguardView.onLockedButNotSecured(false);
        }

        mKeyguardHost.setVisibility(View.VISIBLE);
        mKeyguardView.requestFocus();
    }
@@ -183,7 +195,7 @@ public class KeyguardViewManager implements KeyguardWindowController {

    public synchronized void verifyUnlock() {
        if (DEBUG) Log.d(TAG, "verifyUnlock()");
        show();
        show(ShowMode.KeepCurrentState);
        mKeyguardView.verifyUnlock();
    }

+175 −57

File changed.

Preview size limit exceeded, changes collapsed.

+40 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {

    private boolean mRequiresSim;

    private boolean mLockedButNotYetSecured = false;

    /**
     * Either a lock screen (an informational keyguard screen), or an unlock
@@ -251,6 +252,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
                if (stuckOnLockScreenBecauseSimMissing()
                         || (simState == IccCard.State.PUK_REQUIRED)){
                    // stuck on lock screen when sim missing or puk'd

                    // Clear IsSecure() override flag if we have entered a bad
                    // SIM state.
                    LockPatternKeyguardView.this.mLockedButNotYetSecured = false;
                    return;
                }
                if (!isSecure()) {
@@ -258,6 +263,13 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
                } else {
                    updateScreen(Mode.UnlockScreen);
                }

                // Modifying this flag state before now would cause IsSecure()
                // to fail to short circuit (if flag were set) as intended,
                // causing the keyguard to proceed to the unlock screen even if
                // in the interstital locked-but-not-yet-secured state. Clearing
                // now so that subsequent operations proceed without override.
                LockPatternKeyguardView.this.mLockedButNotYetSecured = false;
            }

            public void forgotPattern(boolean isForgotten) {
@@ -542,6 +554,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
    }

    private boolean isSecure() {
        // If the LockScreen has been enabled via its timeout and the security
        // lock timeout has not been reached then we are not secure (prevents
        // the LockScreen exit from immediately invoking the UnlockScreen)
        if (mLockedButNotYetSecured)
            return false;

        UnlockMode unlockMode = getUnlockMode();
        boolean secure = false;
        switch (unlockMode) {
@@ -564,6 +582,28 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
        return secure;
    }

    public void onLockedButNotSecured(boolean lockedButNotSecured) {
        // Setting the flag ensures that IsSecure() will short-circuit and
        // report false
        mLockedButNotYetSecured = lockedButNotSecured;

        // Pattern unlock screen shows immediately. All others follow the
        // progression of Lock -> Unlock, so only Pattern lock requires this
        // state to be changed.
        if (!lockedButNotSecured && mMode != Mode.UnlockScreen
                && this.mLockPatternUtils.isLockPatternEnabled()) {
            updateScreen(Mode.UnlockScreen);
        } else
        if (lockedButNotSecured && mMode != Mode.LockScreen) {
            // If lockedButNotSecured is enabled, frob the screen to lock
            updateScreen(Mode.LockScreen);
        } else {
            if (DEBUG_CONFIGURATION)
                Log.v(TAG, "onLockedButNotSecured() : nothing to do");
        }

    }

    private void updateScreen(final Mode mode) {

        if (DEBUG_CONFIGURATION) Log.v(TAG, "**** UPDATE SCREEN: mode=" + mode