Call detect anomaly in period job only when there is new battery usage data.
- Reduce the memory usage of call anomaly detection - Remove redundant condition for low battery banner Bug: 300446490 Bug: 284893240 Fix: 300446490 Test: presubmit Change-Id: I11c1b41a45e129bcec57b9d18c4affe0de7f1d38
This commit is contained in:
@@ -116,8 +116,16 @@ public final class BatteryUsageDataLoader {
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
final BatteryLevelData batteryLevelData = DataProcessManager.getBatteryLevelData(
|
||||
context, handler, /*isFromPeriodJob=*/ true,
|
||||
batteryDiffDataMap -> DatabaseUtils.sendBatteryUsageSlotData(context,
|
||||
ConvertUtils.convertToBatteryUsageSlotList(batteryDiffDataMap)));
|
||||
batteryDiffDataMap -> {
|
||||
DatabaseUtils.sendBatteryUsageSlotData(context,
|
||||
ConvertUtils.convertToBatteryUsageSlotList(batteryDiffDataMap));
|
||||
if (batteryDiffDataMap.values().stream().anyMatch(data ->
|
||||
(!data.getAppDiffEntryList().isEmpty()
|
||||
|| !data.getSystemDiffEntryList().isEmpty()))) {
|
||||
FeatureFactory.getFeatureFactory().getPowerUsageFeatureProvider()
|
||||
.detectSettingsAnomaly(context, /* displayDrain= */ 0);
|
||||
}
|
||||
});
|
||||
if (batteryLevelData == null) {
|
||||
Log.d(TAG, "preprocessBatteryUsageSlots() no new battery usage data.");
|
||||
return;
|
||||
@@ -139,8 +147,6 @@ public final class BatteryUsageDataLoader {
|
||||
// No app usage data or battery diff data at this time.
|
||||
loadAppUsageData(context);
|
||||
preprocessBatteryUsageSlots(context);
|
||||
FeatureFactory.getFeatureFactory().getPowerUsageFeatureProvider()
|
||||
.detectSettingsAnomaly(context, /* displayDrain= */ 0);
|
||||
}
|
||||
Log.d(TAG, String.format(
|
||||
"loadUsageDataSafely() in %d/ms", System.currentTimeMillis() - start));
|
||||
|
||||
Reference in New Issue
Block a user