summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2015-12-03 14:27:34 -0500
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2019-12-25 17:07:34 +0100
commit1dfda0226970d7c93aeeeb617359b80d4ba68045 (patch)
treec98edb3014aa12019bdafd61cf4575bb3dce7d76
parent8462e4fd2590515a1a4579c6a9f9f5ffa1029d4e (diff)
downloadframeworks_base-1dfda0226970d7c93aeeeb617359b80d4ba68045.tar.gz
frameworks_base-1dfda0226970d7c93aeeeb617359b80d4ba68045.tar.bz2
frameworks_base-1dfda0226970d7c93aeeeb617359b80d4ba68045.zip
support separate encryption/lockscreen passwords
This adds the necessary infrastructure for allowing users to opt-in to a distinct device encryption passphrase. The passwords are still tied together by default. This makes it possible to use a complex encryption passphrase without losing the convenience of a very simple lockscreen pin. This feature can be combined with a forced reboot after a chosen number of failed unlocking attempts to prevent brute-forcing by requiring the entry of the encryption password instead.
-rw-r--r--core/java/android/provider/Settings.java7
-rw-r--r--core/java/com/android/internal/widget/LockPatternUtils.java72
-rw-r--r--services/core/java/com/android/server/LockSettingsService.java1
3 files changed, 77 insertions, 3 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3ab16fe7a39..e6f1f4ac602 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4926,6 +4926,13 @@ public final class Settings {
"lock_screen_allow_private_notifications";
/**
+ * Separate password for encryption and the lockscreen.
+ * @hide
+ */
+ public static final String LOCK_SEPARATE_ENCRYPTION_PASSWORD =
+ "lock_separate_encryption_password";
+
+ /**
* Set by the system to track if the user needs to see the call to action for
* the lockscreen notification policy.
* @hide
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 5dc91d27452..92f520b3cc3 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -462,7 +462,8 @@ public class LockPatternUtils {
// well, we tried...
}
- if (userHandle == UserHandle.USER_OWNER) {
+ if (userHandle == UserHandle.USER_OWNER
+ && !isSeparateEncryptionPasswordEnabled()) {
// Set the encryption password to default.
updateEncryptionPassword(StorageManager.CRYPT_TYPE_DEFAULT, null);
}
@@ -523,7 +524,8 @@ public class LockPatternUtils {
// Update the device encryption password.
if (userId == UserHandle.USER_OWNER
- && LockPatternUtils.isDeviceEncryptionEnabled()) {
+ && LockPatternUtils.isDeviceEncryptionEnabled()
+ && !isSeparateEncryptionPasswordEnabled()) {
if (!shouldEncryptWithCredentials(true)) {
clearEncryptionPassword();
} else {
@@ -732,7 +734,8 @@ public class LockPatternUtils {
// Update the device encryption password.
if (userHandle == UserHandle.USER_OWNER
- && LockPatternUtils.isDeviceEncryptionEnabled()) {
+ && LockPatternUtils.isDeviceEncryptionEnabled()
+ && !isSeparateEncryptionPasswordEnabled()) {
if (!shouldEncryptWithCredentials(true)) {
clearEncryptionPassword();
} else {
@@ -1089,6 +1092,69 @@ public class LockPatternUtils {
}
}
+ private void updateEncryptionPasswordFromPassword(String password) {
+ if (!TextUtils.isEmpty(password)) {
+ int computedQuality = computePasswordQuality(password);
+ 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);
+ } else {
+ clearEncryptionPassword();
+ }
+ }
+
+ /**
+ * Set the encryption password separately from the lockscreen password.
+ *
+ * @param password The password to save
+ */
+ public void setSeparateEncryptionPassword(String password) {
+ updateEncryptionPasswordFromPassword(password);
+ setSeparateEncryptionPasswordEnabled(true);
+ }
+
+ /**
+ * Replace the separate encryption password by tying it to the lockscreen
+ * password. No change will occur if the provided lockscreen password is
+ * incorrect.
+ *
+ * @param password The current lockscreen password
+ * @return Whether the lockscreen password was correct.
+ */
+ public void replaceSeparateEncryptionPassword(String password) {
+ updateEncryptionPasswordFromPassword(password);
+ setSeparateEncryptionPasswordEnabled(false);
+ }
+
+ /**
+ * Replace the separate encryption password by tying it to the lockscreen
+ * pattern. No change will occur if the provided lockscreen password is
+ * incorrect.
+ *
+ * @param pattern The current lockscreen pattern
+ * @return Whether the lockscreen pattern was correct.
+ */
+ public void replaceSeparateEncryptionPasswordWithPattern(List<LockPatternView.Cell> pattern) {
+ String stringPattern = patternToString(pattern);
+ updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern);
+ setSeparateEncryptionPasswordEnabled(false);
+ }
+
+ /**
+ * @return Whether the encryption password is separate from the lockscreen password.
+ */
+ public boolean isSeparateEncryptionPasswordEnabled() {
+ return getBoolean(Settings.Secure.LOCK_SEPARATE_ENCRYPTION_PASSWORD, false, UserHandle.USER_OWNER);
+ }
+
+ private void setSeparateEncryptionPasswordEnabled(boolean enabled) {
+ setBoolean(Settings.Secure.LOCK_SEPARATE_ENCRYPTION_PASSWORD, enabled, UserHandle.USER_OWNER);
+ }
+
/**
* @return Whether tactile feedback for the pattern is enabled.
*/
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 10b0bdd270b..81cbc19362d 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -839,6 +839,7 @@ public class LockSettingsService extends ILockSettings.Stub {
Secure.LOCK_PATTERN_SIZE,
Secure.LOCK_DOTS_VISIBLE,
Secure.LOCK_SHOW_ERROR_PATH,
+ Secure.LOCK_SEPARATE_ENCRYPTION_PASSWORD
};
// Reading these settings needs the contacts permission