diff options
| author | 2022-06-14 11:01:48 +0000 | |
|---|---|---|
| committer | 2022-06-14 11:01:48 +0000 | |
| commit | bee318e35bcaba57eeeed641ccb555733235cc12 (patch) | |
| tree | eed5390b23800cc02a287c21873a2a5b8f64c55d | |
| parent | 2685de9862657b0e0ac3593aa3f351e1b42dc01e (diff) | |
| parent | f112d19ff3d18d323e27498bb2edf2b6787048e5 (diff) | |
Merge "Dismiss BiometricPrompt if window focus is lost" into tm-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java | 11 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt | 17 |
2 files changed, 27 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index 233f3648aeb3..6da2f50aac27 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -406,6 +406,15 @@ public class AuthContainerView extends LinearLayout } @Override + public void onWindowFocusChanged(boolean hasWindowFocus) { + super.onWindowFocusChanged(hasWindowFocus); + if (!hasWindowFocus) { + Log.v(TAG, "Lost window focus, dismissing the dialog"); + animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED); + } + } + + @Override public void onAttachedToWindow() { super.onAttachedToWindow(); @@ -720,7 +729,7 @@ public class AuthContainerView extends LinearLayout final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, + WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL, windowFlags, PixelFormat.TRANSLUCENT); lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; 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 2341928b2565..52b5857a2106 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt @@ -106,6 +106,23 @@ class AuthContainerViewTest : SysuiTestCase() { } @Test + fun testDismissesOnFocusLoss() { + val container = initializeContainer() + waitForIdleSync() + + verify(callback).onDialogAnimatedIn() + + container.onWindowFocusChanged(false) + waitForIdleSync() + + verify(callback).onDismissed( + eq(AuthDialogCallback.DISMISSED_USER_CANCELED), + eq<ByteArray?>(null) /* credentialAttestation */ + ) + assertThat(container.parent).isNull() + } + + @Test fun testActionAuthenticated_sendsDismissedAuthenticated() { val container = initializeContainer() container.mBiometricCallback.onAction( |