Add the current sensor strength into dumpsys

Bug: 169730503

Test: atest com.android.server.biometrics
Test: atest com.android.systemui.biometrics
Change-Id: I67529fc65fb712ff7231f4aa063cb0d84aabd701
This commit is contained in:
Haining Chen
2021-03-31 15:16:37 -07:00
parent b82251a5ff
commit 03ecc2d4b7
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

@@ -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()) {

View File

@@ -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()) {

View File

@@ -526,6 +526,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

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