Skip to content

Commit 9cf2c52

Browse files
author
Jim Miller
committed
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
1 parent f5e2b2c commit 9cf2c52

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*/
5555

5656
public class KeyguardPasswordView extends LinearLayout
57-
implements KeyguardSecurityView, OnEditorActionListener {
57+
implements KeyguardSecurityView, OnEditorActionListener, TextWatcher {
5858
private KeyguardSecurityCallback mCallback;
5959
private EditText mPasswordEntry;
6060
private LockPatternUtils mLockPatternUtils;
@@ -121,6 +121,7 @@ protected void onFinishInflate() {
121121
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
122122
mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
123123
mPasswordEntry.setOnEditorActionListener(this);
124+
mPasswordEntry.addTextChangedListener(this);
124125

125126
mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
126127
new int[] {
@@ -351,5 +352,20 @@ public KeyguardSecurityCallback getCallback() {
351352
return mCallback;
352353
}
353354

355+
@Override
356+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
357+
if (mCallback != null) {
358+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
359+
}
360+
}
361+
362+
@Override
363+
public void onTextChanged(CharSequence s, int start, int before, int count) {
364+
}
365+
366+
@Override
367+
public void afterTextChanged(Editable s) {
368+
}
369+
354370
}
355371

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.android.internal.widget.PasswordEntryKeyboardView;
3131
import com.android.internal.R;
3232

33+
import android.text.Editable;
34+
import android.text.TextWatcher;
3335
import android.util.AttributeSet;
3436
import android.view.KeyEvent;
3537
import android.view.MotionEvent;
@@ -45,9 +47,7 @@
4547
* Displays a dialer like interface to unlock the SIM PIN.
4648
*/
4749
public class KeyguardSimPinView extends LinearLayout
48-
implements KeyguardSecurityView, OnEditorActionListener {
49-
50-
private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
50+
implements KeyguardSecurityView, OnEditorActionListener, TextWatcher {
5151

5252
private EditText mPinEntry;
5353
private ProgressDialog mSimUnlockProgressDialog = null;
@@ -80,6 +80,7 @@ protected void onFinishInflate() {
8080

8181
mPinEntry = (EditText) findViewById(R.id.sim_pin_entry);
8282
mPinEntry.setOnEditorActionListener(this);
83+
mPinEntry.addTextChangedListener(this);
8384

8485
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
8586
mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
@@ -163,7 +164,7 @@ public void run() {
163164

164165
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
165166
// Check if this was the result of hitting the enter key
166-
mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
167+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
167168
if (event.getAction() == MotionEvent.ACTION_DOWN && (
168169
actionId == EditorInfo.IME_NULL
169170
|| actionId == EditorInfo.IME_ACTION_DONE
@@ -247,4 +248,19 @@ public KeyguardSecurityCallback getCallback() {
247248
return mCallback;
248249
}
249250

251+
@Override
252+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
253+
if (mCallback != null) {
254+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
255+
}
256+
}
257+
258+
@Override
259+
public void onTextChanged(CharSequence s, int start, int before, int count) {
260+
}
261+
262+
@Override
263+
public void afterTextChanged(Editable s) {
264+
}
265+
250266
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.os.RemoteException;
2424
import android.os.ServiceManager;
2525
import android.text.Editable;
26+
import android.text.TextWatcher;
2627
import android.util.AttributeSet;
2728
import android.view.KeyEvent;
2829
import android.view.MotionEvent;
@@ -40,9 +41,7 @@
4041
import com.android.internal.R;
4142

4243
public class KeyguardSimPukView extends LinearLayout implements View.OnClickListener,
43-
KeyguardSecurityView, OnEditorActionListener {
44-
45-
private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
44+
KeyguardSecurityView, OnEditorActionListener, TextWatcher {
4645

4746
private View mDeleteButton;
4847

@@ -135,6 +134,7 @@ protected void onFinishInflate() {
135134

136135
mSimPinEntry = (TextView) findViewById(R.id.sim_pin_entry);
137136
mSimPinEntry.setOnEditorActionListener(this);
137+
mSimPinEntry.addTextChangedListener(this);
138138
mDeleteButton = findViewById(R.id.delete_button);
139139
mDeleteButton.setOnClickListener(this);
140140
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
@@ -222,7 +222,7 @@ public void onClick(View v) {
222222
digits.delete(len-1, len);
223223
}
224224
}
225-
mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
225+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
226226
}
227227

228228
private Dialog getSimUnlockProgressDialog() {
@@ -292,7 +292,7 @@ public void run() {
292292
@Override
293293
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
294294
// Check if this was the result of hitting the enter key
295-
mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
295+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
296296
if (event.getAction() == MotionEvent.ACTION_DOWN) {
297297
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE
298298
|| actionId == EditorInfo.IME_ACTION_NEXT) {
@@ -318,4 +318,19 @@ public KeyguardSecurityCallback getCallback() {
318318
return mCallback;
319319
}
320320

321+
@Override
322+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
323+
if (mCallback != null) {
324+
mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS);
325+
}
326+
}
327+
328+
@Override
329+
public void onTextChanged(CharSequence s, int start, int before, int count) {
330+
}
331+
332+
@Override
333+
public void afterTextChanged(Editable s) {
334+
}
335+
321336
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class KeyguardViewManager {
5252
private static String TAG = "KeyguardViewManager";
5353
public static boolean USE_UPPER_CASE = true;
5454

55+
// Timeout used for keypresses
56+
static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
57+
5558
private final Context mContext;
5659
private final ViewManager mViewManager;
5760
private final KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;

0 commit comments

Comments
 (0)