Merge "Dismiss BiometricPrompt if window focus is lost" into tm-d1-dev am: a259049f29 am: 0d9b0434e3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18878593

Change-Id: I934c8e0d979df054e97732f4f3f5066c676fdf32
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ilya Matyukhin
2022-06-14 07:07:30 +00:00
committed by Automerger Merge Worker
2 changed files with 27 additions and 1 deletions

View File

@@ -435,6 +435,15 @@ public class AuthContainerView extends LinearLayout
maybeUpdatePositionForUdfps(true /* invalidate */);
}
@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();
@@ -795,7 +804,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;

View File

@@ -105,6 +105,23 @@ class AuthContainerViewTest : SysuiTestCase() {
verify(callback).onDialogAnimatedIn()
}
@Test
fun testDismissesOnFocusLoss() {
val container = initializeFingerprintContainer()
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 = initializeFingerprintContainer()