From 30607ce49dbb59383cb7ddac3fa78e77bad46d8f Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Fri, 11 Jan 2019 18:00:45 -0800 Subject: [PATCH] Keep task stack listener around as long as dialog is showing Fixes: 122473133 Test: Fail authentication 5 times, then press home button immediately Dialog is dismissed immediately Change-Id: I41d3726d107319586943e72f79dc6a95148b7a00 --- .../server/biometrics/BiometricService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/biometrics/BiometricService.java b/services/core/java/com/android/server/biometrics/BiometricService.java index 24f2ef9ef9796..41fedc5fab45b 100644 --- a/services/core/java/com/android/server/biometrics/BiometricService.java +++ b/services/core/java/com/android/server/biometrics/BiometricService.java @@ -351,10 +351,7 @@ public class BiometricService extends SystemService { if (!runningTasks.isEmpty()) { final String topPackage = runningTasks.get(0).topActivity.getPackageName(); if (mCurrentAuthSession != null - && !topPackage.contentEquals(mCurrentAuthSession.mOpPackageName) - && mCurrentAuthSession.mState != STATE_AUTH_STARTED) { - // We only care about this state, since Service will - // cancel any client that's still in STATE_AUTH_STARTED + && !topPackage.contentEquals(mCurrentAuthSession.mOpPackageName)) { mStatusBarService.hideBiometricDialog(); mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener); mCurrentAuthSession.mClientReceiver.onError( @@ -464,8 +461,9 @@ public class BiometricService extends SystemService { if (mCurrentAuthSession != null && mCurrentAuthSession.containsCookie(cookie)) { if (mCurrentAuthSession.mState == STATE_AUTH_STARTED) { mStatusBarService.onBiometricError(message); - mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener); if (error == BiometricConstants.BIOMETRIC_ERROR_CANCELED) { + mActivityTaskManager.unregisterTaskStackListener( + mTaskStackListener); mCurrentAuthSession.mClientReceiver.onError(error, message); mCurrentAuthSession.mState = STATE_AUTH_IDLE; mCurrentAuthSession = null; @@ -475,6 +473,8 @@ public class BiometricService extends SystemService { mHandler.postDelayed(() -> { try { if (mCurrentAuthSession != null) { + mActivityTaskManager.unregisterTaskStackListener( + mTaskStackListener); mCurrentAuthSession.mClientReceiver.onError(error, message); mCurrentAuthSession.mState = STATE_AUTH_IDLE; @@ -543,6 +543,11 @@ public class BiometricService extends SystemService { @Override public void onDialogDismissed(int reason) throws RemoteException { + if (mCurrentAuthSession == null) { + Slog.e(TAG, "onDialogDismissed: " + reason + ", auth session null"); + return; + } + if (reason != BiometricPrompt.DISMISSED_REASON_POSITIVE) { // Positive button is used by passive modalities as a "confirm" button, // do not send to client