Merge "Fix mobile radio battery consumption double counting" into sc-v2-dev am: f709e34b90 am: 9d9976b68f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17206575 Change-Id: I9c301bd9e347fedaa1a04ce8f2e50fda402ece4d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -111,9 +111,9 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
|
||||
calculateApp(app, uid, total, query, keys);
|
||||
}
|
||||
|
||||
final long consumptionUC = batteryStats.getMobileRadioMeasuredBatteryConsumptionUC();
|
||||
final int powerModel = getPowerModel(consumptionUC, query);
|
||||
calculateRemaining(total, powerModel, batteryStats, rawRealtimeUs, consumptionUC);
|
||||
final long totalConsumptionUC = batteryStats.getMobileRadioMeasuredBatteryConsumptionUC();
|
||||
final int powerModel = getPowerModel(totalConsumptionUC, query);
|
||||
calculateRemaining(total, powerModel, batteryStats, rawRealtimeUs, totalConsumptionUC);
|
||||
|
||||
if (total.remainingPowerMah != 0 || total.totalAppPowerMah != 0) {
|
||||
builder.getAggregateBatteryConsumerBuilder(
|
||||
@@ -187,12 +187,13 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
|
||||
|
||||
private void calculateRemaining(PowerAndDuration total,
|
||||
@BatteryConsumer.PowerModel int powerModel, BatteryStats batteryStats,
|
||||
long rawRealtimeUs, long consumptionUC) {
|
||||
long rawRealtimeUs, long totalConsumptionUC) {
|
||||
long signalTimeMs = 0;
|
||||
double powerMah = 0;
|
||||
|
||||
if (powerModel == BatteryConsumer.POWER_MODEL_MEASURED_ENERGY) {
|
||||
powerMah = uCtoMah(consumptionUC);
|
||||
powerMah = uCtoMah(totalConsumptionUC) - total.totalAppPowerMah;
|
||||
if (powerMah < 0) powerMah = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_SIGNAL_STRENGTH_LEVELS; i++) {
|
||||
|
||||
@@ -269,8 +269,9 @@ public class MobileRadioPowerCalculatorTest {
|
||||
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
||||
|
||||
BatteryConsumer deviceConsumer = mStatsRule.getDeviceBatteryConsumer();
|
||||
// 10_000_000 micro-Coulomb * 1/1000 milli/micro * 1/3600 hour/second = 2.77778 mAh
|
||||
assertThat(deviceConsumer.getConsumedPower(BatteryConsumer.POWER_COMPONENT_MOBILE_RADIO))
|
||||
.isWithin(PRECISION).of(4.31711);
|
||||
.isWithin(PRECISION).of(2.77778);
|
||||
assertThat(deviceConsumer.getPowerModel(BatteryConsumer.POWER_COMPONENT_MOBILE_RADIO))
|
||||
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user