Merge "Add the current sensor strength into dumpsys" into sc-dev

This commit is contained in:
Haining Chen
2021-04-20 20:27:30 +00:00
committed by Android (Google) Code Review
7 changed files with 36 additions and 4 deletions

View File

@@ -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.

View File

@@ -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);
}
}

View File

@@ -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.
*

View File

@@ -557,6 +557,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()) {

View File

@@ -807,6 +807,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()) {

View File

@@ -527,6 +527,8 @@ class Sensor {
proto.write(SensorStateProto.SENSOR_ID, mSensorProperties.sensorId);
proto.write(SensorStateProto.MODALITY, SensorStateProto.FINGERPRINT);
proto.write(SensorStateProto.CURRENT_STRENGTH,
Utils.getCurrentStrength(mSensorProperties.sensorId));
proto.write(SensorStateProto.SCHEDULER, mScheduler.dumpProtoState(clearSchedulerBuffer));
for (UserInfo user : UserManager.get(mContext).getUsers()) {

View File

@@ -764,6 +764,8 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
proto.write(SensorStateProto.SENSOR_ID, mSensorProperties.sensorId);
proto.write(SensorStateProto.MODALITY, SensorStateProto.FINGERPRINT);
proto.write(SensorStateProto.CURRENT_STRENGTH,
Utils.getCurrentStrength(mSensorProperties.sensorId));
proto.write(SensorStateProto.SCHEDULER, mScheduler.dumpProtoState(clearSchedulerBuffer));
for (UserInfo user : UserManager.get(mContext).getUsers()) {