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

Commit 03ecc2d4 authored by Haining Chen's avatar Haining Chen
Browse files

Add the current sensor strength into dumpsys

Bug: 169730503

Test: atest com.android.server.biometrics
Test: atest com.android.systemui.biometrics
Change-Id: I67529fc65fb712ff7231f4aa063cb0d84aabd701
parent b82251a5
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -120,18 +120,23 @@ message SensorStateProto {

    optional Modality modality = 2;

    // The current strength (see {@link BiometricManager.Authenticators}) of this sensor, taking any
    // downgraded strengths into effect. It may be different from the sensor's original strength but
    // can never be stronger than that.
    optional int32 current_strength = 3;

    // State of the sensor's scheduler.
    optional BiometricSchedulerProto scheduler = 3;
    optional BiometricSchedulerProto scheduler = 4;

    // User states for this sensor.
    repeated UserStateProto user_states = 4;
    repeated UserStateProto user_states = 5;

    // True if resetLockout requires a HAT to be verified in the TEE or equivalent.
    optional bool reset_lockout_requires_hardware_auth_token = 5;
    optional bool reset_lockout_requires_hardware_auth_token = 6;

    // True if a HAT is required (field above) AND a challenge needs to be generated by the
    // biometric TEE (or equivalent), and wrapped within the HAT.
    optional bool reset_lockout_requires_challenge = 6;
    optional bool reset_lockout_requires_challenge = 7;
}

// State of a specific user for a specific sensor.
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ public class BiometricStrengthController {
            final int id = sensor.id;
            if (idToStrength.containsKey(id)) {
                final int newStrength = idToStrength.get(id);
                Slog.d(TAG, "updateStrengths: update sensorId=" + id + " to newStrength="
                        + newStrength);
                sensor.updateStrength(newStrength);
            }
        }
+17 −0
Original line number Diff line number Diff line
@@ -410,6 +410,23 @@ public class Utils {
        }
    }

    /**
     * Returns the sensor's current strength, taking any updated strengths into effect.
     *
     * @param sensorId The sensor Id
     * @return see {@link BiometricManager.Authenticators}
     */
    public static @Authenticators.Types int getCurrentStrength(int sensorId) {
        IBiometricService service = IBiometricService.Stub.asInterface(
                ServiceManager.getService(Context.BIOMETRIC_SERVICE));
        try {
            return service.getCurrentStrength(sensorId);
        } catch (RemoteException e) {
            Slog.e(TAG, "RemoteException", e);
            return Authenticators.EMPTY_SET;
        }
    }

    /**
     * Checks if a client package matches Keyguard and can perform internal biometric operations.
     *
+2 −0
Original line number Diff line number Diff line
@@ -546,6 +546,8 @@ public class Sensor {

        proto.write(SensorStateProto.SENSOR_ID, mSensorProperties.sensorId);
        proto.write(SensorStateProto.MODALITY, SensorStateProto.FACE);
        proto.write(SensorStateProto.CURRENT_STRENGTH,
                Utils.getCurrentStrength(mSensorProperties.sensorId));
        proto.write(SensorStateProto.SCHEDULER, mScheduler.dumpProtoState(clearSchedulerBuffer));

        for (UserInfo user : UserManager.get(mContext).getUsers()) {
+2 −0
Original line number Diff line number Diff line
@@ -792,6 +792,8 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {

        proto.write(SensorStateProto.SENSOR_ID, mSensorProperties.sensorId);
        proto.write(SensorStateProto.MODALITY, SensorStateProto.FACE);
        proto.write(SensorStateProto.CURRENT_STRENGTH,
                Utils.getCurrentStrength(mSensorProperties.sensorId));
        proto.write(SensorStateProto.SCHEDULER, mScheduler.dumpProtoState(clearSchedulerBuffer));

        for (UserInfo user : UserManager.get(mContext).getUsers()) {
Loading