diff options
author | Jim Miller <jaggies@google.com> | 2014-10-16 19:50:18 -0700 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2014-10-17 16:08:21 -0700 |
commit | dd5de719c5a0d39030f94d931c0ab1bed1f147f8 (patch) | |
tree | 58510c4971e21e02768d7d6764e257aa01dcd8b4 /core/java/com | |
parent | a865bb5df834194dee339db615c17d7c7b63aaa3 (diff) | |
download | frameworks_base-dd5de719c5a0d39030f94d931c0ab1bed1f147f8.zip frameworks_base-dd5de719c5a0d39030f94d931c0ab1bed1f147f8.tar.gz frameworks_base-dd5de719c5a0d39030f94d931c0ab1bed1f147f8.tar.bz2 |
Add utility methods to LockPatternUtils for encryption
This enables a change in Settings that allows device
encryption to be disabled by the user.
Fixes bug 17881324
Change-Id: I34dfc586df1a598bf969dc82adf8537a2730d345
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); + } } |