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

Commit 856a818e authored by Daniel Tschinder's avatar Daniel Tschinder Committed by Steve Kondik
Browse files

Option to disable lockscreen if security screen lock active (1/3)

[This patch consists of three commits. This one, one for Settings and one for CMParts.]

Adds an option to CMParts that allows to turn off lockscreen if
a security screen lock is enabled.

Default value for new users is "disabled", so the lockscreen is always displayed before
the security screen.

If you update from an earlier build of CM, this option will be automatically enabled if pattern lock is
active and otherwise disabled.

Change-Id: I03a9b3815329f4541debbfd4255e64d08d6a3b9d
parent 5209317d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2423,6 +2423,12 @@ public final class Settings {
         */
        public static final String VOLUME_WAKE_SCREEN = "volume_wake_screen";

        /**
         * Whether the lockscreen should be disabled if security is on
         * @hide
         */
        public static final String LOCKSCREEN_DISABLE_ON_SECURITY = "lockscreen_disable_on_security";

        /**
         * Whether to use the custom quick unlock screen control
         * @hide
+29 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -136,6 +137,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
     */
    private Mode mMode = Mode.LockScreen;

    /**
     * Whether the lockscreen should be disabled if security is on
     */
    private boolean mLockscreenDisableOnSecurity;

    /**
     * Keeps track of what mode the current unlock screen is (cached from most recent computation in
     * {@link #getUnlockMode}).
@@ -203,6 +209,27 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
        mLockPatternUtils = lockPatternUtils;
        mWindowController = controller;

        int LockscreenDisableOnSecurityValue = Settings.System.getInt(
                mContext.getContentResolver(), Settings.System.LOCKSCREEN_DISABLE_ON_SECURITY, 3);

        if (LockscreenDisableOnSecurityValue == 3) {
            // We don't have the option set, check if pattern security is
            // enabled and set the option accordingly
            final boolean usingLockPattern = mLockPatternUtils.isLockPatternEnabled();

            if (usingLockPattern) {
                Settings.System.putInt(mContext.getContentResolver(),
                        Settings.System.LOCKSCREEN_DISABLE_ON_SECURITY, 1);
                LockscreenDisableOnSecurityValue = 1;
            } else {
                Settings.System.putInt(mContext.getContentResolver(),
                        Settings.System.LOCKSCREEN_DISABLE_ON_SECURITY, 0);
                LockscreenDisableOnSecurityValue = 0;
            }
        }

        mLockscreenDisableOnSecurity = LockscreenDisableOnSecurityValue == 1;

        mMode = getInitialMode();

        mKeyguardScreenCallback = new KeyguardScreenCallback() {
@@ -657,10 +684,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
        if (stuckOnLockScreenBecauseSimMissing() || (simState == IccCard.State.PUK_REQUIRED)) {
            return Mode.LockScreen;
        } else {
            // Show LockScreen first for any screen other than Pattern unlock.
            final boolean usingLockPattern = mLockPatternUtils.getKeyguardStoredPasswordQuality()
                    == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
            if (isSecure() && usingLockPattern) {
            // Disable LockScreen if security lockscreen is active and option in CMParts set
            if (mLockscreenDisableOnSecurity && isSecure()) {
                return Mode.UnlockScreen;
            } else {
                return Mode.LockScreen;