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

Commit 6adb3a1d authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Reset lockout using BiometricManager

Bug: 120572933

Test: lockout count is reset when pin/pattern/pass is confirmed

Change-Id: I64389dea38636cc6d4e3f4946a8098d625b489df
parent 3b7054b5
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -152,5 +152,24 @@ public class BiometricManager {
            Slog.w(TAG, "setActiveUser(): Service not connected");
        }
    }

    /**
     * Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
     *
     * @param token an opaque token returned by password confirmation.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void resetTimeout(byte[] token) {
        if (mService != null) {
            try {
                mService.resetTimeout(token);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "resetTimeout(): Service not connected");
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -48,4 +48,7 @@ interface IBiometricService {
    // Notify BiometricService when <Biometric>Service is ready to start the prepared client.
    // Client lifecycle is still managed in <Biometric>Service.
    void onReadyForAuthentication(int cookie, boolean requireConfirmation, int userId);

    // Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
    void resetTimeout(in byte [] token);
}
+18 −0
Original line number Diff line number Diff line
@@ -813,6 +813,24 @@ public class BiometricService extends SystemService {
            }
        }

        @Override // Binder call
        public void resetTimeout(byte[] token) {
            checkInternalPermission();
            final long ident = Binder.clearCallingIdentity();
            try {
                if (mFingerprintService != null) {
                    mFingerprintService.resetTimeout(token);
                }
                if (mFaceService != null) {
                    mFaceService.resetTimeout(token);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception", e);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

        void cancelInternal(IBinder token, String opPackageName, boolean fromClient) {
            final int callingUid = Binder.getCallingUid();
            final int callingPid = Binder.getCallingPid();
+7 −9
Original line number Diff line number Diff line
@@ -24,8 +24,7 @@ import android.app.AlarmManager.OnAlarmListener;
import android.app.admin.DevicePolicyManager;
import android.app.trust.IStrongAuthTracker;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.biometrics.BiometricManager;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteCallbackList;
@@ -62,7 +61,7 @@ public class LockSettingsStrongAuth {
    private final Context mContext;

    private AlarmManager mAlarmManager;
    private FingerprintManager mFingerprintManager;
    private BiometricManager mBiometricManager;

    public LockSettingsStrongAuth(Context context) {
        mContext = context;
@@ -71,9 +70,8 @@ public class LockSettingsStrongAuth {
    }

    public void systemReady() {
        final PackageManager pm = mContext.getPackageManager();
        if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
            mFingerprintManager = mContext.getSystemService(FingerprintManager.class);
        if (BiometricManager.hasBiometrics(mContext)) {
            mBiometricManager = mContext.getSystemService(BiometricManager.class);
        }
    }

@@ -187,9 +185,9 @@ public class LockSettingsStrongAuth {
    }

    public void reportSuccessfulStrongAuthUnlock(int userId) {
        if (mFingerprintManager != null) {
            byte[] token = null; /* TODO: pass real auth token once fp HAL supports it */
            mFingerprintManager.resetTimeout(token);
        if (mBiometricManager != null) {
            byte[] token = null; /* TODO: pass real auth token once HAL supports it */
            mBiometricManager.resetTimeout(token);
        }

        final int argNotUsed = 0;