Ensure negative latencies are not being reported

Ensure that BiometricsService will not report negative latencies.
Test: Manual
Bug: 148408637

Change-Id: Ie6a22ebeff4711b5f51c787392e00cc8daf9129c
This commit is contained in:
joshmccloskey
2020-02-10 14:31:50 -08:00
parent 7f99ea08eb
commit b16c7e3d8e

View File

@@ -124,7 +124,7 @@ public abstract class LoggableMonitor {
error,
vendorCode,
Utils.isDebugEnabled(context, targetUserId),
latency);
sanitizeLatency(latency));
}
protected final void logOnAuthenticated(Context context, boolean authenticated,
@@ -165,7 +165,7 @@ public abstract class LoggableMonitor {
statsClient(),
requireConfirmation,
authState,
latency,
sanitizeLatency(latency),
Utils.isDebugEnabled(context, targetUserId));
}
@@ -183,8 +183,16 @@ public abstract class LoggableMonitor {
FrameworkStatsLog.write(FrameworkStatsLog.BIOMETRIC_ENROLLED,
statsModality(),
targetUserId,
latency,
sanitizeLatency(latency),
enrollSuccessful);
}
private long sanitizeLatency(long latency) {
if (latency < 0) {
Slog.w(TAG, "found a negative latency : " + latency);
return -1;
}
return latency;
}
}