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

Unverified Commit 95547433 authored by Adnan Begovic's avatar Adnan Begovic Committed by Michael Bestas
Browse files

admin: Restore requireSecureKeyguard interface.

Change-Id: I3c0533bafdae77df953d5bff457a4efdb94167e7
parent 1024ad16
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -18748,4 +18748,24 @@ public class DevicePolicyManager {
        // TODO(b/434920631): Remove this method and use {@link #setPolicy} in tests directly.
        setPolicy(new PolicyIdentifier<Integer>(key), scope, Integer.valueOf(value));
    }
    /**
     * 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
@@ -663,4 +663,6 @@ interface IDevicePolicyManager {
    int getAppFunctionsPolicy(String callerPackageName, int userId);

    void setPolicy(in String callerPackageName, in String policy, in int scope, in PolicyValueTransport value);

    boolean requireSecureKeyguard(int userHandle);
}
+24 −0
Original line number Diff line number Diff line
@@ -9776,6 +9776,30 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                .write();
    }
    /**
     * @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.