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

Commit 96265c65 authored by Roman Birg's avatar Roman Birg
Browse files

update secure keyguard check



We use this method to determine wither to allow profiles and the lock
screen tile whether to allow messing with the lockscreen.

Don't check whether the keystore is empty. Check whether we allow trust
agents by DPM. And also make keyguard use this method to respect it.

Ref: CYNGNOS-1930

Change-Id: I1a2b26419d43bd2bbc1d4a5027f1ed78d2744466
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 6ba6b8cf
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -1249,15 +1249,7 @@ public class KeyguardViewMediator extends SystemUI {
        DevicePolicyManager dpm = (DevicePolicyManager)
                mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
        if (dpm != null) {
            int passwordQuality = dpm.getPasswordQuality(null);
            switch (passwordQuality) {
                case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
                case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
                case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
                case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
                    return true;
            }
            return dpm.requireSecureKeyguard();
        }
        return false;
    }
+7 −4
Original line number Diff line number Diff line
@@ -106,17 +106,20 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
            state.visible = mediator.isKeyguardBound();

            if (mediator.isProfileDisablingKeyguard()) {
                state.value = false;
                state.enabled = false;
                state.label = mContext.getString(
                        R.string.quick_settings_lockscreen_label_locked_by_profile);
                state.value = false;
            } else if (lockscreenEnforced) {
                state.value = true;
                state.enabled = false;
                state.label = mContext.getString(
                        R.string.quick_settings_lockscreen_label_enforced);
            } else {
                state.value = lockscreenEnabled;
                state.enabled = !mKeyguard.isShowing() || !mKeyguard.isSecure();

                state.label = mContext.getString(lockscreenEnforced
                        ? R.string.quick_settings_lockscreen_label_enforced
                        : R.string.quick_settings_lockscreen_label);
                state.label = mContext.getString(R.string.quick_settings_lockscreen_label);
            }
            // update icon
            if (lockscreenEnabled) {
+2 −12
Original line number Diff line number Diff line
@@ -4215,18 +4215,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                || encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING) {
            return true;
        }

        // Keystore.isEmpty() requires system UID
        long token = Binder.clearCallingIdentity();
        try {
            if (!KeyStore.getInstance().isEmpty()) {
                return true;
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }

        return false;
        final int keyguardDisabledFeatures = getKeyguardDisabledFeatures(null, userHandle);
        return (keyguardDisabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
    }

    // Returns the active device owner or null if there is no device owner.