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

Commit 50e62183 authored by Jim Miller's avatar Jim Miller
Browse files

Add new DevicePolicyManager disable flags for keyguard.

- KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
- KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
- KEYGUARD_DISABLE_TRUST_AGENTS

Change-Id: I4ed2b9cef78b497d87bb719c57fabdad94c18e82
parent 7bdcc0b1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -5010,7 +5010,10 @@ package android.app.admin {
    field public static final int KEYGUARD_DISABLE_FEATURES_ALL = 2147483647; // 0x7fffffff
    field public static final int KEYGUARD_DISABLE_FEATURES_NONE = 0; // 0x0
    field public static final int KEYGUARD_DISABLE_SECURE_CAMERA = 2; // 0x2
    field public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1; // 0x1
    field public static final int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS = 4; // 0x4
    field public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 16; // 0x10
    field public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 8; // 0x8
    field public static final deprecated int KEYGUARD_DISABLE_WIDGETS_ALL = 1; // 0x1
    field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
    field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
    field public static final int PASSWORD_QUALITY_BIOMETRIC_WEAK = 32768; // 0x8000
+21 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.trust.TrustAgentService;
import android.util.Log;

import com.android.org.conscrypt.TrustedCertificateStore;
@@ -1267,7 +1268,8 @@ public class DevicePolicyManager {
    public static final int KEYGUARD_DISABLE_FEATURES_NONE = 0;

    /**
     * Disable all keyguard widgets
     * Disable all keyguard widgets. Has no effect.
     * @deprecated
     */
    public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1 << 0;

@@ -1276,6 +1278,22 @@ public class DevicePolicyManager {
     */
    public static final int KEYGUARD_DISABLE_SECURE_CAMERA = 1 << 1;

    /**
     * Disable showing all notifications on secure keyguard screens (e.g. PIN/Pattern/Password)
     */
    public static final int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS = 1 << 2;

    /**
     * Only allow redacted notifications on secure keyguard screens (e.g. PIN/Pattern/Password)
     */
    public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 1 << 3;

    /**
     * Ignore {@link TrustAgentService} state on secure keyguard screens
     * (e.g. PIN/Pattern/Password).
     */
    public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 1 << 4;

    /**
     * Disable all current and future keyguard customizations.
     */
@@ -1496,7 +1514,8 @@ public class DevicePolicyManager {
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param which {@link #KEYGUARD_DISABLE_FEATURES_NONE} (default),
     * {@link #KEYGUARD_DISABLE_WIDGETS_ALL}, {@link #KEYGUARD_DISABLE_SECURE_CAMERA},
     * {@link #KEYGUARD_DISABLE_FEATURES_ALL}
     * {@link #KEYGUARD_DISABLE_SECURE_NOTIFICATIONS}, {@link #KEYGUARD_DISABLE_TRUST_AGENTS},
     * {@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS}, {@link #KEYGUARD_DISABLE_FEATURES_ALL}
     */
    public void setKeyguardDisabledFeatures(ComponentName admin, int which) {
        if (mService != null) {
+22 −1
Original line number Diff line number Diff line
@@ -215,8 +215,29 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        mUserHasTrust.put(userId, enabled);
    }

    private boolean isTrustDisabled(int userId) {
        final DevicePolicyManager dpm =
                (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
        if (dpm != null) {
                // TODO once UI is finalized
                final boolean disabledByGlobalActions = false;
                final boolean disabledBySettings = false;

                // Don't allow trust agent if device is secured with a SIM PIN. This is here
                // mainly because there's no other way to prompt the user to enter their SIM PIN
                // once they get past the keyguard screen.
                final boolean disabledBySimPin = isSimPinSecure();

                final boolean disabledByDpm = (dpm.getKeyguardDisabledFeatures(null, userId)
                        & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
                return disabledByDpm || disabledByGlobalActions || disabledBySettings
                        || disabledBySimPin;
        }
        return false;
    }

    public boolean getUserHasTrust(int userId) {
        return mUserHasTrust.get(userId);
        return !isTrustDisabled(userId) && mUserHasTrust.get(userId);
    }

    static class DisplayClientState {