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

Commit c486219b authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Update Fingerprint/Face getSensorProperties

For each modality, updates/adds getSensorProperties() to return a list
of all sensors, containing their sensorId and other properties.

Bug: 160024833
Bug: 145978626

Test: atest KeyguardUpdateMonitorTest
Test: enroll/auth on fingerprint/face devices

Change-Id: I9adc4798183f53881f3592a8e72e6bd3595fbf1e
parent e1e6d6cb
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.view.Surface;
import com.android.internal.R;
import com.android.internal.os.SomeArgs;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -622,16 +623,16 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    @NonNull
    public FaceSensorProperties getSensorProperties() {
    public List<FaceSensorProperties> getSensorProperties() {
        try {
            if (mService == null || !mService.isHardwareDetected(mContext.getOpPackageName())) {
                return new FaceSensorProperties();
                return new ArrayList<>();
            }
            return mService.getSensorProperties(mContext.getOpPackageName());
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
        return new FaceSensorProperties();
        return new ArrayList<>();
    }

    /**
+5 −8
Original line number Diff line number Diff line
@@ -25,23 +25,19 @@ import android.os.Parcelable;
 */
public class FaceSensorProperties implements Parcelable {

    public final int sensorId;
    public final boolean supportsFaceDetection;

    /**
     * Creates a SensorProperties class with safe default values
     */
    public FaceSensorProperties() {
        supportsFaceDetection = false;
    }

    /**
     * Initializes SensorProperties with specified values
     */
    public FaceSensorProperties(boolean supportsFaceDetection) {
    public FaceSensorProperties(int sensorId, boolean supportsFaceDetection) {
        this.sensorId = sensorId;
        this.supportsFaceDetection = supportsFaceDetection;
    }

    protected FaceSensorProperties(Parcel in) {
        sensorId = in.readInt();
        supportsFaceDetection = in.readBoolean();
    }

@@ -65,6 +61,7 @@ public class FaceSensorProperties implements Parcelable {

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(sensorId);
        dest.writeBoolean(supportsFaceDetection);
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ import android.view.Surface;
 * @hide
 */
interface IFaceService {
    // Retrieve static sensor properties for all face sensors
    List<FaceSensorProperties> getSensorProperties(String opPackageName);

    // Authenticate the given sessionId with a face
    void authenticate(IBinder token, long operationId, int userid, IFaceServiceReceiver receiver,
            String opPackageName);
@@ -88,9 +91,6 @@ interface IFaceService {
    // Determine if a user has at least one enrolled face
    boolean hasEnrolledFaces(int userId, String opPackageName);

    // Retrieve static sensor properties
    FaceSensorProperties getSensorProperties(String opPackageName);

    // Return the LockoutTracker status for the specified user
    int getLockoutModeForUser(int userId);

+19 −18
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.util.Slog;
import android.view.Surface;

import java.security.Signature;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
@@ -736,24 +737,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        return hasEnrolledFingerprints(userId);
    }

    /**
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public boolean isUdfps() {
        if (mService == null) {
            Slog.w(TAG, "isUdfps: no fingerprint service");
            return false;
        }

        try {
            return mService.isUdfps();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
        return false;
    }

    /**
     * @hide
     */
@@ -861,6 +844,24 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        return false;
    }

    /**
     * Get statically configured sensor properties.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    @NonNull
    public List<FingerprintSensorProperties> getSensorProperties() {
        try {
            if (mService == null || !mService.isHardwareDetected(mContext.getOpPackageName())) {
                return new ArrayList<>();
            }
            return mService.getSensorProperties(mContext.getOpPackageName());
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
        return new ArrayList<>();
    }

    /**
     * @hide
     */
+18 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.hardware.fingerprint;

parcelable FingerprintSensorProperties;
 No newline at end of file
Loading