diff options
author | Xiyuan Xia <xiyuan@google.com> | 2015-05-13 15:29:42 -0700 |
---|---|---|
committer | Xiyuan Xia <xiyuan@google.com> | 2015-05-13 16:03:33 -0700 |
commit | 09eb0337b760c74d73a614edfdc7eaa6e083a29f (patch) | |
tree | 9fe711fca69bae4401481a0541871e4f040f0c64 /packages/Keyguard | |
parent | 05fe90c10b54111a742187935f2890029b348bf5 (diff) | |
download | frameworks_base-09eb0337b760c74d73a614edfdc7eaa6e083a29f.zip frameworks_base-09eb0337b760c74d73a614edfdc7eaa6e083a29f.tar.gz frameworks_base-09eb0337b760c74d73a614edfdc7eaa6e083a29f.tar.bz2 |
Clear security message on user input
Bug:20536310
Change-Id: I57c2fda9def7db4908303ce3ac1977563fc4bfdd
Diffstat (limited to 'packages/Keyguard')
6 files changed, 49 insertions, 16 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java index db56161..54bbd5a 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java @@ -174,9 +174,16 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout }.start(); } + protected void onUserInput() { + if (mCallback != null) { + mCallback.userActivity(); + } + mSecurityMessageDisplay.setMessage("", false); + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - mCallback.userActivity(); + onUserInput(); return false; } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java index 7ddeab4..40fd920 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java @@ -88,24 +88,33 @@ class KeyguardMessageArea extends TextView { } } + @Override public void setMessage(CharSequence msg, boolean important) { if (!TextUtils.isEmpty(msg) && important) { mMessageArea.mMessage = msg; mMessageArea.securityMessageChanged(); + } else { + mMessageArea.clearMessage(); } } + @Override public void setMessage(int resId, boolean important) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getResources().getText(resId); mMessageArea.securityMessageChanged(); + } else { + mMessageArea.clearMessage(); } } + @Override public void setMessage(int resId, boolean important, Object... formatArgs) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getString(resId, formatArgs); mMessageArea.securityMessageChanged(); + } else { + mMessageArea.clearMessage(); } } @@ -176,6 +185,11 @@ class KeyguardMessageArea extends TextView { (SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY)); } + public void clearMessage() { + mHandler.removeCallbacks(mClearMessageRunnable); + mHandler.post(mClearMessageRunnable); + } + /** * Update the status lines based on these rules: * AlarmStatus: Alarm state always gets it's own line. diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java index 929258d..3fcc3c3 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java @@ -20,6 +20,7 @@ import android.content.Context; import android.graphics.Rect; import android.text.Editable; import android.text.InputType; +import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.TextKeyListener; import android.util.AttributeSet; @@ -138,20 +139,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView // Set selected property on so the view can send accessibility events. mPasswordEntry.setSelected(true); - mPasswordEntry.addTextChangedListener(new TextWatcher() { - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - public void afterTextChanged(Editable s) { - if (mCallback != null) { - mCallback.userActivity(); - } - } - }); - mPasswordEntry.requestFocus(); // If there's more than one IME, enable the IME switcher button @@ -293,6 +280,11 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView @Override public void afterTextChanged(Editable s) { + // Poor man's user edit detection, assuming empty text is programmatic and everything else + // is from the user. + if (!TextUtils.isEmpty(s)) { + onUserInput(); + } } @Override diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java index f67b2e7..35c6873 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java @@ -208,6 +208,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit public void onPatternStart() { mLockPatternView.removeCallbacks(mCancelPatternRunnable); + mSecurityMessageDisplay.setMessage("", false); } public void onPatternCleared() { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java index bca0305..84b4cf8 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java @@ -148,7 +148,14 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView // Poke the wakelock any time the text is selected or modified mPasswordEntry.setOnClickListener(new OnClickListener() { public void onClick(View v) { - mCallback.userActivity(); + onUserInput(); + } + }); + + mPasswordEntry.setUserActivityListener(new PasswordTextView.UserActivityListener() { + @Override + public void onUserActivity() { + onUserInput(); } }); diff --git a/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java b/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java index 67ddcfa..50e7ecb 100644 --- a/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java +++ b/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java @@ -92,6 +92,11 @@ public class PasswordTextView extends View { private Interpolator mDisappearInterpolator; private Interpolator mFastOutSlowInInterpolator; private boolean mShowPassword; + private UserActivityListener mUserActivityListener; + + public interface UserActivityListener { + void onUserActivity(); + } public PasswordTextView(Context context) { this(context, null); @@ -206,8 +211,15 @@ public class PasswordTextView extends View { sendAccessibilityEventTypeViewTextChanged(textbefore, textbefore.length(), 0, 1); } + public void setUserActivityListener(UserActivityListener userActivitiListener) { + mUserActivityListener = userActivitiListener; + } + private void userActivity() { mPM.userActivity(SystemClock.uptimeMillis(), false); + if (mUserActivityListener != null) { + mUserActivityListener.onUserActivity(); + } } public void deleteLastChar() { |