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

Commit 1dce3a2a authored by eray orçunus's avatar eray orçunus Committed by Bruno Martins
Browse files

lockscreen: Add support for showing unlock screen directly



Squash of the following changes, updated for the new SDK:

  From: eray orçunus <erayorcunus@gmail.com>
  Date: Wed, 17 Jun 2015 16:12:19 +0300

      lockscreen: Add option for showing unlock screen directly

       * Option appears on PIN, pattern and password methods
       * User can press back button to see swipe-up-to-unlock screen
       * Instantly hide keyguard if Smart Lock has unlocked phone

      Change-Id: I2ceeed348d7e61632b8344f35431f30cba62ca4f
      Ticket-Id: CYNGNOS-1873
      Signed-off-by: default avatareray orçunus <erayorcunus@gmail.com>

  From: Danesh M <daneshm90@gmail.com>
  Date: Tue, 17 Nov 2015 20:09:38 -0800

      SettingsProvider: Add missing platform sdk dependency

      Change-Id: I4844eaa0a989bf634a2251e95dc84a505037c012

Change-Id: I0cfb43bfb631fce532dfacdf56455309a04ddfa2
parent d0012829
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -718,6 +718,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                   Secure.LOCK_PATTERN_SIZE,
                   Secure.LOCK_DOTS_VISIBLE,
                   Secure.LOCK_SHOW_ERROR_PATH,
                   "lock_screen_pass_to_security_view",
                   "lockscreen.password_type",
                   "lockscreen.lockoutattemptdeadline",
                   "lockscreen.patterneverchosen",
+29 −10
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ import com.android.systemui.DejankUtils;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;

import org.lineageos.internal.util.LineageLockPatternUtils;

import java.io.PrintWriter;

