From 29e796d26a840b5ba364f0895d33154ccbbcb721 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 10 May 2018 15:31:20 -0700 Subject: Do not hide keyguard message when fp Test: atest packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java Change-Id: I5d76b688b0eb7c1df6a36c1cb910f2b0ec98bc46 Fixes: 78235570 --- .../android/keyguard/KeyguardAbsKeyInputView.java | 7 +++++- .../keyguard/KeyguardPinBasedInputView.java | 3 +-- .../keyguard/KeyguardPinBasedInputViewTest.java | 27 ++++++++++++++++++---- 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); } } -- cgit v1.2.3-59-g8ed1b