Log app versionCode in anomaly detection

Change-Id: Ie760a4156b14b739279aa398bd1d2b8485449e91
Fixes: 77919142
Test: RunSettingsRoboTests
This commit is contained in:
Lei Yu
2018-04-11 19:53:53 -07:00
parent 7d09e2ea68
commit 63795b2f5c
3 changed files with 32 additions and 5 deletions

View File

@@ -146,6 +146,7 @@ public class AnomalyDetectionJobService extends JobService {
: Settings.Global.getInt(contentResolver,
Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON;
final String packageName = batteryUtils.getPackageName(uid);
final long versionCode = batteryUtils.getAppLongVersionCode(packageName);
final boolean anomalyDetected;
if (isExcessiveBackgroundAnomaly(anomalyInfo)) {
@@ -162,7 +163,9 @@ public class AnomalyDetectionJobService extends JobService {
MetricsProto.MetricsEvent.ACTION_ANOMALY_IGNORED,
packageName,
Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT,
anomalyInfo.anomalyType));
anomalyInfo.anomalyType),
Pair.create(MetricsProto.MetricsEvent.FIELD_APP_VERSION_CODE,
versionCode));
} else {
if (autoFeatureOn && anomalyInfo.autoRestriction) {
// Auto restrict this app
@@ -180,7 +183,9 @@ public class AnomalyDetectionJobService extends JobService {
MetricsProto.MetricsEvent.ACTION_ANOMALY_TRIGGERED,
packageName,
Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE,
anomalyInfo.anomalyType));
anomalyInfo.anomalyType),
Pair.create(MetricsProto.MetricsEvent.FIELD_APP_VERSION_CODE,
versionCode));
}
}
} catch (NullPointerException | IndexOutOfBoundsException e) {