Remove foreground_service_usage_time_in_ms field which has been merged
into background_usage_time_in_ms in the BatteryUsageStats (b/257392992). Test: make RunSettingsRoboTests + manual Bug: 258124768 Bug: 253553141 Change-Id: I0967eec0cbe6d0cb7a0535d744a1046dec1d267b
This commit is contained in:
@@ -629,7 +629,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
PowerGaugePreference preference, BatteryDiffEntry entry) {
|
||||
final long foregroundUsageTimeInMs = entry.mForegroundUsageTimeInMs;
|
||||
final long backgroundUsageTimeInMs = entry.mBackgroundUsageTimeInMs;
|
||||
// TODO: update this value after the new API for foreground service is completed.
|
||||
final long totalUsageTimeInMs = foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
||||
String usageTimeSummary = null;
|
||||
// Not shows summary for some system components without usage time.
|
||||
|
@@ -52,7 +52,6 @@ public class BatteryDiffEntry {
|
||||
(a, b) -> Double.compare(b.getPercentOfTotal(), a.getPercentOfTotal());
|
||||
|
||||
public long mForegroundUsageTimeInMs;
|
||||
public long mForegroundServiceUsageTimeInMs;
|
||||
public long mBackgroundUsageTimeInMs;
|
||||
public double mConsumePower;
|
||||
public double mForegroundUsageConsumePower;
|
||||
@@ -83,7 +82,6 @@ public class BatteryDiffEntry {
|
||||
public BatteryDiffEntry(
|
||||
Context context,
|
||||
long foregroundUsageTimeInMs,
|
||||
long foregroundServiceUsageTimeInMs,
|
||||
long backgroundUsageTimeInMs,
|
||||
double consumePower,
|
||||
double foregroundUsageConsumePower,
|
||||
@@ -98,7 +96,6 @@ public class BatteryDiffEntry {
|
||||
mBackgroundUsageConsumePower = backgroundUsageConsumePower;
|
||||
mCachedUsageConsumePower = cachedUsageConsumePower;
|
||||
mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
|
||||
mForegroundServiceUsageTimeInMs = foregroundServiceUsageTimeInMs;
|
||||
mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
|
||||
mBatteryHistEntry = batteryHistEntry;
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
@@ -121,7 +118,6 @@ public class BatteryDiffEntry {
|
||||
return new BatteryDiffEntry(
|
||||
this.mContext,
|
||||
this.mForegroundUsageTimeInMs,
|
||||
this.mForegroundServiceUsageTimeInMs,
|
||||
this.mBackgroundUsageTimeInMs,
|
||||
this.mConsumePower,
|
||||
this.mForegroundUsageConsumePower,
|
||||
@@ -385,14 +381,9 @@ public class BatteryDiffEntry {
|
||||
mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
|
||||
.append(String.format("\n\tconsume power= background:%f cached:%f",
|
||||
mBackgroundUsageConsumePower, mCachedUsageConsumePower))
|
||||
.append(String.format("\n\ttime= foreground:%s foregroundService:%s background:%s",
|
||||
.append(String.format("\n\ttime= foreground:%s background:%s",
|
||||
StringUtil.formatElapsedTime(mContext, (double) mForegroundUsageTimeInMs,
|
||||
/*withSeconds=*/ true, /*collapseTimeUnit=*/ false),
|
||||
StringUtil.formatElapsedTime(
|
||||
mContext,
|
||||
(double) mForegroundServiceUsageTimeInMs,
|
||||
/*withSeconds=*/ true,
|
||||
/*collapseTimeUnit=*/ false),
|
||||
StringUtil.formatElapsedTime(mContext, (double) mBackgroundUsageTimeInMs,
|
||||
/*withSeconds=*/ true, /*collapseTimeUnit=*/ false)))
|
||||
.append(String.format("\n\tpackage:%s|%s uid:%d userId:%d",
|
||||
|
@@ -112,7 +112,6 @@ public class BatteryEntry {
|
||||
private final int mPowerComponentId;
|
||||
private long mUsageDurationMs;
|
||||
private long mTimeInForegroundMs;
|
||||
private long mTimeInForegroundServiceMs;
|
||||
private long mTimeInBackgroundMs;
|
||||
|
||||
public String mName;
|
||||
@@ -176,9 +175,6 @@ public class BatteryEntry {
|
||||
getQuickNameIconForUid(uid, packages, loadDataInBackground);
|
||||
mTimeInForegroundMs =
|
||||
uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
|
||||
//TODO: update this to the correct API after the new API is completed.
|
||||
mTimeInForegroundServiceMs =
|
||||
uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
|
||||
mTimeInBackgroundMs =
|
||||
uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_BACKGROUND);
|
||||
mConsumedPowerInForeground = safeGetConsumedPower(
|
||||
@@ -436,15 +432,6 @@ public class BatteryEntry {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns foreground service time/ms that is attributed to this entry. */
|
||||
public long getTimeInForegroundServiceMs() {
|
||||
if (mBatteryConsumer instanceof UidBatteryConsumer) {
|
||||
return mTimeInForegroundServiceMs;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns background activity time/ms that is attributed to this entry. */
|
||||
public long getTimeInBackgroundMs() {
|
||||
if (mBatteryConsumer instanceof UidBatteryConsumer) {
|
||||
@@ -518,9 +505,6 @@ public class BatteryEntry {
|
||||
UidBatteryConsumer uidBatteryConsumer = (UidBatteryConsumer) batteryConsumer;
|
||||
mTimeInForegroundMs += uidBatteryConsumer.getTimeInStateMs(
|
||||
UidBatteryConsumer.STATE_FOREGROUND);
|
||||
//TODO: update this to the correct API after the new API is completed.
|
||||
mTimeInForegroundServiceMs += uidBatteryConsumer.getTimeInStateMs(
|
||||
UidBatteryConsumer.STATE_FOREGROUND);
|
||||
mTimeInBackgroundMs += uidBatteryConsumer.getTimeInStateMs(
|
||||
UidBatteryConsumer.STATE_BACKGROUND);
|
||||
mConsumedPowerInForeground += safeGetConsumedPower(
|
||||
|
@@ -56,7 +56,6 @@ public class BatteryHistEntry {
|
||||
public final double mCachedUsageConsumePower;
|
||||
public final double mPercentOfTotal;
|
||||
public final long mForegroundUsageTimeInMs;
|
||||
public final long mForegroundServiceUsageTimeInMs;
|
||||
public final long mBackgroundUsageTimeInMs;
|
||||
@BatteryConsumer.PowerComponent
|
||||
public final int mDrainType;
|
||||
@@ -91,7 +90,6 @@ public class BatteryHistEntry {
|
||||
mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
|
||||
mPercentOfTotal = batteryInformation.getPercentOfTotal();
|
||||
mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
|
||||
mForegroundServiceUsageTimeInMs = batteryInformation.getForegroundServiceUsageTimeInMs();
|
||||
mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
|
||||
mDrainType = batteryInformation.getDrainType();
|
||||
final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
|
||||
@@ -121,7 +119,6 @@ public class BatteryHistEntry {
|
||||
mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
|
||||
mPercentOfTotal = batteryInformation.getPercentOfTotal();
|
||||
mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
|
||||
mForegroundServiceUsageTimeInMs = batteryInformation.getForegroundServiceUsageTimeInMs();
|
||||
mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
|
||||
mDrainType = batteryInformation.getDrainType();
|
||||
final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
|
||||
@@ -141,7 +138,6 @@ public class BatteryHistEntry {
|
||||
double backgroundUsageConsumePower,
|
||||
double cachedUsageConsumePower,
|
||||
long foregroundUsageTimeInMs,
|
||||
long foregroundServiceUsageTimeInMs,
|
||||
long backgroundUsageTimeInMs,
|
||||
int batteryLevel) {
|
||||
mUid = fromEntry.mUid;
|
||||
@@ -160,7 +156,6 @@ public class BatteryHistEntry {
|
||||
mCachedUsageConsumePower = cachedUsageConsumePower;
|
||||
mPercentOfTotal = fromEntry.mPercentOfTotal;
|
||||
mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
|
||||
mForegroundServiceUsageTimeInMs = foregroundServiceUsageTimeInMs;
|
||||
mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
|
||||
mDrainType = fromEntry.mDrainType;
|
||||
mConsumerType = fromEntry.mConsumerType;
|
||||
@@ -223,9 +218,8 @@ public class BatteryHistEntry {
|
||||
mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
|
||||
.append(String.format("\n\tbackground=%f|cached=%f",
|
||||
mBackgroundUsageConsumePower, mCachedUsageConsumePower))
|
||||
.append(String.format("\n\telapsedTime=%d|%d|%d",
|
||||
.append(String.format("\n\telapsedTime=%d|%d",
|
||||
Duration.ofMillis(mForegroundUsageTimeInMs).getSeconds(),
|
||||
Duration.ofMillis(mForegroundServiceUsageTimeInMs).getSeconds(),
|
||||
Duration.ofMillis(mBackgroundUsageTimeInMs).getSeconds()))
|
||||
.append(String.format("\n\tdrainType=%d|consumerType=%d",
|
||||
mDrainType, mConsumerType))
|
||||
@@ -320,12 +314,6 @@ public class BatteryHistEntry {
|
||||
(double) (lowerHistEntry == null ? 0 : lowerHistEntry.mForegroundUsageTimeInMs),
|
||||
(double) upperHistEntry.mForegroundUsageTimeInMs,
|
||||
ratio);
|
||||
final double foregroundServiceUsageTimeInMs = interpolate(
|
||||
(double) (lowerHistEntry == null
|
||||
? 0
|
||||
: lowerHistEntry.mForegroundServiceUsageTimeInMs),
|
||||
(double) upperHistEntry.mForegroundServiceUsageTimeInMs,
|
||||
ratio);
|
||||
final double backgroundUsageTimeInMs = interpolate(
|
||||
(double) (lowerHistEntry == null ? 0 : lowerHistEntry.mBackgroundUsageTimeInMs),
|
||||
(double) upperHistEntry.mBackgroundUsageTimeInMs,
|
||||
@@ -338,7 +326,6 @@ public class BatteryHistEntry {
|
||||
|| upperHistEntry.mBackgroundUsageConsumePower < backgroundUsageConsumePower
|
||||
|| upperHistEntry.mCachedUsageConsumePower < cachedUsageConsumePower
|
||||
|| upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
|
||||
|| upperHistEntry.mForegroundServiceUsageTimeInMs < foregroundServiceUsageTimeInMs
|
||||
|| upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, String.format(
|
||||
@@ -365,7 +352,6 @@ public class BatteryHistEntry {
|
||||
backgroundUsageConsumePower,
|
||||
cachedUsageConsumePower,
|
||||
Math.round(foregroundUsageTimeInMs),
|
||||
Math.round(foregroundServiceUsageTimeInMs),
|
||||
Math.round(backgroundUsageTimeInMs),
|
||||
(int) Math.round(batteryLevel));
|
||||
}
|
||||
|
@@ -219,7 +219,6 @@ public final class ConvertUtils {
|
||||
.setPercentOfTotal(entry.mPercent)
|
||||
.setDrainType(entry.getPowerComponentId())
|
||||
.setForegroundUsageTimeInMs(entry.getTimeInForegroundMs())
|
||||
.setForegroundServiceUsageTimeInMs(entry.getTimeInForegroundServiceMs())
|
||||
.setBackgroundUsageTimeInMs(entry.getTimeInBackgroundMs());
|
||||
}
|
||||
|
||||
|
@@ -479,7 +479,6 @@ public final class DataProcessor {
|
||||
final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
|
||||
context,
|
||||
entry.mForegroundUsageTimeInMs,
|
||||
entry.mForegroundServiceUsageTimeInMs,
|
||||
entry.mBackgroundUsageTimeInMs,
|
||||
entry.mConsumePower,
|
||||
entry.mForegroundUsageConsumePower,
|
||||
@@ -573,12 +572,10 @@ public final class DataProcessor {
|
||||
return batteryEntryList.stream()
|
||||
.filter(entry -> {
|
||||
final long foregroundMs = entry.getTimeInForegroundMs();
|
||||
final long foregroundServiceMs = entry.getTimeInForegroundServiceMs();
|
||||
final long backgroundMs = entry.getTimeInBackgroundMs();
|
||||
return entry.getConsumedPower() > 0
|
||||
|| (entry.getConsumedPower() == 0
|
||||
&& (foregroundMs != 0 || foregroundServiceMs != 0
|
||||
|| backgroundMs != 0));
|
||||
&& (foregroundMs != 0 || backgroundMs != 0));
|
||||
})
|
||||
.map(entry -> ConvertUtils.convertToBatteryHistEntry(
|
||||
entry,
|
||||
@@ -699,14 +696,9 @@ public final class DataProcessor {
|
||||
if (lowerEntry != null) {
|
||||
final boolean invalidForegroundUsageTime =
|
||||
lowerEntry.mForegroundUsageTimeInMs > upperEntry.mForegroundUsageTimeInMs;
|
||||
final boolean invalidForegroundServiceUsageTime =
|
||||
lowerEntry.mForegroundServiceUsageTimeInMs
|
||||
> upperEntry.mForegroundServiceUsageTimeInMs;
|
||||
final boolean invalidBackgroundUsageTime =
|
||||
lowerEntry.mBackgroundUsageTimeInMs > upperEntry.mBackgroundUsageTimeInMs;
|
||||
if (invalidForegroundUsageTime
|
||||
|| invalidForegroundServiceUsageTime
|
||||
|| invalidBackgroundUsageTime) {
|
||||
if (invalidForegroundUsageTime || invalidBackgroundUsageTime) {
|
||||
newHistEntryMap.put(entryKey, upperEntry);
|
||||
log(context, "abnormal reset condition is found", currentSlot, upperEntry);
|
||||
continue;
|
||||
@@ -937,11 +929,6 @@ public final class DataProcessor {
|
||||
currentEntry.mForegroundUsageTimeInMs,
|
||||
nextEntry.mForegroundUsageTimeInMs,
|
||||
nextTwoEntry.mForegroundUsageTimeInMs);
|
||||
long foregroundServiceUsageTimeInMs =
|
||||
getDiffValue(
|
||||
currentEntry.mForegroundServiceUsageTimeInMs,
|
||||
nextEntry.mForegroundServiceUsageTimeInMs,
|
||||
nextTwoEntry.mForegroundServiceUsageTimeInMs);
|
||||
long backgroundUsageTimeInMs =
|
||||
getDiffValue(
|
||||
currentEntry.mBackgroundUsageTimeInMs,
|
||||
@@ -974,7 +961,6 @@ public final class DataProcessor {
|
||||
nextTwoEntry.mCachedUsageConsumePower);
|
||||
// Excludes entry since we don't have enough data to calculate.
|
||||
if (foregroundUsageTimeInMs == 0
|
||||
&& foregroundServiceUsageTimeInMs == 0
|
||||
&& backgroundUsageTimeInMs == 0
|
||||
&& consumePower == 0) {
|
||||
continue;
|
||||
@@ -986,7 +972,6 @@ public final class DataProcessor {
|
||||
}
|
||||
// Forces refine the cumulative value since it may introduce deviation error since we
|
||||
// will apply the interpolation arithmetic.
|
||||
// TODO: update this value after the new API for foreground service is completed.
|
||||
final float totalUsageTimeInMs =
|
||||
foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
||||
if (totalUsageTimeInMs > TOTAL_HOURLY_TIME_THRESHOLD) {
|
||||
@@ -999,8 +984,6 @@ public final class DataProcessor {
|
||||
}
|
||||
foregroundUsageTimeInMs =
|
||||
Math.round(foregroundUsageTimeInMs * ratio);
|
||||
foregroundServiceUsageTimeInMs =
|
||||
Math.round(foregroundServiceUsageTimeInMs * ratio);
|
||||
backgroundUsageTimeInMs =
|
||||
Math.round(backgroundUsageTimeInMs * ratio);
|
||||
consumePower = consumePower * ratio;
|
||||
@@ -1019,7 +1002,6 @@ public final class DataProcessor {
|
||||
final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
|
||||
context,
|
||||
foregroundUsageTimeInMs,
|
||||
foregroundServiceUsageTimeInMs,
|
||||
backgroundUsageTimeInMs,
|
||||
consumePower,
|
||||
foregroundUsageConsumePower,
|
||||
@@ -1105,8 +1087,6 @@ public final class DataProcessor {
|
||||
// Sums up some field data into the existing one.
|
||||
oldBatteryDiffEntry.mForegroundUsageTimeInMs +=
|
||||
entry.mForegroundUsageTimeInMs;
|
||||
oldBatteryDiffEntry.mForegroundServiceUsageTimeInMs +=
|
||||
entry.mForegroundServiceUsageTimeInMs;
|
||||
oldBatteryDiffEntry.mBackgroundUsageTimeInMs +=
|
||||
entry.mBackgroundUsageTimeInMs;
|
||||
oldBatteryDiffEntry.mConsumePower += entry.mConsumePower;
|
||||
@@ -1404,7 +1384,6 @@ public final class DataProcessor {
|
||||
final BatteryDiffEntry batteryDiffEntry = new BatteryDiffEntry(
|
||||
context,
|
||||
/*foregroundUsageTimeInMs=*/ 0,
|
||||
/*foregroundServiceUsageTimeInMs=*/ 0,
|
||||
/*backgroundUsageTimeInMs=*/ 0,
|
||||
consumePower,
|
||||
/*foregroundUsageConsumePower=*/ 0,
|
||||
|
@@ -165,20 +165,16 @@ public final class DatabaseUtils {
|
||||
batteryEntryList.stream()
|
||||
.filter(entry -> {
|
||||
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));
|
||||
"no consumed power but has running time for %s time=%d|%d",
|
||||
entry.getLabel(), foregroundMs, backgroundMs));
|
||||
}
|
||||
return entry.getConsumedPower() != 0
|
||||
|| foregroundMs != 0
|
||||
|| foregroundServiceMs != 0
|
||||
|| backgroundMs != 0;
|
||||
})
|
||||
.forEach(entry -> valuesList.add(
|
||||
|
@@ -31,10 +31,9 @@ message BatteryInformation {
|
||||
optional double percent_of_total = 12;
|
||||
optional int32 drain_type = 13;
|
||||
optional int64 foreground_usage_time_in_ms = 14;
|
||||
optional int64 foreground_service_usage_time_in_ms = 15;
|
||||
optional int64 background_usage_time_in_ms = 16;
|
||||
optional double foreground_usage_consume_power = 17;
|
||||
optional double foreground_service_usage_consume_power = 18;
|
||||
optional double background_usage_consume_power = 19;
|
||||
optional double cached_usage_consume_power = 20;
|
||||
optional int64 background_usage_time_in_ms = 15;
|
||||
optional double foreground_usage_consume_power = 16;
|
||||
optional double foreground_service_usage_consume_power = 17;
|
||||
optional double background_usage_consume_power = 18;
|
||||
optional double cached_usage_consume_power = 19;
|
||||
}
|
Reference in New Issue
Block a user