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

Commit 2038af88 authored by Siddharth Ray's avatar Siddharth Ray
Browse files

Cellular/Wifi power profile

- Added Cellular Energy Calculation
- Moved Wifi power profile to power_profile.xml

BUG:67213967

Test: Manual
Change-Id: I4b23b59fc6fa2461adc8ef6910d46b9f7ab02c83
parent 6e97afc1
Loading
Loading
Loading
Loading
+33 −20
Original line number Diff line number Diff line
@@ -11098,6 +11098,39 @@ public class BatteryStatsImpl extends BatteryStats {
                return;
            }
            if (activityInfo != null) {
                mHasModemReporting = true;
                mModemActivity.getIdleTimeCounter().addCountLocked(
                    activityInfo.getIdleTimeMillis());
                mModemActivity.getRxTimeCounter().addCountLocked(activityInfo.getRxTimeMillis());
                for (int lvl = 0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
                    mModemActivity.getTxTimeCounters()[lvl]
                        .addCountLocked(activityInfo.getTxTimeMillis()[lvl]);
                }
                // POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V.
                final double opVolt = mPowerProfile.getAveragePower(
                    PowerProfile.POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE) / 1000.0;
                if (opVolt != 0) {
                    double energyUsed =
                        activityInfo.getSleepTimeMillis() *
                            mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_SLEEP)
                            + activityInfo.getIdleTimeMillis() *
                            mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_IDLE)
                            + activityInfo.getRxTimeMillis() *
                            mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_RX);
                    int[] txCurrentMa = activityInfo.getTxTimeMillis();
                    for (int i = 0; i < Math.min(txCurrentMa.length,
                        SignalStrength.NUM_SIGNAL_STRENGTH_BINS); i++) {
                        energyUsed += txCurrentMa[i] * mPowerProfile.getAveragePower(
                            PowerProfile.POWER_MODEM_CONTROLLER_TX, i);
                    }
                    // We store the power drain as mAms.
                    mModemActivity.getPowerCounter().addCountLocked((long) energyUsed);
                }
            }
            final long elapsedRealtimeMs = mClocks.elapsedRealtime();
            long radioTime = mMobileRadioActivePerAppTimer.getTimeSinceMarkLocked(
                    elapsedRealtimeMs * 1000);
@@ -11196,26 +11229,6 @@ public class BatteryStatsImpl extends BatteryStats {
                mNetworkStatsPool.release(delta);
                delta = null;
            }
            if (activityInfo != null) {
                mHasModemReporting = true;
                mModemActivity.getIdleTimeCounter().addCountLocked(
                        activityInfo.getIdleTimeMillis());
                mModemActivity.getRxTimeCounter().addCountLocked(activityInfo.getRxTimeMillis());
                for (int lvl = 0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
                    mModemActivity.getTxTimeCounters()[lvl]
                            .addCountLocked(activityInfo.getTxTimeMillis()[lvl]);
                }
                // POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V.
                final double opVolt = mPowerProfile.getAveragePower(
                        PowerProfile.POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE) / 1000.0;
                if (opVolt != 0) {
                    // We store the power drain as mAms.
                    mModemActivity.getPowerCounter().addCountLocked(
                            (long) (activityInfo.getEnergyUsed() / opVolt));
                }
            }
        }
    }
