Check for race condition between onAuthenticated and taskStackChanged

Bug: 111461540

Test: no more logs like the ones below

Change-Id: I784ecc71df1028bac8e0203156f79157f0509636
FingerprintService: onAuthenticated(owner=com.android.settings, id=-1049244503
FingerprintService: Stopping background authentication, top: com.example.android.biometric currentClient: com.android.settings
FingerprintService: client com.android.settings is no longer authenticating
FingerprintService: Done with client: com.android.settings
FingerprintService: handleError(client=null, error = 5)
This commit is contained in:
Kevin Chyn
2018-10-05 18:57:35 -07:00
parent 75dbb83fc2
commit c79856b460
3 changed files with 9 additions and 1 deletions

View File

@@ -232,6 +232,7 @@ public abstract class AuthenticationClient extends ClientMonitor {
public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier,
boolean authenticated, ArrayList<Byte> token) {
if (authenticated) {
mAlreadyDone = true;
if (mRequireConfirmation) {
// Store the token so it can be sent to keystore after the user presses confirm
mEscrow = new TokenEscrow(identifier, token);

View File

@@ -408,7 +408,8 @@ public abstract class BiometricServiceBase extends SystemService
mActivityTaskManager.getTasks(1);
if (!runningTasks.isEmpty()) {
final String topPackage = runningTasks.get(0).topActivity.getPackageName();
if (!topPackage.contentEquals(currentClient)) {
if (!topPackage.contentEquals(currentClient)
&& !mCurrentClient.isAlreadyDone()) {
Slog.e(getTag(), "Stopping background authentication, top: " + topPackage
+ " currentClient: " + currentClient);
mCurrentClient.stop(false /* initiatedByClient */);

View File

@@ -63,6 +63,7 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient {
protected final Metrics mMetrics;
protected boolean mAlreadyCancelled;
protected boolean mAlreadyDone;
/**
* @param context context of BiometricService
@@ -136,6 +137,11 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient {
public abstract boolean onEnumerationResult(
BiometricAuthenticator.Identifier identifier, int remaining);
public boolean isAlreadyDone() {
return mAlreadyDone;
}
/**
* Called when we get notification from the biometric's HAL that an image has been acquired.
* Common to authenticate and enroll.