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

Commit b82d3d7e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Calculate cellular radio value from modem.controller values." into pi-dev

parents 004e01d3 39b29bc2
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -50,11 +50,33 @@ public class MobileRadioPowerCalculator extends PowerCalculator {
    }

    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++) {
                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;
    }