diff options
author | Jim Miller <jaggies@google.com> | 2014-10-17 23:57:33 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-17 23:57:33 +0000 |
commit | d9b81b11b9c3c61d21565d7c6ac250fba1a4f052 (patch) | |
tree | 7af9e47d337a5ca060adfbf75c79100e14bbc407 /core/java/com | |
parent | a801d34911bfb0a1e662fdf124d7c02fb4ffaf27 (diff) | |
parent | a054a8280c1316a1f805cc86f00f571a3b1cfc2f (diff) | |
download | frameworks_base-d9b81b11b9c3c61d21565d7c6ac250fba1a4f052.zip frameworks_base-d9b81b11b9c3c61d21565d7c6ac250fba1a4f052.tar.gz frameworks_base-d9b81b11b9c3c61d21565d7c6ac250fba1a4f052.tar.bz2 |
am a054a828: am c6c843fb: Merge "Add utility methods to LockPatternUtils for encryption" into lmp-dev
* commit 'a054a8280c1316a1f805cc86f00f571a3b1cfc2f':
Add utility methods to LockPatternUtils for encryption
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 412b4d2..d6885da 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -560,9 +560,7 @@ public class LockPatternUtils { // 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; + final boolean required = isCredentialRequiredToDecrypt(true); if (!required) { clearEncryptionPassword(); } else { @@ -793,10 +791,7 @@ public class LockPatternUtils { // 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) { + if (!isCredentialRequiredToDecrypt(true)) { clearEncryptionPassword(); } else { boolean numeric = computedQuality @@ -1658,4 +1653,19 @@ public class LockPatternUtils { private void onAfterChangingPassword() { getTrustManager().reportEnabledTrustAgentsChanged(getCurrentOrCallingUserId()); } + + public boolean isCredentialRequiredToDecrypt(boolean defaultValue) { + final int value = Settings.Global.getInt(mContentResolver, + Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, -1); + return value == -1 ? defaultValue : (value != 0); + } + + public void setCredentialRequiredToDecrypt(boolean required) { + if (getCurrentUser() != UserHandle.USER_OWNER) { + Log.w(TAG, "Only device owner may call setCredentialRequiredForDecrypt()"); + return; + } + Settings.Global.putInt(mContext.getContentResolver(), + Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, required ? 1 : 0); + } } |