/**
@@ -60,11 +62,17 @@ public class KeyguardBouncer {
    protected final Context mContext;
    protected final ViewMediatorCallback mCallback;
    protected final LockPatternUtils mLockPatternUtils;
    private final LineageLockPatternUtils mLineageLockPatternUtils;
    protected final ViewGroup mContainer;
    private final FalsingManager mFalsingManager;
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final Handler mHandler;
    private final BouncerExpansionCallback mExpansionCallback;

    public static final int UNLOCK_SEQUENCE_DEFAULT = 0;
    public static final int UNLOCK_SEQUENCE_BOUNCER_FIRST = 1;
    public static final int UNLOCK_SEQUENCE_FORCE_BOUNCER = 2;

    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
                @Override
@@ -101,6 +109,7 @@ public class KeyguardBouncer {
        mDismissCallbackRegistry = dismissCallbackRegistry;
        mExpansionCallback = expansionCallback;
        mHandler = new Handler();
        mLineageLockPatternUtils = new LineageLockPatternUtils(mContext);
    }

    public void show(boolean resetSecuritySelection) {
@@ -421,17 +430,31 @@ public class KeyguardBouncer {
        return mKeyguardView != null && mKeyguardView.handleBackKey();
    }

    public int getUnlockSequence(boolean useCurrentSecurityMode) {
        int unlockSequence = UNLOCK_SEQUENCE_DEFAULT;
        if (mKeyguardView != null) {
            SecurityMode mode = useCurrentSecurityMode ?
                    mKeyguardView.getCurrentSecurityMode() : mKeyguardView.getSecurityMode();
            if (mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk) {
                unlockSequence = UNLOCK_SEQUENCE_FORCE_BOUNCER;
            } else if ((mode == SecurityMode.Pattern || mode == SecurityMode.Password
                    || mode == SecurityMode.PIN) && (mLockPatternUtils != null
                    && mLineageLockPatternUtils.shouldPassToSecurityView(
                            KeyguardUpdateMonitor.getCurrentUser()))) {
                // "Bouncer first" mode is only available to some security methods
                unlockSequence = UNLOCK_SEQUENCE_BOUNCER_FIRST;
            }
        }
        return unlockSequence;
    }

    /**
     * @return True if and only if the security method should be shown before showing the
     * notifications on Keyguard, like SIM PIN/PUK.
     */
    public boolean needsFullscreenBouncer() {
        ensureView();
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
        return getUnlockSequence(false) == UNLOCK_SEQUENCE_FORCE_BOUNCER;
    }

    /**
@@ -439,11 +462,7 @@ public class KeyguardBouncer {
     * makes this method much faster.
     */
    public boolean isFullscreenBouncer() {
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
        return getUnlockSequence(true) == UNLOCK_SEQUENCE_FORCE_BOUNCER;
    }

    /**
+41 −14
Original line number Diff line number Diff line
@@ -200,17 +200,37 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
     * Shows the notification keyguard or the bouncer depending on
     * {@link KeyguardBouncer#needsFullscreenBouncer()}.
     */
    protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) {
        if (mBouncer.needsFullscreenBouncer() && !mDozing) {
    protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing, boolean isBackPressed) {
        switch (mBouncer.getUnlockSequence(false /* useCurrentSecurityMode */)) {
            case KeyguardBouncer.UNLOCK_SEQUENCE_FORCE_BOUNCER:
                // SIM PIN/PUK
                // The keyguard might be showing (already). So we need to hide it.
                mStatusBar.hideKeyguard();
                mBouncer.show(true /* resetSecuritySelection */);
                break;
            case KeyguardBouncer.UNLOCK_SEQUENCE_BOUNCER_FIRST:
                // Pattern / PIN / password with "Directly show " enabled
                if (isBackPressed) {
                    mStatusBar.showKeyguard();
                    if (hideBouncerWhenShowing) {
                        mBouncer.hide(false /* destroyView */);
                        mBouncer.prepare();
                    }
                } else {
                    // The keyguard might be showing (already). So we need to hide it.
                    mStatusBar.hideKeyguard();
                    mBouncer.show(true /* resetSecuritySelection */);
                }
                break;
            case KeyguardBouncer.UNLOCK_SEQUENCE_DEFAULT:
                mStatusBar.showKeyguard();
                if (hideBouncerWhenShowing) {
                hideBouncer(shouldDestroyViewOnReset() /* destroyView */);
                    mBouncer.hide(false /* destroyView */);
                    mBouncer.prepare();
                }
                break;
            default:
                break;
        }
        updateStates();
    }
@@ -273,7 +293,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    /**
     * Reset the state of the view.
     */
    public void reset(boolean hideBouncerWhenShowing) {
    public void reset(boolean hideBouncerWhenShowing, boolean isBackPressed) {
        if (mShowing) {
            if (mOccluded && !mDozing) {
                mStatusBar.hideKeyguard();
@@ -281,13 +301,20 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                    hideBouncer(false /* destroyView */);
                }
            } else {
                showBouncerOrKeyguard(hideBouncerWhenShowing);
                showBouncerOrKeyguard(hideBouncerWhenShowing, isBackPressed);
            }
            KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
            updateStates();
        }
    }

    /**
     * Reset the state of the view; not caused by back press
     */
    public void reset(boolean hideBouncerWhenShowing) {
        reset(hideBouncerWhenShowing, false);
    }

    public boolean isGoingToSleepVisibleNotOccluded() {
        return mGoingToSleepVisibleNotOccluded;
    }
@@ -543,7 +570,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    public boolean onBackPressed(boolean hideImmediately) {
        if (mBouncer.isShowing()) {
            mStatusBar.endAffordanceLaunch();
            reset(hideImmediately);
            reset(hideImmediately, true /* isBackPressed */);
            return true;
        }
        return false;
+4 −1
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ import com.android.server.locksettings.recoverablekeystore.RecoverableKeyStoreMa
import com.android.server.locksettings.SyntheticPasswordManager.AuthenticationResult;
import com.android.server.locksettings.SyntheticPasswordManager.AuthenticationToken;

import lineageos.providers.LineageSettings;

import libcore.util.HexEncoding;

import java.io.ByteArrayOutputStream;
@@ -2129,7 +2131,8 @@ public class LockSettingsService extends ILockSettings.Stub {
            Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
            Secure.LOCK_PATTERN_SIZE,
            Secure.LOCK_DOTS_VISIBLE,
            Secure.LOCK_SHOW_ERROR_PATH
            Secure.LOCK_SHOW_ERROR_PATH,
            LineageSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW
    };

    // Reading these settings needs the contacts permission