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

Commit 5711b9e4 authored by eray orçunus's avatar eray orçunus Committed by Gerrit Code Review
Browse files

lockscreen: Add option for showing unlock screen directly (1/3)



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

CYNGNOS-1873

Change-Id: I2ceeed348d7e61632b8344f35431f30cba62ca4f
Signed-off-by: default avatareray orçunus <erayorcunus@gmail.com>
parent 6bb3b082
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -726,6 +726,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                   Secure.LOCK_PATTERN_ENABLED,
                   Secure.LOCK_PATTERN_VISIBLE,
                   Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
                   CMSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW,
                   Secure.LOCK_PATTERN_SIZE,
                   Secure.LOCK_DOTS_VISIBLE,
                   Secure.LOCK_SHOW_ERROR_PATH,
+1 −1
Original line number Diff line number Diff line
@@ -1726,7 +1726,7 @@ public class KeyguardViewMediator extends SystemUI {
    private void handleReset() {
        synchronized (KeyguardViewMediator.this) {
            if (DEBUG) Log.d(TAG, "handleReset");
            mStatusBarKeyguardViewManager.reset();
            mStatusBarKeyguardViewManager.reset(false);
        }
    }

+30 −8
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import com.android.keyguard.R;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils;

import org.cyanogenmod.internal.util.CmLockPatternUtils;

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

@@ -40,9 +42,14 @@ import static com.android.keyguard.KeyguardSecurityModel.SecurityMode;
 */
public class 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;

    private Context mContext;
    private ViewMediatorCallback mCallback;
    private LockPatternUtils mLockPatternUtils;
    private CmLockPatternUtils mCmLockPatternUtils;
    private ViewGroup mContainer;
    private StatusBarWindowManager mWindowManager;
    private KeyguardHostView mKeyguardView;
@@ -65,6 +72,7 @@ public class KeyguardBouncer {
        mLockPatternUtils = lockPatternUtils;
        mContainer = container;
        mWindowManager = windowManager;
        mCmLockPatternUtils = new CmLockPatternUtils(mContext);
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
    }

@@ -207,28 +215,42 @@ 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;
            // "Bouncer first" mode currently only available to some security methods.
            else if ((mode == SecurityMode.Pattern || mode == SecurityMode.Password
                    || mode == SecurityMode.PIN) && (mLockPatternUtils != null &&
                    mCmLockPatternUtils.shouldPassToSecurityView(
                    KeyguardUpdateMonitor.getCurrentUser())))
                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;
        }
        return false;
            if (mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk)
                return UNLOCK_SEQUENCE_FORCE_BOUNCER;
            // "Bouncer first" mode currently only available to some security methods.
            else if ((mode == SecurityMode.Pattern || mode == SecurityMode.Password
                    || mode == SecurityMode.PIN) && (mLockPatternUtils != null &&
                    mCmLockPatternUtils.shouldPassToSecurityView(
                    KeyguardUpdateMonitor.getCurrentUser())))
                return UNLOCK_SEQUENCE_BOUNCER_FIRST;
        }
        return UNLOCK_SEQUENCE_DEFAULT;
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -5211,6 +5211,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE");
            mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
        }
        mWindowManagerService
        vibrateForCameraGesture();
        if (!mStatusBarKeyguardViewManager.isShowing()) {
            startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT,
+33 −17
Original line number Diff line number Diff line
@@ -114,23 +114,38 @@ public class StatusBarKeyguardViewManager {
        mShowing = true;
        mStatusBarWindowManager.setKeyguardShowing(true);
        mScrimController.abortKeyguardFadingOut();
        reset();
        reset(false);
    }

    /**
     * Shows the notification keyguard or the bouncer depending on
     * {@link KeyguardBouncer#needsFullscreenBouncer()}.
     */
    private void showBouncerOrKeyguard() {
        if (mBouncer.needsFullscreenBouncer()) {

    private void showBouncerOrKeyguard(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 pass to security view" 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;
        }
    }

@@ -157,14 +172,14 @@ public class StatusBarKeyguardViewManager {
    /**
     * Reset the state of the view.
     */
    public void reset() {
    public void reset(boolean isBackPressed) {
        if (mShowing) {
            if (mOccluded) {
                mPhoneStatusBar.hideKeyguard();
                mPhoneStatusBar.stopWaitingForKeyguardExit();
                mBouncer.hide(false /* destroyView */);
            } else {
                showBouncerOrKeyguard();
                showBouncerOrKeyguard(isBackPressed);
            }
            KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
            updateStates();
@@ -233,7 +248,7 @@ public class StatusBarKeyguardViewManager {
                            @Override
                            public void run() {
                                mStatusBarWindowManager.setKeyguardOccluded(mOccluded);
                                reset();
                                reset(false);
                            }
                        });
                return;
@@ -245,7 +260,7 @@ public class StatusBarKeyguardViewManager {
        if (mUnlockFab != null && mUnlockFab.isAttachedToWindow() && !occluded) {
            hideUnlockFab();
        }
        reset();
        reset(false);
    }

    public boolean isOccluded() {
@@ -416,7 +431,7 @@ public class StatusBarKeyguardViewManager {
    public boolean onBackPressed() {
        if (mBouncer.isShowing()) {
            mPhoneStatusBar.endAffordanceLaunch();
            reset();
            reset(true);
            return true;
        }
        return false;
@@ -449,7 +464,8 @@ public class StatusBarKeyguardViewManager {
        boolean showing = mShowing;
        boolean occluded = mOccluded;
        boolean bouncerShowing = mBouncer.isShowing();
        boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
        boolean bouncerDismissible = (mBouncer.isFullscreenBouncer() !=
                KeyguardBouncer.UNLOCK_SEQUENCE_FORCE_BOUNCER);

        if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing)
                || mFirstUpdate) {
Loading