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

Commit b2a04279 authored by Alessandro Astone's avatar Alessandro Astone Committed by Luca Stefani
Browse files

Start BiometricService even if no hardware is present

* BiometricService already has support for authenticate() to fallback to CDC.
  This allows BiometricPrompt to ask for credentials when no biometric
  hardware is present, rather then doing nothing.

Change-Id: Ib69b913a9e9a6d4d76de5d2ee9e618a3dfd6e5bd
parent 2904eee3
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -933,17 +933,11 @@ final class SystemServiceRegistry {
                    @Override
                    public BiometricManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        if (BiometricManager.hasBiometrics(ctx)) {
                        final IBinder binder =
                                ServiceManager.getServiceOrThrow(Context.BIOMETRIC_SERVICE);
                        final IBiometricService service =
                                IBiometricService.Stub.asInterface(binder);
                        return new BiometricManager(ctx.getOuterContext(), service);
                        } else {
                            // Allow access to the manager when service is null. This saves memory
                            // on devices without biometric hardware.
                            return new BiometricManager(ctx.getOuterContext(), null);
                        }
                    }
                });

+2 −9
Original line number Diff line number Diff line
@@ -648,15 +648,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            mExecutor = executor;
            mAuthenticationCallback = callback;
            final long sessionId = crypto != null ? crypto.getOpId() : 0;
            if (BiometricManager.hasBiometrics(mContext)) {
            mService.authenticate(mToken, sessionId, userId, mBiometricServiceReceiver,
                    mContext.getOpPackageName(), mBundle, confirmDeviceCredentialCallback);
            } else {
                mExecutor.execute(() -> {
                    callback.onAuthenticationError(BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT,
                            mContext.getString(R.string.biometric_error_hw_unavailable));
                });
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Remote exception while authenticating", e);
            mExecutor.execute(() -> {
+4 −6
Original line number Diff line number Diff line
@@ -1798,12 +1798,10 @@ public final class SystemServer {
                traceEnd();
            }

            if (hasFeatureFace || hasFeatureIris || hasFeatureFingerprint) {
            // Start this service after all biometric services.
            traceBeginAndSlog("StartBiometricService");
            mSystemServiceManager.startService(BiometricService.class);
            traceEnd();
            }

            traceBeginAndSlog("StartBackgroundDexOptService");
            try {