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

Commit 5560b464 authored by Diya Bera's avatar Diya Bera Committed by Android (Google) Code Review
Browse files

Merge "Fix FaceServiceTest" into main

parents 62af1124 0ad7205f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ public class FaceSensorConfigurations implements Parcelable {
            try {
                IVirtualHal vhal = IVirtualHal.Stub.asInterface(
                        Binder.allowBlocking(ServiceManager.waitForService(fqNameMapped)));
                return vhal.getFaceHal();
                return vhal != null ? vhal.getFaceHal() : null;
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception in vhal.getFaceHal() call" + fqNameMapped);
            }
+2 −32
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.face;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.MANAGE_FACE;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.hardware.face.FaceSensorConfigurations.getIFace;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -81,7 +80,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

/**
@@ -105,9 +103,6 @@ public class FaceService extends SystemService {
    private final AuthenticationStateListeners mAuthenticationStateListeners;
    @NonNull
    private final FaceProviderFunction mFaceProviderFunction;
    @NonNull private final Function<String, FaceProvider> mFaceProvider;
    @NonNull
    private final Supplier<String[]> mAidlInstanceNameSupplier;

    interface FaceProviderFunction {
        FaceProvider getFaceProvider(Pair<String, SensorProps[]> filteredSensorProps,
@@ -757,17 +752,13 @@ public class FaceService extends SystemService {
                BiometricContext.getInstance(context),
                null /* faceProviderFunction */,
                () -> IBiometricService.Stub.asInterface(
                        ServiceManager.getService(Context.BIOMETRIC_SERVICE)),
                null /* faceProvider */,
                () -> getDeclaredInstances());
                        ServiceManager.getService(Context.BIOMETRIC_SERVICE)));
    }

    @VisibleForTesting FaceService(Context context,
            BiometricContext biometricContext,
            FaceProviderFunction faceProviderFunction,
            Supplier<IBiometricService> biometricServiceSupplier,
            Function<String, FaceProvider> faceProvider,
            Supplier<String[]> aidlInstanceNameSupplier) {
            Supplier<IBiometricService> biometricServiceSupplier) {
        super(context);
        mServiceWrapper = new FaceServiceWrapper();
        mLockoutResetDispatcher = new LockoutResetDispatcher(context);
@@ -781,27 +772,6 @@ public class FaceService extends SystemService {
                mBiometricStateCallback.start(mRegistry.getProviders());
            }
        });
        mAidlInstanceNameSupplier = aidlInstanceNameSupplier;

        mFaceProvider = faceProvider != null ? faceProvider : (name) -> {
            final String fqName = IFace.DESCRIPTOR + "/" + name;
            final IFace face = getIFace(fqName);
            if (face == null) {
                Slog.e(TAG, "Unable to get declared service: " + fqName);
                return null;
            }
            try {
                final SensorProps[] props = face.getSensorProps();
                return new FaceProvider(getContext(),
                        mBiometricStateCallback, mAuthenticationStateListeners, props, name,
                        mLockoutResetDispatcher, biometricContext,
                        false /* resetLockoutRequiresChallenge */);
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception in getSensorProps: " + fqName);
            }

            return null;
        };

        mFaceProviderFunction = faceProviderFunction != null ? faceProviderFunction :
                ((filteredSensorProps, resetLockoutRequiresChallenge) -> new FaceProvider(
+1 −7
Original line number Diff line number Diff line
@@ -140,13 +140,7 @@ public class FaceServiceTest {
                    if (NAME_DEFAULT.equals(filteredSensorProps.first)) return mFaceProviderDefault;
                    if (NAME_VIRTUAL.equals(filteredSensorProps.first)) return mFaceProviderVirtual;
                    return null;
                }, () -> mIBiometricService,
                (name) -> {
                    if (NAME_DEFAULT.equals(name)) return mFaceProviderDefault;
                    if (NAME_VIRTUAL.equals(name)) return mFaceProviderVirtual;
                    return null;
                },
                () -> new String[]{NAME_DEFAULT, NAME_VIRTUAL});
                }, () -> mIBiometricService);
    }

    @Test