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

Commit 8e005bfb authored by DvTonder's avatar DvTonder
Browse files

Framework: Fix Profiles Insecure lock screen not working

This fixes Issue 6226: The insecure lockscreen setting is not being activated with
the use of profiles if the default is secure (PIN or Password)

Change-Id: I2fdb8b8eedd136abfeeb30d2f7397d4eec871cc9
parent 1a599e82
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.AlertDialog;
import android.app.Profile;
import android.app.ProfileManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -39,7 +41,6 @@ import android.os.Parcelable;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -126,6 +127,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase {

    private Parcelable mSavedState;

    // We can use the profile manager to override security
    private ProfileManager mProfileManager;

    /**
     * Either a lock screen (an informational keyguard screen), or an unlock
     * screen (a means for unlocking the device) is shown at any given time.
@@ -461,6 +465,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
        mPluggedIn = mUpdateMonitor.isDevicePluggedIn();
        mScreenOn = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isScreenOn();
        mUpdateMonitor.registerInfoCallback(mInfoCallback);
        mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);

        /**
         * We'll get key events the current screen doesn't use. see
@@ -827,7 +832,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
        boolean secure = false;
        switch (unlockMode) {
            case Pattern:
                secure = mLockPatternUtils.isLockPatternEnabled();
                secure = mLockPatternUtils.isLockPatternEnabled() &&
                    mProfileManager.getActiveProfile().getScreenLockMode() != Profile.LockMode.INSECURE;
                break;
            case SimPin:
                secure = mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED;
@@ -839,7 +845,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
                secure = true;
                break;
            case Password:
                secure = mLockPatternUtils.isLockPasswordEnabled();
                secure = mLockPatternUtils.isLockPasswordEnabled() &&
                    mProfileManager.getActiveProfile().getScreenLockMode() != Profile.LockMode.INSECURE;
                break;
            case Unknown:
                // This means no security is set up