diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java | 23 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java | 13 |
2 files changed, 32 insertions, 4 deletions
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java index eacb31f910..603bca02e8 100644 --- a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java +++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java @@ -35,7 +35,11 @@ public class AnomalyDetectionPolicy { @VisibleForTesting static final String KEY_WAKELOCK_DETECTION_ENABLED = "wakelock_enabled"; @VisibleForTesting + static final String KEY_WAKEUP_ALARM_DETECTION_ENABLED = "wakeup_alarm_enabled"; + @VisibleForTesting static final String KEY_WAKELOCK_THRESHOLD = "wakelock_threshold"; + @VisibleForTesting + static final String KEY_WAKEUP_ALARM_THRESHOLD = "wakeup_alarm_threshold"; /** * {@code true} if general anomaly detection is enabled @@ -54,6 +58,14 @@ public class AnomalyDetectionPolicy { public final boolean wakeLockDetectionEnabled; /** + * {@code true} if wakeup alarm detection is enabled + * + * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS + * @see #KEY_WAKEUP_ALARM_DETECTION_ENABLED + */ + public final boolean wakeupAlarmDetectionEnabled; + + /** * Threshold for wakelock time in milli seconds * * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS @@ -61,6 +73,14 @@ public class AnomalyDetectionPolicy { */ public final long wakeLockThreshold; + /** + * Threshold for wakeup alarm count per hour + * + * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS + * @see #KEY_WAKEUP_ALARM_THRESHOLD + */ + public final long wakeupAlarmThreshold; + private final KeyValueListParserWrapper mParserWrapper; public AnomalyDetectionPolicy(Context context) { @@ -81,8 +101,11 @@ public class AnomalyDetectionPolicy { anomalyDetectionEnabled = mParserWrapper.getBoolean(KEY_ANOMALY_DETECTION_ENABLED, true); wakeLockDetectionEnabled = mParserWrapper.getBoolean(KEY_WAKELOCK_DETECTION_ENABLED, true); + wakeupAlarmDetectionEnabled = mParserWrapper.getBoolean(KEY_WAKEUP_ALARM_DETECTION_ENABLED, + true); wakeLockThreshold = mParserWrapper.getLong(KEY_WAKELOCK_THRESHOLD, DateUtils.HOUR_IN_MILLIS); + wakeupAlarmThreshold = mParserWrapper.getLong(KEY_WAKEUP_ALARM_THRESHOLD, 60); } } diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java index 82c009ed29..b97fd46d1f 100644 --- a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java +++ b/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java @@ -39,15 +39,20 @@ import java.util.List; */ public class WakeupAlarmAnomalyDetector implements AnomalyDetector { private static final String TAG = "WakeupAlarmAnomalyDetector"; - //TODO: add this threshold into AnomalyDetectionPolicy - private static final int WAKEUP_ALARM_THRESHOLD = 60; - private Context mContext; @VisibleForTesting BatteryUtils mBatteryUtils; + private long mWakeupAlarmThreshold; + private Context mContext; public WakeupAlarmAnomalyDetector(Context context) { + this(context, new AnomalyDetectionPolicy(context)); + } + + @VisibleForTesting + WakeupAlarmAnomalyDetector(Context context, AnomalyDetectionPolicy policy) { mContext = context; mBatteryUtils = BatteryUtils.getInstance(context); + mWakeupAlarmThreshold = policy.wakeupAlarmThreshold; } @Override @@ -66,7 +71,7 @@ public class WakeupAlarmAnomalyDetector implements AnomalyDetector { } final int wakeups = getWakeupAlarmCountFromUid(uid); - if ((wakeups / totalRunningHours) > WAKEUP_ALARM_THRESHOLD) { + if ((wakeups / totalRunningHours) > mWakeupAlarmThreshold) { final String packageName = mBatteryUtils.getPackageName(uid.getUid()); final CharSequence displayName = Utils.getApplicationLabel(mContext, packageName); |