diff options
author | 2022-09-29 01:22:14 +0800 | |
---|---|---|
committer | 2022-10-14 21:23:37 +0800 | |
commit | ef36c5f99700dc1dc6c24e8498fa37afafa081db (patch) | |
tree | c4aa181cd4a48688a12c496e96cc5b90d1435ef3 | |
parent | 94bd703e56c4cd80d4adb3553c448005e813db28 (diff) |
Request hiding IME before starting dismiss biometric UI animation
As recents animation will invoke hideSoftInputFromWindow when the
Biometric UI lost focus during quick-switch.
Since IME hiding animation will be scheduled on the focus app's UI
thread, so if Biometric UI has running the animation on UI thread, the
IME hiding animation will be delayed until the animation finish.
Make sure calling WindowInsetsController#hide(ime()) before starting
dismiss biometric UI to fix this issue.
Fix: 247705580
Test: manual by issue steps:
1. Unlock the device
2. Go to Settings -> Network and internet -> Hotspot and tethering
-> WIFI hotspot
3. Enable use Wi-Fi hotspot
4. Tap on Biometric to show keyboard
5. From password screen go to home screen
6. Expect keyboard will be hidden without being delayed
Test: atest AuthContainerViewTest#\
testDismissesOnFocusLoss_hidesKeyboardWhenVisible
Merged-In: I541f41832753ea1f4f48f6c4745649606b37d207
Change-Id: I541f41832753ea1f4f48f6c4745649606b37d207
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java | 6 | ||||
-rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt | 31 |
2 files changed, 37 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index 8f5cbb76222f..00236f150488 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -775,6 +775,12 @@ public class AuthContainerView extends LinearLayout } mContainerState = STATE_ANIMATING_OUT; + // Request hiding soft-keyboard before animating away credential UI, in case IME insets + // animation get delayed by dismissing animation. + if (isAttachedToWindow() && getRootWindowInsets().isVisible(WindowInsets.Type.ime())) { + getWindowInsetsController().hide(WindowInsets.Type.ime()); + } + if (sendReason) { mPendingCallbackReason = reason; } else { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt index 4a5b23c02e40..ca9224f631e9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt @@ -35,6 +35,8 @@ import android.view.WindowInsets import android.view.WindowManager import android.widget.ScrollView import androidx.test.filters.SmallTest +import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn +import com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn import com.android.internal.jank.InteractionJankMonitor import com.android.internal.widget.LockPatternUtils import com.android.systemui.R @@ -143,6 +145,35 @@ class AuthContainerViewTest : SysuiTestCase() { } @Test + fun testDismissesOnFocusLoss_hidesKeyboardWhenVisible() { + val container = initializeFingerprintContainer( + authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL + ) + waitForIdleSync() + + val requestID = authContainer?.requestId ?: 0L + + // Simulate keyboard was shown on the credential view + val windowInsetsController = container.windowInsetsController + spyOn(windowInsetsController) + spyOn(container.rootWindowInsets) + doReturn(true).`when`(container.rootWindowInsets).isVisible(WindowInsets.Type.ime()) + + container.onWindowFocusChanged(false) + waitForIdleSync() + + // Expect hiding IME request will be invoked when dismissing the view + verify(windowInsetsController)?.hide(WindowInsets.Type.ime()) + + verify(callback).onDismissed( + eq(AuthDialogCallback.DISMISSED_USER_CANCELED), + eq<ByteArray?>(null), /* credentialAttestation */ + eq(requestID) + ) + assertThat(container.parent).isNull() + } + + @Test fun testActionAuthenticated_sendsDismissedAuthenticated() { val container = initializeFingerprintContainer() container.mBiometricCallback.onAction( |