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

Commit ccab0c0b authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan
Browse files

LockPatternUtils: isSecure: respect profile settings

When the lock screen is set to secure and overridden to insecure
by profile settings, isSecure() would return true causing confusion
to some code.

For example, attempting to use a lockscreen shortcut
to launch an activity will cause the device to soft-reboot due to
recursive calling and a stack overflow.

Change-Id: I02984671c2a047765f4da1f6a44bb19dea5bf2d3
parent 2f9b1f02
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
package com.android.internal.widget;

import android.app.ActivityManagerNative;
import android.app.Profile;
import android.app.ProfileManager;
import android.app.admin.DevicePolicyManager;
import android.appwidget.AppWidgetManager;
import android.content.ContentResolver;
@@ -158,6 +160,7 @@ public class LockPatternUtils {
    private final ContentResolver mContentResolver;
    private DevicePolicyManager mDevicePolicyManager;
    private ILockSettings mLockSettingsService;
    private ProfileManager mProfileManager;

    // The current user is set by KeyguardViewMediator and shared by all LockPatternUtils.
    private static volatile int sCurrentUserId = UserHandle.USER_NULL;
@@ -180,6 +183,7 @@ public class LockPatternUtils {
    public LockPatternUtils(Context context) {
        mContext = context;
        mContentResolver = context.getContentResolver();
        mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);
    }

    private ILockSettings getLockSettings() {
@@ -1275,8 +1279,9 @@ public class LockPatternUtils {
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
        final boolean secure = isPattern && isLockPatternEnabled() && savedPatternExists()
                || isPassword && savedPasswordExists();
        final boolean isProfileSecure = mProfileManager.getActiveProfile().getScreenLockMode() == Profile.LockMode.DEFAULT;
        final boolean secure = (isPattern && isLockPatternEnabled() && savedPatternExists()
                || isPassword && savedPasswordExists()) && isProfileSecure;
        return secure;
    }