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

Commit 9dac848d authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Wait for current task to complete before revoking challenge

Test: enrolled from Settings and quickly pressed the power button twice
Test: before hitting "done". The phone did not deadlock.
Bug: 136444006
Change-Id: I7e87c0722b84cde0cb96103f6b94535ca3a96798
parent 947aeb09
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.server.SystemServerInitThreadPool;
import com.android.server.biometrics.AuthenticationClient;
import com.android.server.biometrics.BiometricServiceBase;
import com.android.server.biometrics.BiometricUtils;
import com.android.server.biometrics.ClientMonitor;
import com.android.server.biometrics.Constants;
import com.android.server.biometrics.EnumerateClient;
import com.android.server.biometrics.RemovalClient;
@@ -342,7 +343,16 @@ public class FaceService extends BiometricServiceBase {
        @Override // Binder call
        public int revokeChallenge(IBinder token) {
            checkPermission(MANAGE_BIOMETRIC);
            // TODO(b/137106905): Schedule binder calls in FaceService to avoid deadlocks.
            if (getCurrentClient() == null) {
                // if we aren't handling any other HIDL calls (mCurrentClient == null), revoke the
                // challenge right away.
                return startRevokeChallenge(token);
            } else {
                // postpone revoking the challenge until we finish processing the current HIDL call.
                mRevokeChallengePending = true;
                return Status.OK;
            }
        }

        @Override // Binder call
@@ -812,6 +822,7 @@ public class FaceService extends BiometricServiceBase {
    @GuardedBy("this")
    private IBiometricsFace mDaemon;
    private UsageStats mUsageStats;
    private boolean mRevokeChallengePending = false;
    // One of the AuthenticationClient constants
    private int mCurrentUserLockoutMode;

@@ -1040,6 +1051,15 @@ public class FaceService extends BiometricServiceBase {
                .getIntArray(R.array.config_face_acquire_vendor_enroll_ignorelist);
    }

    @Override
    protected void removeClient(ClientMonitor client) {
        super.removeClient(client);
        if (mRevokeChallengePending) {
            startRevokeChallenge(null);
            mRevokeChallengePending = false;
        }
    }

    @Override
    public void onStart() {
        super.onStart();
@@ -1251,7 +1271,11 @@ public class FaceService extends BiometricServiceBase {
            return 0;
        }
        try {
            return daemon.revokeChallenge();
            final int res = daemon.revokeChallenge();
            if (res != Status.OK) {
                Slog.e(TAG, "revokeChallenge returned " + res);
            }
            return res;
        } catch (RemoteException e) {
            Slog.e(TAG, "startRevokeChallenge failed", e);
        }