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

Commit dd6d27ec authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move the face HIDL code under the hidl package"

parents 1091e697 92de384c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class FaceService extends SystemService {
    private final LockoutResetDispatcher mLockoutResetDispatcher;
    private final LockPatternUtils mLockPatternUtils;
    @NonNull
    private List<ServiceProvider> mServiceProviders;
    private final List<ServiceProvider> mServiceProviders;

    @Nullable
    private ServiceProvider getProviderForSensor(int sensorId) {
@@ -498,7 +498,8 @@ public class FaceService extends SystemService {
                @BiometricManager.Authenticators.Types int strength) {
            Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
            mServiceProviders.add(
                    new Face10(getContext(), sensorId, strength, mLockoutResetDispatcher));
                    new com.android.server.biometrics.sensors.face.hidl.Face10(getContext(),
                            sensorId, strength, mLockoutResetDispatcher));
        }
    }

+5 −5
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import java.util.ArrayDeque;
 * Keep a short historical buffer of stats, with an aggregated usage time.
 */

class UsageStats {
public class UsageStats {
    private static final int EVENT_LOG_SIZE = 100;

    /**
@@ -44,7 +44,7 @@ class UsageStats {
        private int mVendorError;
        private int mUser;

        AuthenticationEvent(long startTime, long latency, boolean authenticated, int error,
        public AuthenticationEvent(long startTime, long latency, boolean authenticated, int error,
                int vendorError, int user) {
            mStartTime = startTime;
            mLatency = latency;
@@ -76,14 +76,14 @@ class UsageStats {
    private long mRejectLatency;
    private SparseLongArray mErrorLatency;

    UsageStats(Context context) {
    public UsageStats(Context context) {
        mAuthenticationEvents = new ArrayDeque<>();
        mErrorCount = new SparseIntArray();
        mErrorLatency = new SparseLongArray();
        mContext = context;
    }

    void addEvent(AuthenticationEvent event) {
    public void addEvent(AuthenticationEvent event) {
        if (mAuthenticationEvents.size() >= EVENT_LOG_SIZE) {
            mAuthenticationEvents.removeFirst();
        }
@@ -101,7 +101,7 @@ class UsageStats {
        }
    }

    void print(PrintWriter pw) {
    public void print(PrintWriter pw) {
        pw.println("Events since last reboot: " + mAuthenticationEvents.size());
        for (AuthenticationEvent event : mAuthenticationEvents) {
            pw.println(event.toString(mContext));
+156 −143
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.server.biometrics.sensors.face;
package com.android.server.biometrics.sensors.face.hidl;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -63,6 +63,10 @@ import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.LockoutTracker;
import com.android.server.biometrics.sensors.PerformanceTracker;
import com.android.server.biometrics.sensors.RemovalConsumer;
import com.android.server.biometrics.sensors.face.FaceUtils;
import com.android.server.biometrics.sensors.face.LockoutHalImpl;
import com.android.server.biometrics.sensors.face.ServiceProvider;
import com.android.server.biometrics.sensors.face.UsageStats;

import org.json.JSONArray;
import org.json.JSONException;
@@ -82,7 +86,7 @@ import java.util.Map;
 * Supports a single instance of the {@link android.hardware.biometrics.face.V1_0} or
 * its extended minor versions.
 */
class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {

    private static final String TAG = "Face10";
    private static final int ENROLL_TIMEOUT_SEC = 75;
@@ -140,7 +144,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                }

