Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cf2c523 authored by Jim Miller's avatar Jim Miller
Browse files

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
parent f5e2b2c2
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ import com.android.internal.widget.PasswordEntryKeyboardHelper;
 */

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 @@ public class KeyguardPasswordView extends LinearLayout
        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 @@ public class KeyguardPasswordView extends LinearLayout
        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) {
    }

}
+20 −4
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.internal.widget.PasswordEntryKeyboardHelper;
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 @@ import android.widget.TextView.OnEditorActionListener;
 * 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 @@ public class KeyguardSimPinView extends LinearLayout

        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 class KeyguardSimPinView extends LinearLayout

    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 @@ public class KeyguardSimPinView extends LinearLayout
        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) {
    }

}
+20 −5
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Rect;
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.widget.PasswordEntryKeyboardView;
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 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList

        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 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
                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 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
    @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 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
        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) {
    }

}
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ public class KeyguardViewManager {
    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;