Merge "Fix mobile radio battery consumption double counting" into sc-v2-dev am: f709e34b90
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17206575 Change-Id: I472e4dc6a9b0ae0f8f76e2b620ec59e53aba0b3a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -99,9 +99,9 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
|
|||||||
calculateApp(app, uid, powerPerPacketMah, total, query);
|
calculateApp(app, uid, powerPerPacketMah, total, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long consumptionUC = batteryStats.getMobileRadioMeasuredBatteryConsumptionUC();
|
final long totalConsumptionUC = batteryStats.getMobileRadioMeasuredBatteryConsumptionUC();
|
||||||
final int powerModel = getPowerModel(consumptionUC, query);
|
final int powerModel = getPowerModel(totalConsumptionUC, query);
|
||||||
calculateRemaining(total, powerModel, batteryStats, rawRealtimeUs, consumptionUC);
|
calculateRemaining(total, powerModel, batteryStats, rawRealtimeUs, totalConsumptionUC);
|
||||||
|
|
||||||
if (total.remainingPowerMah != 0 || total.totalAppPowerMah != 0) {
|
if (total.remainingPowerMah != 0 || total.totalAppPowerMah != 0) {
|
||||||
builder.getAggregateBatteryConsumerBuilder(
|
builder.getAggregateBatteryConsumerBuilder(
|
||||||
@@ -229,12 +229,13 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
|
|||||||
|
|
||||||
private void calculateRemaining(PowerAndDuration total,
|
private void calculateRemaining(PowerAndDuration total,
|
||||||
@BatteryConsumer.PowerModel int powerModel, BatteryStats batteryStats,
|
@BatteryConsumer.PowerModel int powerModel, BatteryStats batteryStats,
|
||||||
long rawRealtimeUs, long consumptionUC) {
|
long rawRealtimeUs, long totalConsumptionUC) {
|
||||||
long signalTimeMs = 0;
|
long signalTimeMs = 0;
|
||||||
double powerMah = 0;
|
double powerMah = 0;
|
||||||
|
|
||||||
if (powerModel == BatteryConsumer.POWER_MODEL_MEASURED_ENERGY) {
|
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++) {
|
for (int i = 0; i < NUM_SIGNAL_STRENGTH_LEVELS; i++) {
|
||||||
|
|||||||
@@ -176,8 +176,9 @@ public class MobileRadioPowerCalculatorTest {
|
|||||||
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
||||||
|
|
||||||
BatteryConsumer deviceConsumer = mStatsRule.getDeviceBatteryConsumer();
|
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))
|
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))
|
assertThat(deviceConsumer.getPowerModel(BatteryConsumer.POWER_COMPONENT_MOBILE_RADIO))
|
||||||
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
.isEqualTo(BatteryConsumer.POWER_MODEL_MEASURED_ENERGY);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user