Provide foreground_service usage time in BatteryDiffEntry.
- Fetch foreground service info through new api from UidBatteryConsumer. - Record fgs & bg usage time separately, combine them till ui display. Bug: 315255868 Test: make RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.fuelgauge.*" Change-Id: Ic19844db7908a6ae6522c7a72972f44f94dcfca4
This commit is contained in:
@@ -660,36 +660,39 @@ public final class DatabaseUtils {
|
||||
// Creates the ContentValues list to insert them into provider.
|
||||
final List<ContentValues> valuesList = new ArrayList<>();
|
||||
if (batteryEntryList != null) {
|
||||
batteryEntryList.stream()
|
||||
.filter(
|
||||
entry -> {
|
||||
final long foregroundMs = entry.getTimeInForegroundMs();
|
||||
final long backgroundMs = entry.getTimeInBackgroundMs();
|
||||
if (entry.getConsumedPower() == 0
|
||||
&& (foregroundMs != 0 || backgroundMs != 0)) {
|
||||
Log.w(
|
||||
TAG,
|
||||
String.format(
|
||||
"no consumed power but has running time for %s"
|
||||
+ " time=%d|%d",
|
||||
entry.getLabel(), foregroundMs, backgroundMs));
|
||||
}
|
||||
return entry.getConsumedPower() != 0
|
||||
|| foregroundMs != 0
|
||||
|| backgroundMs != 0;
|
||||
})
|
||||
.forEach(
|
||||
entry ->
|
||||
valuesList.add(
|
||||
ConvertUtils.convertBatteryEntryToContentValues(
|
||||
entry,
|
||||
batteryUsageStats,
|
||||
batteryLevel,
|
||||
batteryStatus,
|
||||
batteryHealth,
|
||||
snapshotBootTimestamp,
|
||||
snapshotTimestamp,
|
||||
isFullChargeStart)));
|
||||
for (BatteryEntry entry : batteryEntryList) {
|
||||
final long foregroundMs = entry.getTimeInForegroundMs();
|
||||
final long foregroundServiceMs = entry.getTimeInForegroundServiceMs();
|
||||
final long backgroundMs = entry.getTimeInBackgroundMs();
|
||||
if (entry.getConsumedPower() == 0
|
||||
&& (foregroundMs != 0 || foregroundServiceMs != 0 || backgroundMs != 0)) {
|
||||
Log.w(
|
||||
TAG,
|
||||
String.format(
|
||||
"no consumed power but has running time for %s"
|
||||
+ " time=%d|%d|%d",
|
||||
entry.getLabel(),
|
||||
foregroundMs,
|
||||
foregroundServiceMs,
|
||||
backgroundMs));
|
||||
}
|
||||
if (entry.getConsumedPower() == 0
|
||||
&& foregroundMs == 0
|
||||
&& foregroundServiceMs == 0
|
||||
&& backgroundMs == 0) {
|
||||
continue;
|
||||
}
|
||||
valuesList.add(
|
||||
ConvertUtils.convertBatteryEntryToContentValues(
|
||||
entry,
|
||||
batteryUsageStats,
|
||||
batteryLevel,
|
||||
batteryStatus,
|
||||
batteryHealth,
|
||||
snapshotBootTimestamp,
|
||||
snapshotTimestamp,
|
||||
isFullChargeStart));
|
||||
}
|
||||
}
|
||||
|
||||
int size = 1;
|
||||
|
Reference in New Issue
Block a user