summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
diff options
context:
space:
mode:
authorRich Cannings <richc@google.com>2019-02-21 12:40:36 -0800
committerRich Cannings <richc@google.com>2019-02-21 14:39:05 -0800
commitf64ec63a027447d8e38dd3e0d05d127cf06dccfc (patch)
treeb308f07e28dea17a30eb1e7a8cf59584f60a42a7 /packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
parent3b5741c5604f538aab7434eb746327dc0124ba74 (diff)
Refactor passwords/pins/patterns to byte[]
Relating to frameworks/base Bug: 120484642 Test: manual - test setting and unlocking passwords/pins/patterns. automated - about 20 failing due to an issue in the test code. Change-Id: I57aa530ca2db1a026c56b66f5b4c91172f2667f6
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
index 3cc18ddf3b2a..ecafc3408224 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -165,8 +165,8 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
}
@Override
- protected String getPasswordText() {
- return mPasswordEntry.getText();
+ protected byte[] getPasswordText() {
+ return charSequenceToByteArray(mPasswordEntry.getText());
}
@Override
@@ -264,4 +264,18 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_pin_unlock);
}
+
+ /*
+ * This method avoids creating a new string when getting a byte array from EditView#getText().
+ */
+ private static byte[] charSequenceToByteArray(CharSequence chars) {
+ if (chars == null) {
+ return null;
+ }
+ byte[] bytes = new byte[chars.length()];
+ for (int i = 0; i < chars.length(); i++) {
+ bytes[i] = (byte) chars.charAt(i);
+ }
+ return bytes;
+ }
}