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

Commit 39b29bc2 authored by Hui Yu's avatar Hui Yu
Browse files

Calculate cellular radio value from modem.controller values.

Recently cellular radio related values {"radio.active", "radio.scanning",
"radio.on"} are removed from power_profile.xml, which causes inaccurate
radio power usage. We use following formula to calculate radio
values from modem.controller values.

radio.active = average of modem.controller.rx and modem.controller.tx values
radio.scanning = 0 (since this is already included in radio.on bin 0)
<array name="radio.on"> <!-- Strength 0 to BINS-1 -->
    <value>modem.controller.idle * 25 / 180 </value>   <!-- none -->
    <value>max(1, modem.controller.idle/256) </value>  <!-- poor -->
    <value>max(1, modem.controller.idle/256) </value>  <!-- moderate -->
    <value>max(1, modem.controller.idle/256) </value>  <!-- good -->
    <value>max(1, modem.controller.idle/256) </value>  <!-- great -->
 </array>

Bug: 79379255
Test:  use debugger to observe correct mPowerRadioOn, mPowerBins,
mPowerScan are calculated. "adb shell dumpsys batterystats", looking for
"radio=" in "Estimated power use" section.

Change-Id: Ic65a5c8a35a5b1f4ba05ddc150e29b00bc62689f
parent 57f6932f
Loading
Loading
Loading
Loading
+26 −4
Original line number Original line Diff line number Diff line
@@ -50,11 +50,33 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
    }
    }


    public MobileRadioPowerCalculator(PowerProfile profile, BatteryStats stats) {
    public MobileRadioPowerCalculator(PowerProfile profile, BatteryStats stats) {
        mPowerRadioOn = profile.getAveragePower(PowerProfile.POWER_RADIO_ACTIVE);
        double temp =
                profile.getAveragePowerOrDefault(PowerProfile.POWER_RADIO_ACTIVE, -1);
        if (temp != -1) {
            mPowerRadioOn = temp;
        } else {
            double sum = 0;
            sum += profile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_RX);
            for (int i = 0; i < mPowerBins.length; i++) {
                sum += profile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_TX, i);
            }
            mPowerRadioOn = sum / (mPowerBins.length + 1);
        }

        temp = profile.getAveragePowerOrDefault(PowerProfile.POWER_RADIO_ON, -1);
        if (temp != -1 ) {
            for (int i = 0; i < mPowerBins.length; i++) {
            for (int i = 0; i < mPowerBins.length; i++) {
                mPowerBins[i] = profile.getAveragePower(PowerProfile.POWER_RADIO_ON, i);
                mPowerBins[i] = profile.getAveragePower(PowerProfile.POWER_RADIO_ON, i);
            }
            }
        mPowerScan = profile.getAveragePower(PowerProfile.POWER_RADIO_SCANNING);
        } else {
            double idle = profile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_IDLE);
            mPowerBins[0] = idle * 25 / 180;
            for (int i = 1; i < mPowerBins.length; i++) {
                mPowerBins[i] = Math.max(1, idle / 256);
            }
        }

        mPowerScan = profile.getAveragePowerOrDefault(PowerProfile.POWER_RADIO_SCANNING, 0);
        mStats = stats;
        mStats = stats;
    }
    }