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

Commit 0be286de authored by eray orçunus's avatar eray orçunus Committed by Sam Mortimer
Browse files

lockscreen: Add option 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 183486f8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \
    src/com/android/providers/settings/EventLogTags.logtags

LOCAL_JAVA_LIBRARIES := telephony-common ims-common
LOCAL_STATIC_JAVA_LIBRARIES := junit legacy-android-test
LOCAL_STATIC_JAVA_LIBRARIES := junit legacy-android-test \
    org.lineageos.platform.internal

LOCAL_PACKAGE_NAME := SettingsProvider
LOCAL_CERTIFICATE := platform
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;

import lineageos.providers.LineageSettings;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@@ -721,6 +723,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                   Secure.LOCK_PATTERN_ENABLED,
                   Secure.LOCK_PATTERN_VISIBLE,
                   Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
                   LineageSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW,
                   "lockscreen.password_type",
                   "lockscreen.lockoutattemptdeadline",
                   "lockscreen.patterneverchosen",
+33 −8
Original line number Diff line number Diff line
@@ -40,6 +40,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 static com.android.keyguard.KeyguardHostView.OnDismissAction;
import static com.android.keyguard.KeyguardSecurityModel.SecurityMode;

@@ -53,10 +55,16 @@ 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;

    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;

    protected KeyguardHostView mKeyguardView;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
@@ -81,6 +89,7 @@ public class KeyguardBouncer {
        mFalsingManager = FalsingManager.getInstance(mContext);
        mDismissCallbackRegistry = dismissCallbackRegistry;
        mHandler = new Handler();
        mLineageLockPatternUtils = new LineageLockPatternUtils(mContext);
    }

    public void show(boolean resetSecuritySelection) {
@@ -263,28 +272,44 @@ public class KeyguardBouncer {
    }

    /**
     * @return True if and only if the security method should be shown before showing the
     * notifications on Keyguard, like SIM PIN/PUK.
     * @return Whether the bouncer should be shown first, this could be because of SIM PIN/PUK
     * or it just could be chosen to be shown first.
     */
    public boolean needsFullscreenBouncer() {
    public int needsFullscreenBouncer() {
        ensureView();
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
            if (mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk) {
                return 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
                return UNLOCK_SEQUENCE_BOUNCER_FIRST;
            }
        return false;
        }
        return UNLOCK_SEQUENCE_DEFAULT;
    }

    /**
     * Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which
     * makes this method much faster.
     */
    public boolean isFullscreenBouncer() {
    public int isFullscreenBouncer() {
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
            if (mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk) {
                return 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
                return UNLOCK_SEQUENCE_BOUNCER_FIRST;
            }
        }
        return false;
        return UNLOCK_SEQUENCE_DEFAULT;
    }

    /**
+43 −16
Original line number Diff line number Diff line
@@ -149,18 +149,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()) {

    protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing, boolean isBackPressed) {
        switch (mBouncer.needsFullscreenBouncer()) {
            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) {
                    mBouncer.hide(false /* destroyView */);
                    mBouncer.prepare();
                }
                break;
            default:
                break;
        }
    }

@@ -194,20 +213,27 @@ 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) {
                mStatusBar.hideKeyguard();
                mStatusBar.stopWaitingForKeyguardExit();
                mBouncer.hide(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 void onStartedGoingToSleep() {
        mStatusBar.onStartedGoingToSleep();
    }
@@ -485,7 +511,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    public boolean onBackPressed() {
        if (mBouncer.isShowing()) {
            mStatusBar.endAffordanceLaunch();
            reset(true /* hideBouncerWhenShowing */);
            reset(true /* hideBouncerWhenShowing */, true /* isBackPressed */);
            return true;
        }
        return false;
@@ -518,7 +544,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        boolean showing = mShowing;
        boolean occluded = mOccluded;
        boolean bouncerShowing = mBouncer.isShowing();
        boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
        boolean bouncerDismissible =
                mBouncer.isFullscreenBouncer() != KeyguardBouncer.UNLOCK_SEQUENCE_FORCE_BOUNCER;
        boolean remoteInputActive = mRemoteInputActive;

        if ((bouncerDismissible || !showing || remoteInputActive) !=
+4 −1
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ import com.android.server.LockSettingsStorage.CredentialHash;
import com.android.server.SyntheticPasswordManager.AuthenticationResult;
import com.android.server.SyntheticPasswordManager.AuthenticationToken;

import lineageos.providers.LineageSettings;

import libcore.util.HexEncoding;

import java.io.ByteArrayOutputStream;
@@ -1767,7 +1769,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