+1 −8
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public class PowerProfile {
    public static final String POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE =
            "bluetooth.controller.voltage";

    public static final String POWER_MODEM_CONTROLLER_SLEEP = "modem.controller.sleep";
    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";
@@ -296,10 +297,6 @@ public class PowerProfile {
                com.android.internal.R.integer.config_bluetooth_rx_cur_ma,
                com.android.internal.R.integer.config_bluetooth_tx_cur_ma,
                com.android.internal.R.integer.config_bluetooth_operating_voltage_mv,
                com.android.internal.R.integer.config_wifi_idle_receive_cur_ma,
                com.android.internal.R.integer.config_wifi_active_rx_cur_ma,
                com.android.internal.R.integer.config_wifi_tx_cur_ma,
                com.android.internal.R.integer.config_wifi_operating_voltage_mv,
        };

        String[] configResIdKeys = new String[]{
@@ -307,10 +304,6 @@ public class PowerProfile {
                POWER_BLUETOOTH_CONTROLLER_RX,
                POWER_BLUETOOTH_CONTROLLER_TX,
                POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE,
                POWER_WIFI_CONTROLLER_IDLE,
                POWER_WIFI_CONTROLLER_RX,
                POWER_WIFI_CONTROLLER_TX,
                POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE,
        };

        for (int i = 0; i < configResIds.length; i++) {
+1 −13
Original line number Diff line number Diff line
@@ -646,18 +646,6 @@
    <!-- Wifi driver supports IEEE80211AC for softap -->
    <bool translatable="false" name="config_wifi_softap_ieee80211ac_supported">false</bool>
    
    <!-- Idle Receive current for wifi radio. 0 by default-->
    <integer translatable="false" name="config_wifi_idle_receive_cur_ma">0</integer>

    <!-- Rx current for wifi radio. 0 by default-->
    <integer translatable="false" name="config_wifi_active_rx_cur_ma">0</integer>

    <!-- Tx current for wifi radio. 0 by default-->
    <integer translatable="false" name="config_wifi_tx_cur_ma">0</integer>

    <!-- Operating volatage for wifi radio. 0 by default-->
    <integer translatable="false" name="config_wifi_operating_voltage_mv">0</integer>

    <!-- Flag indicating whether the we should enable the automatic brightness in Settings.
         Software implementation will be used if config_hardware_auto_brightness_available is not set -->
    <bool name="config_automatic_brightness_available">false</bool>
+0 −4
Original line number Diff line number Diff line
@@ -384,10 +384,6 @@
  <java-symbol type="integer" name="config_wifi_framework_current_network_boost" />
  <java-symbol type="string"  name="config_wifi_random_mac_oui" />
  <java-symbol type="integer"  name="config_wifi_network_switching_blacklist_time" />
  <java-symbol type="integer"  name="config_wifi_idle_receive_cur_ma" />
  <java-symbol type="integer"  name="config_wifi_active_rx_cur_ma" />
  <java-symbol type="integer"  name="config_wifi_tx_cur_ma" />
  <java-symbol type="integer"  name="config_wifi_operating_voltage_mv" />
  <java-symbol type="string"  name="config_wifi_framework_sap_2G_channel_list" />
  <java-symbol type="integer" name="config_wifi_framework_max_tx_rate_for_full_scan" />
  <java-symbol type="integer" name="config_wifi_framework_max_rx_rate_for_full_scan" />
+13 −9
Original line number Diff line number Diff line
@@ -51,15 +51,6 @@
      <value>0.1</value> <!-- ~1mA -->
  </array>


  <!-- Radio related values. For modems WITH energy reporting support in firmware, use
       modem.controller.idle, modem.controller.tx, modem.controller.rx, modem.controller.voltage.
       -->
  <item name="modem.controller.idle">0</item>
  <item name="modem.controller.rx">0</item>
  <item name="modem.controller.tx">0</item>
  <item name="modem.controller.voltage">0</item>

  <!-- A list of heterogeneous CPU clusters, where the value for each cluster represents the
       number of CPU cores for that cluster.

@@ -123,4 +114,17 @@
    <value>2</value>    <!-- 4097-/hr -->
  </array>

  <!-- Cellular modem related values. Default is 0.-->
  <item name="modem.controller.sleep">0</item>
  <item name="modem.controller.idle">0</item>
  <item name="modem.controller.rx">0</item>
  <array name="modem.controller.tx"> <!-- Strength 0 to 4 -->
    <value>0</value>
    <value>0</value>
    <value>0</value>
    <value>0</value>
    <value>0</value>
  </array>
  <item name="modem.controller.voltage">0</item>

</device>