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

Commit 7b0f41eb authored by Aaron Liu's avatar Aaron Liu Committed by Automerger Merge Worker
Browse files

Merge "Ensure keyboard is hidden when bouncer is..." into tm-qpr-dev am: 5340f52f

parents a87b9c3b 5340f52f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.text.method.TextKeyListener;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.WindowInsets;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -156,6 +157,15 @@ public class KeyguardPasswordViewController
        // TODO: Remove this workaround by ensuring such a race condition never happens.
        mMainExecutor.executeDelayed(
                this::updateSwitchImeButton, DELAY_MILLIS_TO_REEVALUATE_IME_SWITCH_ICON);
        mView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                if (!mKeyguardViewController.isBouncerShowing()) {
                    mView.hideKeyboard();
                }
                return insets;
            }
        });
    }

    @Override
+19 −1
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package com.android.keyguard

import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.ImageView
import androidx.test.filters.SmallTest
import com.android.internal.util.LatencyTracker
import com.android.internal.widget.LockPatternUtils
@@ -30,6 +32,7 @@ import com.android.systemui.util.concurrency.DelayableExecutor
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock
@@ -37,6 +40,7 @@ import org.mockito.Mockito
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import org.mockito.MockitoAnnotations

@SmallTest
@@ -76,6 +80,8 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
    Mockito.`when`(keyguardPasswordView.findViewById<EditText>(R.id.passwordEntry))
        .thenReturn(passwordEntry)
    `when`(keyguardPasswordView.resources).thenReturn(context.resources)
    `when`(keyguardPasswordView.findViewById<ImageView>(R.id.switch_ime_button))
        .thenReturn(mock(ImageView::class.java))
     keyguardPasswordViewController =
        KeyguardPasswordViewController(
            keyguardPasswordView,
@@ -112,6 +118,18 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
    verify(keyguardPasswordView, never()).requestFocus()
  }

  @Test
  fun onApplyWindowInsetsListener_onApplyWindowInsets() {
      `when`(keyguardViewController.isBouncerShowing).thenReturn(false)
      val argumentCaptor = ArgumentCaptor.forClass(View.OnApplyWindowInsetsListener::class.java)

      keyguardPasswordViewController.onViewAttached()
      verify(keyguardPasswordView).setOnApplyWindowInsetsListener(argumentCaptor.capture())
      argumentCaptor.value.onApplyWindowInsets(keyguardPasswordView, null)

      verify(keyguardPasswordView).hideKeyboard()
  }

  @Test
  fun testHideKeyboardWhenOnPause() {
    keyguardPasswordViewController.onPause()