Merge "Read odsign metrics from a file and write to statsd."
This commit is contained in:
@@ -39,6 +39,7 @@ public class OdsignStatsLogger {
|
|||||||
// These need to be kept in sync with system/security/ondevice-signing/StatsReporter.{h, cpp}.
|
// These need to be kept in sync with system/security/ondevice-signing/StatsReporter.{h, cpp}.
|
||||||
private static final String METRICS_FILE = "/data/misc/odsign/metrics/odsign-metrics.txt";
|
private static final String METRICS_FILE = "/data/misc/odsign/metrics/odsign-metrics.txt";
|
||||||
private static final String COMPOS_METRIC_NAME = "comp_os_artifacts_check_record";
|
private static final String COMPOS_METRIC_NAME = "comp_os_artifacts_check_record";
|
||||||
|
private static final String ODSIGN_METRIC_NAME = "odsign_record";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arrange for stats to be uploaded in the background.
|
* Arrange for stats to be uploaded in the background.
|
||||||
@@ -64,9 +65,16 @@ public class OdsignStatsLogger {
|
|||||||
for (String line : lines.split("\n")) {
|
for (String line : lines.split("\n")) {
|
||||||
String[] metrics = line.split(" ");
|
String[] metrics = line.split(" ");
|
||||||
|
|
||||||
if (metrics.length != 4 || !metrics[0].equals(COMPOS_METRIC_NAME)) {
|
if (line.isEmpty() || metrics.length < 1) {
|
||||||
Slog.w(TAG, "Malformed metrics file");
|
Slog.w(TAG, "Empty metrics line");
|
||||||
break;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (metrics[0]) {
|
||||||
|
case COMPOS_METRIC_NAME: {
|
||||||
|
if (metrics.length != 4) {
|
||||||
|
Slog.w(TAG, "Malformed CompOS metrics line '" + line + "'");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean currentArtifactsOk = metrics[1].equals("1");
|
boolean currentArtifactsOk = metrics[1].equals("1");
|
||||||
@@ -76,6 +84,26 @@ public class OdsignStatsLogger {
|
|||||||
ArtStatsLog.write(ArtStatsLog.EARLY_BOOT_COMP_OS_ARTIFACTS_CHECK_REPORTED,
|
ArtStatsLog.write(ArtStatsLog.EARLY_BOOT_COMP_OS_ARTIFACTS_CHECK_REPORTED,
|
||||||
currentArtifactsOk, compOsPendingArtifactsExists,
|
currentArtifactsOk, compOsPendingArtifactsExists,
|
||||||
useCompOsGeneratedArtifacts);
|
useCompOsGeneratedArtifacts);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ODSIGN_METRIC_NAME: {
|
||||||
|
if (metrics.length != 2) {
|
||||||
|
Slog.w(TAG, "Malformed odsign metrics line '" + line + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int status = Integer.parseInt(metrics[1]);
|
||||||
|
ArtStatsLog.write(ArtStatsLog.ODSIGN_REPORTED, status);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Slog.w(TAG, "Malformed odsign metrics line '" + line + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Slog.w(TAG, "Malformed metrics line '" + line + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// This is normal and probably means no new metrics have been generated.
|
// This is normal and probably means no new metrics have been generated.
|
||||||
|
|||||||
Reference in New Issue
Block a user