Dismiss BiometricPrompt if window focus is lost
Bug: 233820283 Bug: 216743197 Test: atest AuthContainerViewTest Change-Id: I73a87a364a752154e0f96c018b5e5ee8eb505c03
This commit is contained in:
@@ -435,6 +435,15 @@ public class AuthContainerView extends LinearLayout
|
|||||||
maybeUpdatePositionForUdfps(true /* invalidate */);
|
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
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
@@ -795,7 +804,7 @@ public class AuthContainerView extends LinearLayout
|
|||||||
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL,
|
WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL,
|
||||||
windowFlags,
|
windowFlags,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
|
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
|
||||||
|
|||||||
@@ -105,6 +105,23 @@ class AuthContainerViewTest : SysuiTestCase() {
|
|||||||
verify(callback).onDialogAnimatedIn()
|
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
|
@Test
|
||||||
fun testActionAuthenticated_sendsDismissedAuthenticated() {
|
fun testActionAuthenticated_sendsDismissedAuthenticated() {
|
||||||
val container = initializeFingerprintContainer()
|
val container = initializeFingerprintContainer()
|
||||||
|
|||||||
Reference in New Issue
Block a user