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

Commit 72c3927f authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge "Record ModemActivityInfo and distribute power blame to apps"

parents 104aff50 21f76aa7
Loading
Loading
Loading
Loading
+246 −188

File changed.

Preview size limit exceeded, changes collapsed.

+438 −189

File changed.

Preview size limit exceeded, changes collapsed.

+8 −8
Original line number Diff line number Diff line
@@ -40,15 +40,15 @@ public class BluetoothPowerCalculator extends PowerCalculator {
    @Override
    public void calculateRemaining(BatterySipper app, BatteryStats stats, long rawRealtimeUs,
                                   long rawUptimeUs, int statsType) {
        final long idleTimeMs = stats.getBluetoothControllerActivity(
                BatteryStats.CONTROLLER_IDLE_TIME, statsType);
        final long txTimeMs = stats.getBluetoothControllerActivity(
                BatteryStats.CONTROLLER_TX_TIME, statsType);
        final long rxTimeMs = stats.getBluetoothControllerActivity(
                BatteryStats.CONTROLLER_RX_TIME, statsType);
        final BatteryStats.ControllerActivityCounter counter =
                stats.getBluetoothControllerActivity();

        final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(statsType);
        final long txTimeMs = counter.getTxTimeCounters()[0].getCountLocked(statsType);
        final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(statsType);
        final long totalTimeMs = idleTimeMs + txTimeMs + rxTimeMs;
        double powerMah = stats.getBluetoothControllerActivity(
                BatteryStats.CONTROLLER_POWER_DRAIN, statsType) / (double)(1000*60*60);
        double powerMah = counter.getPowerCounter().getCountLocked(statsType)
                 / (double)(1000*60*60);

        if (powerMah == 0) {
            // Some devices do not report the power, so calculate it.
+12 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@ public class PowerProfile {
    public static final String POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE =
            "bluetooth.controller.voltage";

    public static final String POWER_MODEM_CONTROLLER_IDLE = "modem.controller.idle";
    public static final String POWER_MODEM_CONTROLLER_RX = "modem.controller.rx";
    public static final String POWER_MODEM_CONTROLLER_TX = "modem.controller.tx";
    public static final String POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE =
            "modem.controller.voltage";

    /**
     * Power consumption when GPS is on.
     */
@@ -100,17 +106,23 @@ public class PowerProfile {

    /**
     * Power consumption when Bluetooth driver is on.
     * @deprecated
     */
    @Deprecated
    public static final String POWER_BLUETOOTH_ON = "bluetooth.on";

    /**
     * Power consumption when Bluetooth driver is transmitting/receiving.
     * @deprecated
     */
    @Deprecated
    public static final String POWER_BLUETOOTH_ACTIVE = "bluetooth.active";

    /**
     * Power consumption when Bluetooth driver gets an AT command.
     * @deprecated
     */
    @Deprecated
    public static final String POWER_BLUETOOTH_AT_CMD = "bluetooth.at";


+15 −12
Original line number Diff line number Diff line
@@ -39,10 +39,14 @@ public class WifiPowerCalculator extends PowerCalculator {
    @Override
    public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs,
                             long rawUptimeUs, int statsType) {
        final long idleTime = u.getWifiControllerActivity(BatteryStats.CONTROLLER_IDLE_TIME,
                statsType);
        final long txTime = u.getWifiControllerActivity(BatteryStats.CONTROLLER_TX_TIME, statsType);
        final long rxTime = u.getWifiControllerActivity(BatteryStats.CONTROLLER_RX_TIME, statsType);
        final BatteryStats.ControllerActivityCounter counter = u.getWifiControllerActivity();
        if (counter == null) {
            return;
        }

        final long idleTime = counter.getIdleTimeCounter().getCountLocked(statsType);
        final long txTime = counter.getTxTimeCounters()[0].getCountLocked(statsType);
        final long rxTime = counter.getRxTimeCounter().getCountLocked(statsType);
        app.wifiRunningTimeMs = idleTime + rxTime + txTime;
        app.wifiPowerMah =
                ((idleTime * mIdleCurrentMa) + (txTime * mTxCurrentMa) + (rxTime * mRxCurrentMa))
@@ -67,16 +71,15 @@ public class WifiPowerCalculator extends PowerCalculator {
    @Override
    public void calculateRemaining(BatterySipper app, BatteryStats stats, long rawRealtimeUs,
                                   long rawUptimeUs, int statsType) {
        final long idleTimeMs = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_IDLE_TIME,
                statsType);
        final long rxTimeMs = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_RX_TIME,
                statsType);
        final long txTimeMs = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_TX_TIME,
                statsType);
        final BatteryStats.ControllerActivityCounter counter = stats.getWifiControllerActivity();

        final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(statsType);
        final long txTimeMs = counter.getTxTimeCounters()[0].getCountLocked(statsType);
        final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(statsType);
        app.wifiRunningTimeMs = idleTimeMs + rxTimeMs + txTimeMs;

        double powerDrainMah = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN,
                statsType) / (double)(1000*60*60);
        double powerDrainMah = counter.getPowerCounter().getCountLocked(statsType)
                / (double)(1000*60*60);
        if (powerDrainMah == 0) {
            // Some controllers do not report power drain, so we can calculate it here.
            powerDrainMah = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa)
Loading