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

Unverified Commit 9accab15 authored by eray orçunus's avatar eray orçunus Committed by Michael Bestas
Browse files

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>

SettingsProvider: Add missing platform sdk dependency
Change-Id: I4844eaa0a989bf634a2251e95dc84a505037c012

The change-id below is so that Gerrit won't get confused.
Change-Id: I0cfb43bfb631fce532dfacdf56455309a04ddfa2
parent 43c7c944
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) \
    src/com/android/providers/settings/EventLogTags.logtags

LOCAL_JAVA_LIBRARIES := telephony-common ims-common
LOCAL_STATIC_JAVA_LIBRARIES := org.cyanogenmod.platform.sdk

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

import cyanogenmod.providers.CMSettings;

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

@@ -739,6 +741,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                   Secure.LOCK_PATTERN_SIZE,
                   Secure.LOCK_DOTS_VISIBLE,
                   Secure.LOCK_SHOW_ERROR_PATH,
                   CMSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW,
                   "lockscreen.password_type",
                   "lockscreen.lockoutattemptdeadline",
                   "lockscreen.patterneverchosen",
+32 −8
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils;
import com.android.systemui.classifier.FalsingManager;

import org.cyanogenmod.internal.util.CmLockPatternUtils;

import static com.android.keyguard.KeyguardHostView.OnDismissAction;
import static com.android.keyguard.KeyguardSecurityModel.SecurityMode;

@@ -48,9 +50,14 @@ public class KeyguardBouncer {

    final static private String TAG = "KeyguardBouncer";

    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 Context mContext;
    protected ViewMediatorCallback mCallback;
    protected LockPatternUtils mLockPatternUtils;
    private CmLockPatternUtils mCmLockPatternUtils;
    protected ViewGroup mContainer;
    private StatusBarWindowManager mWindowManager;
    protected KeyguardHostView mKeyguardView;
@@ -76,6 +83,7 @@ public class KeyguardBouncer {
        mWindowManager = windowManager;
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
        mFalsingManager = FalsingManager.getInstance(mContext);
        mCmLockPatternUtils = new CmLockPatternUtils(mContext);
    }

    public void show(boolean resetSecuritySelection) {
@@ -248,28 +256,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
                    && mCmLockPatternUtils.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
                    && mCmLockPatternUtils.shouldPassToSecurityView(
                            KeyguardUpdateMonitor.getCurrentUser()))) {
                // "Bouncer first" mode is only available to some security methods
                return UNLOCK_SEQUENCE_BOUNCER_FIRST;
            }
        }
        return false;
        return UNLOCK_SEQUENCE_DEFAULT;
    }

    /**
+39 −14
Original line number Diff line number Diff line
@@ -124,16 +124,33 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
     * Shows the notification keyguard or the bouncer depending on
     * {@link KeyguardBouncer#needsFullscreenBouncer()}.
     */
    protected void showBouncerOrKeyguard() {
        if (mBouncer.needsFullscreenBouncer()) {

    protected void showBouncerOrKeyguard(final 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.
                mPhoneStatusBar.hideKeyguard();
                mBouncer.show(true /* resetSecuritySelection */);
                break;
            case KeyguardBouncer.UNLOCK_SEQUENCE_BOUNCER_FIRST:
                // Pattern / PIN / password with "Directly show " enabled
                if (isBackPressed) {
                    mPhoneStatusBar.showKeyguard();
                    mBouncer.hide(false /* destroyView */);
                    mBouncer.prepare();
                } else {
                    // The keyguard might be showing (already). So we need to hide it.
                    mPhoneStatusBar.hideKeyguard();
                    mBouncer.show(true /* resetSecuritySelection */);
                }
                break;
            case KeyguardBouncer.UNLOCK_SEQUENCE_DEFAULT:
                mPhoneStatusBar.showKeyguard();
                mBouncer.hide(false /* destroyView */);
                mBouncer.prepare();
                break;
            default:
                break;
        }
    }

@@ -160,20 +177,27 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    /**
     * Reset the state of the view.
     */
    public void reset() {
    public void reset(final boolean isBackPressed) {
        if (mShowing) {
            if (mOccluded) {
                mPhoneStatusBar.hideKeyguard();
                mPhoneStatusBar.stopWaitingForKeyguardExit();
                mBouncer.hide(false /* destroyView */);
            } else {
                showBouncerOrKeyguard();
                showBouncerOrKeyguard(isBackPressed);
            }
            KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
            updateStates();
        }
    }

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

    public void onStartedGoingToSleep() {
        mPhoneStatusBar.onStartedGoingToSleep();
    }
@@ -434,7 +458,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    public boolean onBackPressed() {
        if (mBouncer.isShowing()) {
            mPhoneStatusBar.endAffordanceLaunch();
            reset();
            reset(true);
            return true;
        }
        return false;
@@ -467,7 +491,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) !=
+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.VerifyCredentialResponse;
import com.android.server.LockSettingsStorage.CredentialHash;

import cyanogenmod.providers.CMSettings;

import libcore.util.HexEncoding;

import java.io.ByteArrayOutputStream;
@@ -1633,6 +1635,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        Secure.LOCK_PATTERN_SIZE,
        Secure.LOCK_DOTS_VISIBLE,
        Secure.LOCK_SHOW_ERROR_PATH,
        CMSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW,
    };

    // Reading these settings needs the contacts permission