Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d9976b6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix mobile radio battery consumption double counting" into sc-v2-dev am: f709e34b

parents d6272afe f709e34b
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -99,9 +99,9 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
            calculateApp(app, uid, powerPerPacketMah, total, query);
        }

        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(
@@ -229,12 +229,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++) {
+2 −1
Original line number Diff line number Diff line
@@ -176,8 +176,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);