Loading core/java/com/android/internal/os/BatteryStatsHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -354,9 +354,9 @@ public final class BatteryStatsHelper { if (mBluetoothPowerCalculator == null) { if (checkHasBluetoothPowerReporting(mStats, mPowerProfile)) { mBluetoothPowerCalculator = new BluetoothPowerCalculator(); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } else { mBluetoothPowerCalculator = new BluetoothPowerCalculator(); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } } mBluetoothPowerCalculator.reset(); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +12 −8 Original line number Diff line number Diff line Loading @@ -7814,11 +7814,13 @@ public final class BatteryStatsImpl extends BatteryStats { mWifiActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked( info.getControllerIdleTimeMillis()); final double opVoltage = mPowerProfile.getAveragePower( PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE); if (opVoltage != 0) { // POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V. final double opVolt = mPowerProfile.getAveragePower( PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE) / 1000.0; if (opVolt != 0) { // We store the power drain as mAms. mWifiActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked( (long)(info.getControllerEnergyUsed() / opVoltage)); (long)(info.getControllerEnergyUsed() / opVolt)); } } } Loading Loading @@ -7908,11 +7910,13 @@ public final class BatteryStatsImpl extends BatteryStats { mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked( info.getControllerIdleTimeMillis()); final double opVoltage = mPowerProfile.getAveragePower( PowerProfile.POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE); if (opVoltage != 0) { // POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V. final double opVolt = mPowerProfile.getAveragePower( PowerProfile.POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE) / 1000.0; if (opVolt != 0) { // We store the power drain as mAms. mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked( (long) (info.getControllerEnergyUsed() / opVoltage)); (long) (info.getControllerEnergyUsed() / opVolt)); } } } Loading core/java/com/android/internal/os/BluetoothPowerCalculator.java +17 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,15 @@ import android.util.Log; public class BluetoothPowerCalculator extends PowerCalculator { private static final boolean DEBUG = BatteryStatsHelper.DEBUG; private static final String TAG = "BluetoothPowerCalculator"; private final double mIdleMa; private final double mRxMa; private final double mTxMa; public BluetoothPowerCalculator(PowerProfile profile) { mIdleMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE); mRxMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_RX); mTxMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_TX); } @Override public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, Loading @@ -37,10 +46,15 @@ public class BluetoothPowerCalculator extends PowerCalculator { BatteryStats.CONTROLLER_TX_TIME, statsType); final long rxTimeMs = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_RX_TIME, statsType); final long powerMaMs = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_POWER_DRAIN, statsType); final double powerMah = powerMaMs / (double)(1000*60*60); final long totalTimeMs = idleTimeMs + txTimeMs + rxTimeMs; double powerMah = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_POWER_DRAIN, statsType) / (double)(1000*60*60); if (powerMah == 0) { // Some devices do not report the power, so calculate it. powerMah = ((idleTimeMs * mIdleMa) + (rxTimeMs * mRxMa) + (txTimeMs * mTxMa)) / (1000*60*60); } if (DEBUG && powerMah != 0) { Log.d(TAG, "Bluetooth active: time=" + (totalTimeMs) Loading core/java/com/android/internal/os/WifiPowerCalculator.java +4 −4 Original line number Diff line number Diff line Loading @@ -70,14 +70,14 @@ public class WifiPowerCalculator extends PowerCalculator { statsType); app.wifiRunningTimeMs = idleTimeMs + rxTimeMs + txTimeMs; double powerDrain = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN, double powerDrainMah = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN, statsType) / (double)(1000*60*60); if (powerDrain == 0) { if (powerDrainMah == 0) { // Some controllers do not report power drain, so we can calculate it here. powerDrain = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) powerDrainMah = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) + (rxTimeMs * mRxCurrentMa)) / (1000*60*60); } app.wifiPowerMah = Math.max(0, powerDrain - mTotalAppPowerDrain); app.wifiPowerMah = Math.max(0, powerDrainMah - mTotalAppPowerDrain); if (DEBUG) { Log.d(TAG, "left over WiFi power: " + BatteryStatsHelper.makemAh(app.wifiPowerMah)); Loading Loading
core/java/com/android/internal/os/BatteryStatsHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -354,9 +354,9 @@ public final class BatteryStatsHelper { if (mBluetoothPowerCalculator == null) { if (checkHasBluetoothPowerReporting(mStats, mPowerProfile)) { mBluetoothPowerCalculator = new BluetoothPowerCalculator(); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } else { mBluetoothPowerCalculator = new BluetoothPowerCalculator(); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } } mBluetoothPowerCalculator.reset(); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +12 −8 Original line number Diff line number Diff line Loading @@ -7814,11 +7814,13 @@ public final class BatteryStatsImpl extends BatteryStats { mWifiActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked( info.getControllerIdleTimeMillis()); final double opVoltage = mPowerProfile.getAveragePower( PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE); if (opVoltage != 0) { // POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V. final double opVolt = mPowerProfile.getAveragePower( PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE) / 1000.0; if (opVolt != 0) { // We store the power drain as mAms. mWifiActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked( (long)(info.getControllerEnergyUsed() / opVoltage)); (long)(info.getControllerEnergyUsed() / opVolt)); } } } Loading Loading @@ -7908,11 +7910,13 @@ public final class BatteryStatsImpl extends BatteryStats { mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked( info.getControllerIdleTimeMillis()); final double opVoltage = mPowerProfile.getAveragePower( PowerProfile.POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE); if (opVoltage != 0) { // POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE is measured in mV, so convert to V. final double opVolt = mPowerProfile.getAveragePower( PowerProfile.POWER_BLUETOOTH_CONTROLLER_OPERATING_VOLTAGE) / 1000.0; if (opVolt != 0) { // We store the power drain as mAms. mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked( (long) (info.getControllerEnergyUsed() / opVoltage)); (long) (info.getControllerEnergyUsed() / opVolt)); } } } Loading
core/java/com/android/internal/os/BluetoothPowerCalculator.java +17 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,15 @@ import android.util.Log; public class BluetoothPowerCalculator extends PowerCalculator { private static final boolean DEBUG = BatteryStatsHelper.DEBUG; private static final String TAG = "BluetoothPowerCalculator"; private final double mIdleMa; private final double mRxMa; private final double mTxMa; public BluetoothPowerCalculator(PowerProfile profile) { mIdleMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE); mRxMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_RX); mTxMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_TX); } @Override public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, Loading @@ -37,10 +46,15 @@ public class BluetoothPowerCalculator extends PowerCalculator { BatteryStats.CONTROLLER_TX_TIME, statsType); final long rxTimeMs = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_RX_TIME, statsType); final long powerMaMs = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_POWER_DRAIN, statsType); final double powerMah = powerMaMs / (double)(1000*60*60); final long totalTimeMs = idleTimeMs + txTimeMs + rxTimeMs; double powerMah = stats.getBluetoothControllerActivity( BatteryStats.CONTROLLER_POWER_DRAIN, statsType) / (double)(1000*60*60); if (powerMah == 0) { // Some devices do not report the power, so calculate it. powerMah = ((idleTimeMs * mIdleMa) + (rxTimeMs * mRxMa) + (txTimeMs * mTxMa)) / (1000*60*60); } if (DEBUG && powerMah != 0) { Log.d(TAG, "Bluetooth active: time=" + (totalTimeMs) Loading
core/java/com/android/internal/os/WifiPowerCalculator.java +4 −4 Original line number Diff line number Diff line Loading @@ -70,14 +70,14 @@ public class WifiPowerCalculator extends PowerCalculator { statsType); app.wifiRunningTimeMs = idleTimeMs + rxTimeMs + txTimeMs; double powerDrain = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN, double powerDrainMah = stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN, statsType) / (double)(1000*60*60); if (powerDrain == 0) { if (powerDrainMah == 0) { // Some controllers do not report power drain, so we can calculate it here. powerDrain = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) powerDrainMah = ((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) + (rxTimeMs * mRxCurrentMa)) / (1000*60*60); } app.wifiPowerMah = Math.max(0, powerDrain - mTotalAppPowerDrain); app.wifiPowerMah = Math.max(0, powerDrainMah - mTotalAppPowerDrain); if (DEBUG) { Log.d(TAG, "left over WiFi power: " + BatteryStatsHelper.makemAh(app.wifiPowerMah)); Loading