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

Commit b88dd214 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Profile: respect DPM when overriding screen lock (1/2)" into cm-10.1

parents 29b548a4 9e331a9c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.media.AudioManager;
import android.os.Parcel;
@@ -290,6 +291,18 @@ public final class Profile implements Parcelable, Comparable {
        mDirty = true;
    }

    public int getScreenLockModeWithDPM(Context context) {
        // Check device policy
        DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);

        if (dpm.requireSecureKeyguard()) {
            // Always enforce lock screen
            return LockMode.DEFAULT;
        }

        return mScreenLockMode;
    }

    public int getScreenLockMode() {
        return mScreenLockMode;
    }
+17 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.security.KeyStore;
import android.util.Log;

import java.io.IOException;
@@ -1513,4 +1514,20 @@ public class DevicePolicyManager {
            }
        }
    }

    /**
     * CM: check if secure keyguard is required
     * @hide
     */
    public boolean requireSecureKeyguard() {
        int encryptionStatus = getStorageEncryptionStatus();
        if (getPasswordQuality(null) > PASSWORD_QUALITY_UNSPECIFIED ||
                !KeyStore.getInstance().isEmpty() ||
                encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE ||
                encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING) {
            // Require secure keyguard
            return true;
        }
        return false;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -1279,7 +1279,7 @@ public class LockPatternUtils {
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
        final boolean isProfileSecure = mProfileManager.getActiveProfile().getScreenLockMode() == Profile.LockMode.DEFAULT;
        final boolean isProfileSecure = mProfileManager.getActiveProfile().getScreenLockModeWithDPM(mContext) == Profile.LockMode.DEFAULT;
        final boolean secure = (isPattern && isLockPatternEnabled() && savedPatternExists()
                || isPassword && savedPasswordExists()) && isProfileSecure;
        return secure;
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class KeyguardSecurityModel {
        } else if (simState == IccCardConstants.State.PUK_REQUIRED
                && mLockPatternUtils.isPukUnlockScreenEnable()) {
            mode = SecurityMode.SimPuk;
        } else if (mProfileManager.getActiveProfile().getScreenLockMode() != Profile.LockMode.INSECURE) {
        } else if (mProfileManager.getActiveProfile().getScreenLockModeWithDPM(mContext) != Profile.LockMode.INSECURE) {
            final int security = mLockPatternUtils.getKeyguardStoredPasswordQuality();
            switch (security) {
                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+1 −1
Original line number Diff line number Diff line
@@ -924,7 +924,7 @@ public class KeyguardViewMediator {
        Profile profile = mProfileManager.getActiveProfile();
        if (profile != null) {
            if (!lockedOrMissing
                    && profile.getScreenLockMode() == Profile.LockMode.DISABLE) {
                    && profile.getScreenLockModeWithDPM(mContext) == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override");
                return;
            }