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

Commit 1d71b046 authored by Adnan Begovic's avatar Adnan Begovic Committed by Sam Mortimer
Browse files

admin: Restore requireSecureKeyguard interface.

Change-Id: I3c0533bafdae77df953d5bff457a4efdb94167e7
parent 277bada9
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -8109,4 +8109,24 @@ public class DevicePolicyManager {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Lineage: check if secure keyguard is required
     * @hide
     */
    public boolean requireSecureKeyguard() {
        return requireSecureKeyguard(UserHandle.myUserId());
    }

    /** @hide */
    public boolean requireSecureKeyguard(int userHandle) {
        if (mService != null) {
            try {
                return mService.requireSecureKeyguard(userHandle);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to get secure keyguard requirement");
            }
        }
        return true;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -355,4 +355,6 @@ interface IDevicePolicyManager {

    boolean isCurrentInputMethodSetByOwner();
    StringParceledListSlice getOwnerInstalledCaCerts(in UserHandle user);

    boolean requireSecureKeyguard(int userHandle);
}
+26 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ import android.security.IKeyChainAliasCallback;
import android.security.IKeyChainService;
import android.security.KeyChain;
import android.security.KeyChain.KeyChainConnection;
import android.security.KeyStore;
import android.service.persistentdata.PersistentDataBlockManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -6430,6 +6431,31 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }

    /**
     * @hide
     */
    @Override
    public boolean requireSecureKeyguard(int userHandle) {
        if (!mHasFeature) {
            return false;
        }

        int passwordQuality = getPasswordQuality(null, userHandle, false);
        if (passwordQuality > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
            return true;
        }

        int encryptionStatus = getStorageEncryptionStatus(null, userHandle);
        if (encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE
                || encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING) {
            return true;
        }

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


    /**
     * Gets the disabled state for features in keyguard for the given admin,
     * or the aggregate of all active admins if who is null.