Add wakelock anomaly detector

This cl detects whether apps hold wakelock for long time.
For now we use the following attribute:
1. Longest total duration time among all the wakelocks
for one app.

Following cl will:
1. Get threshold from server side.
2. Add more attributes to make the detection more robust.

Bug: 36925184
Test: RunSettingsRoboTests

Change-Id: I1946faf69c363f6aa823d0005d6e03bc9082c085
This commit is contained in:
jackqdyulei
2017-04-25 18:22:45 -07:00
parent f223383936
commit 4aa3358c4c
5 changed files with 263 additions and 10 deletions

View File

@@ -39,13 +39,16 @@ public class AnomalyLoader extends AsyncLoader<List<Anomaly>> {
}
@Override
protected void onDiscardResult(List<Anomaly> result) {}
protected void onDiscardResult(List<Anomaly> result) {
}
@Override
public List<Anomaly> loadInBackground() {
final List<Anomaly> anomalies = new ArrayList<>();
anomalies.addAll(new WakeLockAnomalyDetector().detectAnomalies(mBatteryStatsHelper));
anomalies.addAll(new WakeLockAnomalyDetector(getContext())
.detectAnomalies(mBatteryStatsHelper));
return anomalies;
}
}