                @Override
        public void onAuthenticated(long deviceId, int faceId, int userId, ArrayList<Byte> token) {
                public void onAuthenticated(long deviceId, int faceId, int userId,
                        ArrayList<Byte> token) {
                    mHandler.post(() -> {
                        final ClientMonitor<?> client = mScheduler.getCurrentClient();
                        if (!(client instanceof AuthenticationConsumer)) {
@@ -158,7 +163,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                }

                @Override
        public void onAcquired(long deviceId, int userId, int acquiredInfo, int vendorCode) {
                public void onAcquired(long deviceId, int userId, int acquiredInfo,
                        int vendorCode) {
                    mHandler.post(() -> {
                        final ClientMonitor<?> client = mScheduler.getCurrentClient();
                        if (!(client instanceof AcquisitionClient)) {
@@ -167,7 +173,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                            return;
                        }

                final AcquisitionClient<?> acquisitionClient = (AcquisitionClient<?>) client;
                        final AcquisitionClient<?> acquisitionClient =
                                (AcquisitionClient<?>) client;
                        acquisitionClient.onAcquired(acquiredInfo, vendorCode);
                    });
                }
@@ -181,7 +188,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                                + ", error: " + error
                                + ", vendorCode: " + vendorCode);
                        if (!(client instanceof Interruptable)) {
                    Slog.e(TAG, "onError for non-error consumer: " + Utils.getClientName(client));
                            Slog.e(TAG, "onError for non-error consumer: " + Utils.getClientName(
                                    client));
                            return;
                        }

@@ -209,7 +217,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                        final RemovalConsumer removalConsumer = (RemovalConsumer) client;

                        if (!removed.isEmpty()) {
                    // Convert to old fingerprint-like behavior, where remove() receives one removal
                            // Convert to old fingerprint-like behavior, where remove() receives
                            // one removal
                            // at a time. This way, remove can share some more common code.
                            for (int i = 0; i < removed.size(); i++) {
                                final int id = removed.get(i);
@@ -240,15 +249,19 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
                        final EnumerateConsumer enumerateConsumer = (EnumerateConsumer) client;

                        if (!faceIds.isEmpty()) {
                    // Convert to old fingerprint-like behavior, where enumerate() receives one
                    // template at a time. This way, enumerate can share some more common code.
                            // Convert to old fingerprint-like behavior, where enumerate()
                            // receives one
                            // template at a time. This way, enumerate can share some more common
                            // code.
                            for (int i = 0; i < faceIds.size(); i++) {
                                final Face face = new Face("", faceIds.get(i), deviceId);
                                enumerateConsumer.onEnumerationResult(face, faceIds.size() - i - 1);
                            }
                        } else {
                    // For face, the HIDL contract is to receive an empty list when there are no
                    // templates enrolled. Send a null identifier since we don't consume them
                            // For face, the HIDL contract is to receive an empty list when there
                            // are no
                            // templates enrolled. Send a null identifier since we don't consume
                            // them
                            // anywhere, and send remaining == 0 so this code can be shared with
                            // Fingerprint@2.1
                            enumerateConsumer.onEnumerationResult(null /* identifier */, 0);
@@ -279,7 +292,7 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
            };

    @VisibleForTesting
    Face10(@NonNull Context context, int sensorId,
    public Face10(@NonNull Context context, int sensorId,
            @BiometricManager.Authenticators.Types int strength,
            @NonNull LockoutResetDispatcher lockoutResetDispatcher,
            boolean supportsSelfIllumination, int maxTemplatesAllowed) {
@@ -304,7 +317,7 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
        }
    }

    Face10(@NonNull Context context, int sensorId,
    public Face10(@NonNull Context context, int sensorId,
            @BiometricManager.Authenticators.Types int strength,
            @NonNull LockoutResetDispatcher lockoutResetDispatcher) {
        this(context, sensorId, strength, lockoutResetDispatcher,
@@ -479,8 +492,8 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
    public void scheduleRevokeChallenge(int sensorId, int userId, @NonNull IBinder token,
            @NonNull String opPackageName, long challenge) {
        mHandler.post(() -> {
            if (mCurrentChallengeOwner != null &&
                    !mCurrentChallengeOwner.getOwnerString().contentEquals(opPackageName)) {
            if (mCurrentChallengeOwner != null
                    && !mCurrentChallengeOwner.getOwnerString().contentEquals(opPackageName)) {
                Slog.e(TAG, "scheduleRevokeChallenge, package: " + opPackageName
                        + " attempting to revoke challenge owned by: "
                        + mCurrentChallengeOwner.getOwnerString());
@@ -717,10 +730,10 @@ class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
            JSONArray sets = new JSONArray();
            for (UserInfo user : UserManager.get(mContext).getUsers()) {
                final int userId = user.getUserHandle().getIdentifier();
                final int N = FaceUtils.getInstance().getBiometricsForUser(mContext, userId).size();
                final int c = FaceUtils.getInstance().getBiometricsForUser(mContext, userId).size();
                JSONObject set = new JSONObject();
                set.put("id", userId);
                set.put("count", N);
                set.put("count", c);
                set.put("accept", performanceTracker.getAcceptForUser(userId));
                set.put("reject", performanceTracker.getRejectForUser(userId));
                set.put("acquire", performanceTracker.getAcquireForUser(userId));
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.server.biometrics.sensors.face;
package com.android.server.biometrics.sensors.face.hidl;

import android.annotation.NonNull;
import android.app.Notification;
@@ -40,6 +40,7 @@ import com.android.server.biometrics.Utils;
import com.android.server.biometrics.sensors.AuthenticationClient;
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
import com.android.server.biometrics.sensors.LockoutTracker;
import com.android.server.biometrics.sensors.face.UsageStats;

import java.util.ArrayList;

+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.server.biometrics.sensors.face;
package com.android.server.biometrics.sensors.face.hidl;

import android.annotation.NonNull;
import android.annotation.Nullable;
Loading