From c33639b26bf57a5ad2d9bb8dd759ec4014c19538 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 14 Dec 2022 03:35:01 +0000 Subject: [PATCH] Stop setting Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT This setting was specific to FDE, so it no longer serves any purpose. Both the Settings app and LockSettingsService can potentially set it, but only to the value 0. This CL removes the corresponding code from LockSettingsService, so this setting will no longer be set. Test: atest com.android.server.locksettings Bug: 208476087 Change-Id: I34b749ac0aeb7f38d8208b10f29d3b061aadc40c --- .../locksettings/LockSettingsService.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index f6cdba05a07c4..2253a9ae4c9f5 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -1688,10 +1688,6 @@ public class LockSettingsService extends ILockSettings.Stub { } private void onPostPasswordChanged(LockscreenCredential newCredential, int userHandle) { - if (userHandle == UserHandle.USER_SYSTEM && isDeviceEncryptionEnabled() && - shouldEncryptWithCredentials() && newCredential.isNone()) { - setCredentialRequiredToDecrypt(false); - } if (newCredential.isPattern()) { setBoolean(LockPatternUtils.PATTERN_EVER_CHOSEN_KEY, true, userHandle); } @@ -1769,24 +1765,6 @@ public class LockSettingsService extends ILockSettings.Stub { return mInjector.getDevicePolicyManager().getPasswordHistoryLength(null, userId); } - private static boolean isDeviceEncryptionEnabled() { - return StorageManager.isEncrypted(); - } - - private boolean shouldEncryptWithCredentials() { - return isCredentialRequiredToDecrypt() && !isDoNotAskCredentialsOnBootSet(); - } - - private boolean isDoNotAskCredentialsOnBootSet() { - return mInjector.getDevicePolicyManager().getDoNotAskCredentialsOnBoot(); - } - - private boolean isCredentialRequiredToDecrypt() { - final int value = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, -1); - return value != 0; - } - private UserManager getUserManagerFromCache(int userId) { UserHandle userHandle = UserHandle.of(userId); if (mUserManagerCache.containsKey(userHandle)) { @@ -1808,13 +1786,6 @@ public class LockSettingsService extends ILockSettings.Stub { return getUserManagerFromCache(userId).isCredentialSharableWithParent(); } - private void setCredentialRequiredToDecrypt(boolean required) { - if (isDeviceEncryptionEnabled()) { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, required ? 1 : 0); - } - } - /** Register the given WeakEscrowTokenRemovedListener. */ @Override public boolean registerWeakEscrowTokenRemovedListener(