Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -6569,6 +6569,15 @@ public final class Settings { */ public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned"; /** * Whether the user wants to be prompted for password to decrypt the device on boot. * This only matters if the storage is encrypted. * <p> * Type: int (0 for false, 1 for true) * @hide */ public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt"; /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. Loading core/java/com/android/internal/widget/LockPatternUtils.java +41 −12 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.IMountService; Loading Loading @@ -556,12 +557,19 @@ public class LockPatternUtils { getLockSettings().setLockPattern(patternToString(pattern), userId); DevicePolicyManager dpm = getDevicePolicyManager(); if (pattern != null) { int userHandle = userId; if (userHandle == UserHandle.USER_OWNER) { // Update the device encryption password. if (userId == UserHandle.USER_OWNER && LockPatternUtils.isDeviceEncryptionEnabled()) { final ContentResolver cr = mContext.getContentResolver(); final boolean required = Settings.Global.getInt(cr, Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 1) == 1 ? true : false; if (!required) { clearEncryptionPassword(); } else { String stringPattern = patternToString(pattern); updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern); } } setBoolean(PATTERN_EVER_CHOSEN_KEY, true); if (!isFallback) { Loading Loading @@ -785,14 +793,24 @@ public class LockPatternUtils { getLockSettings().setLockPassword(password, userHandle); int computedQuality = computePasswordQuality(password); if (userHandle == UserHandle.USER_OWNER) { // Update the encryption password. int type = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC || computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX ? StorageManager.CRYPT_TYPE_PIN // Update the device encryption password. if (userHandle == UserHandle.USER_OWNER && LockPatternUtils.isDeviceEncryptionEnabled()) { final ContentResolver cr = mContext.getContentResolver(); final boolean required = Settings.Global.getInt(cr, Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 1) == 1 ? true : false; if (!required) { clearEncryptionPassword(); } else { boolean numeric = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; boolean numericComplex = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX; int type = numeric || numericComplex ? StorageManager.CRYPT_TYPE_PIN : StorageManager.CRYPT_TYPE_PASSWORD; updateEncryptionPassword(type, password); } } if (!isFallback) { deleteGallery(); Loading Loading @@ -894,6 +912,17 @@ public class LockPatternUtils { return true; } /** * Determine if the device supports encryption, even if it's set to default. This * differs from isDeviceEncrypted() in that it returns true even if the device is * encrypted with the default password. * @return true if device encryption is enabled */ public static boolean isDeviceEncryptionEnabled() { final String status = SystemProperties.get("ro.crypto.state", "unsupported"); return "encrypted".equalsIgnoreCase(status); } /** * Clears the encryption password. */ Loading Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -6569,6 +6569,15 @@ public final class Settings { */ public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned"; /** * Whether the user wants to be prompted for password to decrypt the device on boot. * This only matters if the storage is encrypted. * <p> * Type: int (0 for false, 1 for true) * @hide */ public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt"; /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. Loading
core/java/com/android/internal/widget/LockPatternUtils.java +41 −12 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.IMountService; Loading Loading @@ -556,12 +557,19 @@ public class LockPatternUtils { getLockSettings().setLockPattern(patternToString(pattern), userId); DevicePolicyManager dpm = getDevicePolicyManager(); if (pattern != null) { int userHandle = userId; if (userHandle == UserHandle.USER_OWNER) { // Update the device encryption password. if (userId == UserHandle.USER_OWNER && LockPatternUtils.isDeviceEncryptionEnabled()) { final ContentResolver cr = mContext.getContentResolver(); final boolean required = Settings.Global.getInt(cr, Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 1) == 1 ? true : false; if (!required) { clearEncryptionPassword(); } else { String stringPattern = patternToString(pattern); updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern); } } setBoolean(PATTERN_EVER_CHOSEN_KEY, true); if (!isFallback) { Loading Loading @@ -785,14 +793,24 @@ public class LockPatternUtils { getLockSettings().setLockPassword(password, userHandle); int computedQuality = computePasswordQuality(password); if (userHandle == UserHandle.USER_OWNER) { // Update the encryption password. int type = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC || computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX ? StorageManager.CRYPT_TYPE_PIN // Update the device encryption password. if (userHandle == UserHandle.USER_OWNER && LockPatternUtils.isDeviceEncryptionEnabled()) { final ContentResolver cr = mContext.getContentResolver(); final boolean required = Settings.Global.getInt(cr, Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 1) == 1 ? true : false; if (!required) { clearEncryptionPassword(); } else { boolean numeric = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; boolean numericComplex = computedQuality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX; int type = numeric || numericComplex ? StorageManager.CRYPT_TYPE_PIN : StorageManager.CRYPT_TYPE_PASSWORD; updateEncryptionPassword(type, password); } } if (!isFallback) { deleteGallery(); Loading Loading @@ -894,6 +912,17 @@ public class LockPatternUtils { return true; } /** * Determine if the device supports encryption, even if it's set to default. This * differs from isDeviceEncrypted() in that it returns true even if the device is * encrypted with the default password. * @return true if device encryption is enabled */ public static boolean isDeviceEncryptionEnabled() { final String status = SystemProperties.get("ro.crypto.state", "unsupported"); return "encrypted".equalsIgnoreCase(status); } /** * Clears the encryption password. */ Loading