More userActivity() calls in keyguard
Some security screens aren't currently calling userActivity(). As such,
they allow keyguard to timeout before the user has a chance to enter
the required information.
The fix uses a TextWatcher to look for changes in the input text
and call userActivity() appropriately.
bug 7291431
Change-Id: I6d7889cc01a4d6bdbefefc5af478e812c35b1a49
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
index 4f2545f..a4e8ea4 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
@@ -54,7 +54,7 @@
*/
public class KeyguardPasswordView extends LinearLayout
- implements KeyguardSecurityView, OnEditorActionListener {
+ implements KeyguardSecurityView, OnEditorActionListener, TextWatcher {
private KeyguardSecurityCallback mCallback;
private EditText mPasswordEntry;
private LockPatternUtils mLockPatternUtils;
@@ -121,6 +121,7 @@
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
mPasswordEntry.setOnEditorActionListener(this);
+ mPasswordEntry.addTextChangedListener(this);
mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
new int[] {
@@ -351,5 +352,20 @@
return mCallback;
}
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ if (mCallback != null) {
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
+ }
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
index f913519..5a9ffcf 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
@@ -30,6 +30,8 @@
import com.android.internal.widget.PasswordEntryKeyboardView;
import com.android.internal.R;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -45,9 +47,7 @@
* Displays a dialer like interface to unlock the SIM PIN.
*/
public class KeyguardSimPinView extends LinearLayout
- implements KeyguardSecurityView, OnEditorActionListener {
-
- private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
+ implements KeyguardSecurityView, OnEditorActionListener, TextWatcher {
private EditText mPinEntry;
private ProgressDialog mSimUnlockProgressDialog = null;
@@ -80,6 +80,7 @@
mPinEntry = (EditText) findViewById(R.id.sim_pin_entry);
mPinEntry.setOnEditorActionListener(this);
+ mPinEntry.addTextChangedListener(this);
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
@@ -163,7 +164,7 @@
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Check if this was the result of hitting the enter key
- mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
if (event.getAction() == MotionEvent.ACTION_DOWN && (
actionId == EditorInfo.IME_NULL
|| actionId == EditorInfo.IME_ACTION_DONE
@@ -247,4 +248,19 @@
return mCallback;
}
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ if (mCallback != null) {
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
+ }
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
index 2015826..2cdb52d 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
@@ -23,6 +23,7 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.text.Editable;
+import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -40,9 +41,7 @@
import com.android.internal.R;
public class KeyguardSimPukView extends LinearLayout implements View.OnClickListener,
- KeyguardSecurityView, OnEditorActionListener {
-
- private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
+ KeyguardSecurityView, OnEditorActionListener, TextWatcher {
private View mDeleteButton;
@@ -135,6 +134,7 @@
mSimPinEntry = (TextView) findViewById(R.id.sim_pin_entry);
mSimPinEntry.setOnEditorActionListener(this);
+ mSimPinEntry.addTextChangedListener(this);
mDeleteButton = findViewById(R.id.delete_button);
mDeleteButton.setOnClickListener(this);
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
@@ -222,7 +222,7 @@
digits.delete(len-1, len);
}
}
- mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
}
private Dialog getSimUnlockProgressDialog() {
@@ -292,7 +292,7 @@
@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
// Check if this was the result of hitting the enter key
- mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT) {
@@ -318,4 +318,19 @@
return mCallback;
}
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ if (mCallback != null) {
+ mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
+ }
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index 69b85c3..fd52575 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -52,6 +52,9 @@
private static String TAG = "KeyguardViewManager";
public static boolean USE_UPPER_CASE = true;
+ // Timeout used for keypresses
+ static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
+
private final Context mContext;
private final ViewManager mViewManager;
private final KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;