diff options
| author | 2018-05-11 17:31:24 +0000 | |
|---|---|---|
| committer | 2018-05-11 17:31:24 +0000 | |
| commit | 2d2d79b92cdeb0f668c5288652db2f4c23166acf (patch) | |
| tree | c6f94488b481ab704608886275d062d8141f8dbb | |
| parent | 02b9592ff1b039cbbc5f592cd1a7c9896a685216 (diff) | |
| parent | 29e796d26a840b5ba364f0895d33154ccbbcb721 (diff) | |
Merge "Do not hide keyguard message when fp" into pi-dev
3 files changed, 30 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java index 00cd5a7b1689..48b413456755 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java @@ -246,7 +246,12 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - onUserInput(); + // Fingerprint sensor sends a KeyEvent.KEYCODE_UNKNOWN. + // We don't want to consider it valid user input because the UI + // will already respond to the event. + if (keyCode != KeyEvent.KEYCODE_UNKNOWN) { + onUserInput(); + } return false; } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java index a2befefba79e..cb8c119d08eb 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java @@ -31,8 +31,7 @@ import com.android.internal.annotations.VisibleForTesting; public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView implements View.OnKeyListener, View.OnTouchListener { - @VisibleForTesting - PasswordTextView mPasswordEntry; + protected PasswordTextView mPasswordEntry; private View mOkButton; private View mDeleteButton; private View mButton0; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java index e79c9d0c5455..359832f7a542 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java @@ -16,11 +16,15 @@ package com.android.keyguard; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; +import android.view.KeyEvent; import android.view.LayoutInflater; import com.android.systemui.SysuiTestCase; @@ -28,6 +32,7 @@ import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -37,21 +42,35 @@ import org.mockito.MockitoAnnotations; public class KeyguardPinBasedInputViewTest extends SysuiTestCase { @Mock - private PasswordTextView mPasswordTextView; + private PasswordTextView mPasswordEntry; + @Mock + private SecurityMessageDisplay mSecurityMessageDisplay; + @InjectMocks private KeyguardPinBasedInputView mKeyguardPinView; @Before public void setup() { - MockitoAnnotations.initMocks(this); LayoutInflater inflater = LayoutInflater.from(getContext()); mKeyguardPinView = (KeyguardPinBasedInputView) inflater.inflate(R.layout.keyguard_pin_view, null); - mKeyguardPinView.mPasswordEntry = mPasswordTextView; + MockitoAnnotations.initMocks(this); } @Test public void onResume_requestsFocus() { mKeyguardPinView.onResume(KeyguardSecurityView.SCREEN_ON); - verify(mPasswordTextView).requestFocus(); + verify(mPasswordEntry).requestFocus(); + } + + @Test + public void onKeyDown_clearsSecurityMessage() { + mKeyguardPinView.onKeyDown(KeyEvent.KEYCODE_0, mock(KeyEvent.class)); + verify(mSecurityMessageDisplay).setMessage(eq("")); + } + + @Test + public void onKeyDown_noSecurityMessageInteraction() { + mKeyguardPinView.onKeyDown(KeyEvent.KEYCODE_UNKNOWN, mock(KeyEvent.class)); + verifyZeroInteractions(mSecurityMessageDisplay); } } |