diff options
author | Michael Bestas <mikeioannina@gmail.com> | 2015-04-03 14:33:37 -0700 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2015-12-11 11:42:41 -0600 |
commit | 0cf7d4373afc1bbc0b9a42954d6dbd162aa361a4 (patch) | |
tree | 307f858411925cd08f8edf6fd848d3986d4aab43 /services | |
parent | a037ad401e4a78ce22a9ec2dada8ff3593aa8fa4 (diff) | |
download | frameworks_base-0cf7d4373afc1bbc0b9a42954d6dbd162aa361a4.zip frameworks_base-0cf7d4373afc1bbc0b9a42954d6dbd162aa361a4.tar.gz frameworks_base-0cf7d4373afc1bbc0b9a42954d6dbd162aa361a4.tar.bz2 |
Forward port CM Screen Security settings (1/2)
* Variable size pattern lockscreen
* Toggle dots/error pattern visibility
Change-Id: Ie109e82c1fb2fd96b07e977e1cd76ae3acb865ff
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/LockSettingsService.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/LockSettingsStorage.java | 23 |
2 files changed, 32 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java index 1dbb054..bb0615d 100644 --- a/services/core/java/com/android/server/LockSettingsService.java +++ b/services/core/java/com/android/server/LockSettingsService.java @@ -446,6 +446,10 @@ public class LockSettingsService extends ILockSettings.Stub { } + public byte getLockPatternSize(int userId) { + return mStorage.getLockPatternSize(userId); + } + @Override public void setLockPattern(String pattern, String savedCredential, int userId) throws RemoteException { @@ -563,8 +567,10 @@ public class LockSettingsService extends ILockSettings.Stub { @Override public byte[] toHash(String pattern, int userId) { + final byte lockPatternSize = getLockPatternSize(userId); return LockPatternUtils.patternToHash( - LockPatternUtils.stringToPattern(pattern)); + LockPatternUtils.stringToPattern(pattern, lockPatternSize), + lockPatternSize); } @Override @@ -803,7 +809,10 @@ public class LockSettingsService extends ILockSettings.Stub { Secure.LOCK_PATTERN_ENABLED, Secure.LOCK_BIOMETRIC_WEAK_FLAGS, Secure.LOCK_PATTERN_VISIBLE, - Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED + Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, + Secure.LOCK_PATTERN_SIZE, + Secure.LOCK_DOTS_VISIBLE, + Secure.LOCK_SHOW_ERROR_PATH, }; // Reading these settings needs the contacts permission diff --git a/services/core/java/com/android/server/LockSettingsStorage.java b/services/core/java/com/android/server/LockSettingsStorage.java index de48e71..72e05c1 100644 --- a/services/core/java/com/android/server/LockSettingsStorage.java +++ b/services/core/java/com/android/server/LockSettingsStorage.java @@ -16,6 +16,8 @@ package com.android.server; +import android.os.RemoteException; +import android.provider.Settings; import com.android.internal.annotations.VisibleForTesting; import android.content.ContentValues; @@ -29,6 +31,7 @@ import android.os.UserManager; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; +import com.android.internal.widget.LockPatternUtils; import java.io.File; import java.io.IOException; @@ -328,7 +331,10 @@ class LockSettingsStorage { mStoredCredentialType = hash == null ? CredentialHash.TYPE_NONE : CredentialHash.TYPE_PATTERN; - writeFile(getLockPatternFilename(userId), hash); + + boolean defaultSize = isDefaultSize(userId); + writeFile(getLockPatternFilename(userId, defaultSize), hash); + clearPasswordHash(userId); } @@ -348,9 +354,22 @@ class LockSettingsStorage { writeFile(getLockPasswordFilename(userId), null); } + public byte getLockPatternSize(int userId) { + long size = Long.valueOf(readKeyValue(Settings.Secure.LOCK_PATTERN_SIZE, "-1", userId)); + if (size > 0 && size < 128) { + return (byte) size; + } + return LockPatternUtils.PATTERN_SIZE_DEFAULT; + } + + public boolean isDefaultSize(int userId) { + return getLockPatternSize(userId) == LockPatternUtils.PATTERN_SIZE_DEFAULT; + } + @VisibleForTesting String getLockPatternFilename(int userId) { - return getLockCredentialFilePathForUser(userId, LOCK_PATTERN_FILE); + String baseFileName = LOCK_PATTERN_FILE; + return getLockCredentialFilePathForUser(userId, baseFileName); } @VisibleForTesting |