Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c79856b4 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

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)
parent 75dbb83f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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 */);
+6 −0
Original line number Diff line number Diff line
@@ -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.