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

Commit cc0ef24f authored by eray orçunus's avatar eray orçunus Committed by Michael Bestas
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 4f231e89
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -716,6 +716,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                   Secure.LOCK_PATTERN_ENABLED,
                   Secure.LOCK_PATTERN_VISIBLE,
                   Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
                   "lock_screen_pass_to_security_view",
                   "lockscreen.password_type",
                   "lockscreen.lockoutattemptdeadline",
                   "lockscreen.patterneverchosen",
+28 −10
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import com.android.systemui.R;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.FalsingManager;

import org.lineageos.internal.util.LineageLockPatternUtils;

import java.io.PrintWriter;

/**
@@ -62,6 +64,7 @@ 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;
@@ -94,6 +97,10 @@ public class KeyguardBouncer {
    private boolean mIsScrimmed;
    private ViewGroup mLockIconContainer;

    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;

    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils, ViewGroup container,
            DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager,
@@ -112,6 +119,7 @@ public class KeyguardBouncer {
        mUnlockMethodCache = unlockMethodCache;
        mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback);
        mKeyguardBypassController = keyguardBypassController;
        mLineageLockPatternUtils = new LineageLockPatternUtils(mContext);
    }

    public void show(boolean resetSecuritySelection) {
@@ -463,17 +471,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;
    }

    /**
@@ -481,11 +503,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
@@ -309,17 +309,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();
    }
@@ -385,7 +405,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();
@@ -393,13 +413,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;
    }
@@ -714,7 +741,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                hideBouncer(false);
                updateStates();
            } else {
                reset(hideImmediately);
                reset(hideImmediately, true /* isBackPressed */);
            }
            return true;
        }
+4 −1
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@ import com.android.server.locksettings.SyntheticPasswordManager.AuthenticationTo
import com.android.server.locksettings.recoverablekeystore.RecoverableKeyStoreManager;
import com.android.server.wm.WindowManagerInternal;

import lineageos.providers.LineageSettings;

import libcore.util.HexEncoding;

import java.io.ByteArrayOutputStream;
@@ -2327,7 +2329,8 @@ public class LockSettingsService extends ILockSettings.Stub {
            Secure.LOCK_PATTERN_ENABLED,
            Secure.LOCK_BIOMETRIC_WEAK_FLAGS,
            Secure.LOCK_PATTERN_VISIBLE,
            Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED
            Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
            LineageSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW
    };

    // Reading these settings needs the contacts permission