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

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

Do task stack work on handler to ensure in-order execution

The rest of the ClientMonitor work is done on a handler to guarantee
in-order execution. e.g. setting to null when auth completes, updating
mCurrentClient when new client is requested, etc. Put this work on the
same handler.

Fixes: 137237140

Test: BiometricPromptDemo, go home while authenticating multiple times;
      no crash observed

Change-Id: I43126ce13fb88d751571d0d52fe594c0293f794c
parent c3ee236a
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -497,9 +497,9 @@ public abstract class BiometricServiceBase extends SystemService
        }
    }

    private final class BiometricTaskStackListener extends TaskStackListener {
    private final Runnable mOnTaskStackChangedRunnable = new Runnable() {
        @Override
        public void onTaskStackChanged() {
        public void run() {
            try {
                if (!(mCurrentClient instanceof AuthenticationClient)) {
                    return;
@@ -514,8 +514,8 @@ public abstract class BiometricServiceBase extends SystemService
                    final String topPackage = runningTasks.get(0).topActivity.getPackageName();
                    if (!topPackage.contentEquals(currentClient)
                            && !mCurrentClient.isAlreadyDone()) {
                        Slog.e(getTag(), "Stopping background authentication, top: " + topPackage
                                + " currentClient: " + currentClient);
                        Slog.e(getTag(), "Stopping background authentication, top: "
                                + topPackage + " currentClient: " + currentClient);
                        mCurrentClient.stop(false /* initiatedByClient */);
                    }
                }
@@ -523,6 +523,13 @@ public abstract class BiometricServiceBase extends SystemService
                Slog.e(getTag(), "Unable to get running tasks", e);
            }
        }
    };

    private final class BiometricTaskStackListener extends TaskStackListener {
        @Override
        public void onTaskStackChanged() {
            mHandler.post(mOnTaskStackChangedRunnable);
        }
    }

    private final class ResetClientStateRunnable implements Runnable {