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

Commit babdfbcb authored by lijilou's avatar lijilou
Browse files

BiometricService: put the mthod of resetLockoutFor into handler when

binder called and keep thread-safe in RingBuffer.

//the crash log as below:
java.lang.ArrayIndexOutOfBoundsException: length=100; index=100 at
com.android.server.biometrics.sensors.AuthSessionCoordinator$RingBuffer.addApiCall(AuthSessionCoordinator.java:245)
at
com.android.server.biometrics.sensors.AuthSessionCoordinator.resetLockoutFor(AuthSessionCoordinator.java:183)
at
com.android.server.biometrics.sensors.face.aidl.FaceResetLockoutClient.resetLocalLockoutStateToNone(FaceResetLockoutClient.java:116)
at
com.android.server.biometrics.sensors.face.aidl.FaceResetLockoutClient.onLockoutCleared(FaceResetLockoutClient.java:91)
at
com.android.server.biometrics.sensors.face.aidl.Sensor$HalSessionCallback.lambda$onLockoutCleared$10(Sensor.java:393)
at
com.android.server.biometrics.sensors.face.aidl.Sensor$HalSessionCallback.$r8$lambda$JpLtzBLSCyFmEgRzIxR0Sio-mu0(Unknown
Source:0) at
com.android.server.biometrics.sensors.face.aidl.Sensor$HalSessionCallback$$ExternalSyntheticLambda11.run(Unknown
Source:2) at android.os.Handler.handleCallback(Handler.java:958) at
android.os.Handle......
Bug: 333986670

Change-Id: Iaf541d6323da517db592196904ab2d760cf34343
parent 1fc9f221
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -848,8 +848,10 @@ public class BiometricService extends SystemService {

            Slog.d(TAG, "resetLockout(userId=" + userId
                    + ", hat=" + (hardwareAuthToken == null ? "null " : "present") + ")");
            mHandler.post(() -> {
                mBiometricContext.getAuthSessionCoordinator()
                    .resetLockoutFor(userId, Authenticators.BIOMETRIC_STRONG, -1);
            });
        }

        @android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
+2 −2
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ public class AuthSessionCoordinator implements AuthSessionListener {
            mApiCallNumber = 0;
        }

        void addApiCall(String str) {
        synchronized void addApiCall(String str) {
            mApiCalls[mCurr] = str;
            mCurr++;
            mCurr %= mSize;
@@ -243,7 +243,7 @@ public class AuthSessionCoordinator implements AuthSessionListener {
        }

        @Override
        public String toString() {
        public synchronized String toString() {
            String buffer = "";
            int apiCall = mApiCallNumber > mSize ? mApiCallNumber - mSize : 0;
            for (int i = 0; i < mSize; i++) {