Loading core/java/android/os/BatteryStats.java +41 −3 Original line number Diff line number Diff line Loading @@ -146,6 +146,11 @@ public abstract class BatteryStats implements Parcelable { */ public static final int WAKE_TYPE_DRAW = 18; /** * A constant indicating a bluetooth scan timer. */ public static final int BLUETOOTH_SCAN_ON = 19; /** * Include all of the data in the stats, including previously saved data. */ Loading Loading @@ -438,6 +443,7 @@ public abstract class BatteryStats implements Parcelable { public abstract Timer getFlashlightTurnedOnTimer(); public abstract Timer getCameraTurnedOnTimer(); public abstract Timer getForegroundActivityTimer(); public abstract Timer getBluetoothScanTimer(); // Time this uid has any processes in the top state. public static final int PROCESS_STATE_TOP = 0; Loading Loading @@ -1179,6 +1185,7 @@ public abstract class BatteryStats implements Parcelable { public static final int STATE2_PHONE_IN_CALL_FLAG = 1<<23; public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<22; public static final int STATE2_CAMERA_FLAG = 1<<21; public static final int STATE2_BLUETOOTH_SCAN_FLAG = 1 << 20; public static final int MOST_INTERESTING_STATES2 = STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_MASK Loading Loading @@ -1922,6 +1929,7 @@ public abstract class BatteryStats implements Parcelable { HistoryItem.STATE2_WIFI_SUPPL_STATE_SHIFT, "wifi_suppl", "Wsp", WIFI_SUPPL_STATE_NAMES, WIFI_SUPPL_STATE_SHORT_NAMES), new BitDescription(HistoryItem.STATE2_CAMERA_FLAG, "camera", "ca"), new BitDescription(HistoryItem.STATE2_BLUETOOTH_SCAN_FLAG, "ble_scan", "bles"), }; public static final String[] HISTORY_EVENT_NAMES = new String[] { Loading Loading @@ -2041,6 +2049,13 @@ public abstract class BatteryStats implements Parcelable { */ public abstract long getCameraOnTime(long elapsedRealtimeUs, int which); /** * Returns the time in microseconds that bluetooth scans were running while the device was * on battery. * * {@hide} */ public abstract long getBluetoothScanTime(long elapsedRealtimeUs, int which); public static final int NETWORK_MOBILE_RX_DATA = 0; public static final int NETWORK_MOBILE_TX_DATA = 1; Loading Loading @@ -2797,9 +2812,12 @@ public abstract class BatteryStats implements Parcelable { final long mobileTxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); final long wifiRxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); final long wifiTxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); final long btRxTotalBytes = getNetworkActivityBytes(NETWORK_BT_RX_DATA, which); final long btTxTotalBytes = getNetworkActivityBytes(NETWORK_BT_TX_DATA, which); dumpLine(pw, 0 /* uid */, category, GLOBAL_NETWORK_DATA, mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets); mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets, btRxTotalBytes, btTxTotalBytes); // Dump Modem controller stats dumpControllerActivityLine(pw, 0 /* uid */, category, GLOBAL_MODEM_CONTROLLER_DATA, Loading Loading @@ -3017,14 +3035,18 @@ public abstract class BatteryStats implements Parcelable { final int mobileActiveCount = u.getMobileRadioActiveCount(which); final long wifiPacketsRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); final long wifiPacketsTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); final long btBytesRx = u.getNetworkActivityBytes(NETWORK_BT_RX_DATA, which); final long btBytesTx = u.getNetworkActivityBytes(NETWORK_BT_TX_DATA, which); if (mobileBytesRx > 0 || mobileBytesTx > 0 || wifiBytesRx > 0 || wifiBytesTx > 0 || mobilePacketsRx > 0 || mobilePacketsTx > 0 || wifiPacketsRx > 0 || wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0) { || wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0 || btBytesRx > 0 || btBytesTx > 0) { dumpLine(pw, uid, category, NETWORK_DATA, mobileBytesRx, mobileBytesTx, wifiBytesRx, wifiBytesTx, mobilePacketsRx, mobilePacketsTx, wifiPacketsRx, wifiPacketsTx, mobileActiveTime, mobileActiveCount); mobileActiveTime, mobileActiveCount, btBytesRx, btBytesTx); } // Dump modem controller data, per UID. Loading @@ -3046,6 +3068,9 @@ public abstract class BatteryStats implements Parcelable { dumpControllerActivityLine(pw, uid, category, WIFI_CONTROLLER_DATA, u.getWifiControllerActivity(), which); dumpControllerActivityLine(pw, uid, category, BLUETOOTH_CONTROLLER_DATA, u.getBluetoothControllerActivity(), which); if (u.hasUserActivity()) { args = new Object[Uid.NUM_USER_ACTIVITY_TYPES]; boolean hasData = false; Loading Loading @@ -3668,6 +3693,12 @@ public abstract class BatteryStats implements Parcelable { pw.print(" Bluetooth total received: "); pw.print(formatBytesLocked(btRxTotalBytes)); pw.print(", sent: "); pw.println(formatBytesLocked(btTxTotalBytes)); final long bluetoothScanTimeMs = getBluetoothScanTime(rawRealtime, which) / 1000; sb.setLength(0); sb.append(prefix); sb.append(" Bluetooth scan time: "); formatTimeMs(sb, bluetoothScanTimeMs); pw.println(sb.toString()); printControllerActivity(pw, sb, prefix, "Bluetooth", getBluetoothControllerActivity(), which); Loading Loading @@ -3793,6 +3824,10 @@ public abstract class BatteryStats implements Parcelable { pw.print(" wifi="); printmAh(pw, bs.wifiPowerMah); } if (bs.bluetoothPowerMah != 0) { pw.print(" bt="); printmAh(pw, bs.bluetoothPowerMah); } if (bs.gpsPowerMah != 0) { pw.print(" gps="); printmAh(pw, bs.gpsPowerMah); Loading Loading @@ -4035,6 +4070,9 @@ public abstract class BatteryStats implements Parcelable { pw.println(" sent"); } uidActivity |= printTimer(pw, sb, u.getBluetoothScanTimer(), rawRealtime, which, prefix, "Bluetooth Scan"); if (u.hasUserActivity()) { boolean hasData = false; for (int i=0; i<Uid.NUM_USER_ACTIVITY_TYPES; i++) { Loading core/java/com/android/internal/app/IBatteryStats.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -124,4 +124,5 @@ interface IBatteryStats { void noteBleScanStarted(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteResetBleScan(); } core/java/com/android/internal/os/BatterySipper.java +9 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class BatterySipper implements Comparable<BatterySipper> { public long wakeLockTimeMs; public long cameraTimeMs; public long flashlightTimeMs; public long bluetoothRunningTimeMs; public long mobileRxPackets; public long mobileTxPackets; Loading @@ -56,6 +57,8 @@ public class BatterySipper implements Comparable<BatterySipper> { public long mobileTxBytes; public long wifiRxBytes; public long wifiTxBytes; public long btRxBytes; public long btTxBytes; public double percent; public double noCoveragePercent; public String[] mPackages; Loading @@ -71,6 +74,7 @@ public class BatterySipper implements Comparable<BatterySipper> { public double sensorPowerMah; public double cameraPowerMah; public double flashlightPowerMah; public double bluetoothPowerMah; public enum DrainType { IDLE, Loading Loading @@ -142,6 +146,7 @@ public class BatterySipper implements Comparable<BatterySipper> { wakeLockTimeMs += other.wakeLockTimeMs; cameraTimeMs += other.cameraTimeMs; flashlightTimeMs += other.flashlightTimeMs; bluetoothRunningTimeMs += other.bluetoothRunningTimeMs; mobileRxPackets += other.mobileRxPackets; mobileTxPackets += other.mobileTxPackets; mobileActive += other.mobileActive; Loading @@ -152,6 +157,8 @@ public class BatterySipper implements Comparable<BatterySipper> { mobileTxBytes += other.mobileTxBytes; wifiRxBytes += other.wifiRxBytes; wifiTxBytes += other.wifiTxBytes; btRxBytes += other.btRxBytes; btTxBytes += other.btTxBytes; wifiPowerMah += other.wifiPowerMah; gpsPowerMah += other.gpsPowerMah; cpuPowerMah += other.cpuPowerMah; Loading @@ -160,6 +167,7 @@ public class BatterySipper implements Comparable<BatterySipper> { wakeLockPowerMah += other.wakeLockPowerMah; cameraPowerMah += other.cameraPowerMah; flashlightPowerMah += other.flashlightPowerMah; bluetoothPowerMah += other.bluetoothPowerMah; } /** Loading @@ -169,6 +177,6 @@ public class BatterySipper implements Comparable<BatterySipper> { public double sumPower() { return totalPowerMah = usagePowerMah + wifiPowerMah + gpsPowerMah + cpuPowerMah + sensorPowerMah + mobileRadioPowerMah + wakeLockPowerMah + cameraPowerMah + flashlightPowerMah; flashlightPowerMah + bluetoothPowerMah; } } core/java/com/android/internal/os/BatteryStatsImpl.java +303 −45 File changed.Preview size limit exceeded, changes collapsed. Show changes core/java/com/android/internal/os/BluetoothPowerCalculator.java +38 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ public class BluetoothPowerCalculator extends PowerCalculator { private final double mIdleMa; private final double mRxMa; private final double mTxMa; private double mAppTotalPowerMah = 0; private long mAppTotalTimeMs = 0; public BluetoothPowerCalculator(PowerProfile profile) { mIdleMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE); Loading @@ -34,7 +36,31 @@ public class BluetoothPowerCalculator extends PowerCalculator { @Override public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, long rawUptimeUs, int statsType) { // No per-app distribution yet. final BatteryStats.ControllerActivityCounter counter = u.getBluetoothControllerActivity(); if (counter == null) { return; } final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(statsType); final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(statsType); final long txTimeMs = counter.getTxTimeCounters()[0].getCountLocked(statsType); final long totalTimeMs = idleTimeMs + txTimeMs + rxTimeMs; double powerMah = counter.getPowerCounter().getCountLocked(statsType) / (double)(1000*60*60); if (powerMah == 0) { powerMah = ((idleTimeMs * mIdleMa) + (rxTimeMs * mRxMa) + (txTimeMs * mTxMa)) / (1000*60*60); } app.bluetoothPowerMah = powerMah; app.bluetoothRunningTimeMs = totalTimeMs; app.btRxBytes = u.getNetworkActivityBytes(BatteryStats.NETWORK_BT_RX_DATA, statsType); app.btTxBytes = u.getNetworkActivityBytes(BatteryStats.NETWORK_BT_TX_DATA, statsType); mAppTotalPowerMah += powerMah; mAppTotalTimeMs += totalTimeMs; } @Override Loading @@ -56,12 +82,21 @@ public class BluetoothPowerCalculator extends PowerCalculator { / (1000*60*60); } // Subtract what the apps used, but clamp to 0. powerMah = Math.max(0, powerMah - mAppTotalPowerMah); if (DEBUG && powerMah != 0) { Log.d(TAG, "Bluetooth active: time=" + (totalTimeMs) + " power=" + BatteryStatsHelper.makemAh(powerMah)); } app.usagePowerMah = powerMah; app.usageTimeMs = totalTimeMs; app.bluetoothPowerMah = powerMah; app.bluetoothRunningTimeMs = Math.max(0, totalTimeMs - mAppTotalTimeMs); } @Override public void reset() { mAppTotalPowerMah = 0; mAppTotalTimeMs = 0; } } Loading
core/java/android/os/BatteryStats.java +41 −3 Original line number Diff line number Diff line Loading @@ -146,6 +146,11 @@ public abstract class BatteryStats implements Parcelable { */ public static final int WAKE_TYPE_DRAW = 18; /** * A constant indicating a bluetooth scan timer. */ public static final int BLUETOOTH_SCAN_ON = 19; /** * Include all of the data in the stats, including previously saved data. */ Loading Loading @@ -438,6 +443,7 @@ public abstract class BatteryStats implements Parcelable { public abstract Timer getFlashlightTurnedOnTimer(); public abstract Timer getCameraTurnedOnTimer(); public abstract Timer getForegroundActivityTimer(); public abstract Timer getBluetoothScanTimer(); // Time this uid has any processes in the top state. public static final int PROCESS_STATE_TOP = 0; Loading Loading @@ -1179,6 +1185,7 @@ public abstract class BatteryStats implements Parcelable { public static final int STATE2_PHONE_IN_CALL_FLAG = 1<<23; public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<22; public static final int STATE2_CAMERA_FLAG = 1<<21; public static final int STATE2_BLUETOOTH_SCAN_FLAG = 1 << 20; public static final int MOST_INTERESTING_STATES2 = STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_MASK Loading Loading @@ -1922,6 +1929,7 @@ public abstract class BatteryStats implements Parcelable { HistoryItem.STATE2_WIFI_SUPPL_STATE_SHIFT, "wifi_suppl", "Wsp", WIFI_SUPPL_STATE_NAMES, WIFI_SUPPL_STATE_SHORT_NAMES), new BitDescription(HistoryItem.STATE2_CAMERA_FLAG, "camera", "ca"), new BitDescription(HistoryItem.STATE2_BLUETOOTH_SCAN_FLAG, "ble_scan", "bles"), }; public static final String[] HISTORY_EVENT_NAMES = new String[] { Loading Loading @@ -2041,6 +2049,13 @@ public abstract class BatteryStats implements Parcelable { */ public abstract long getCameraOnTime(long elapsedRealtimeUs, int which); /** * Returns the time in microseconds that bluetooth scans were running while the device was * on battery. * * {@hide} */ public abstract long getBluetoothScanTime(long elapsedRealtimeUs, int which); public static final int NETWORK_MOBILE_RX_DATA = 0; public static final int NETWORK_MOBILE_TX_DATA = 1; Loading Loading @@ -2797,9 +2812,12 @@ public abstract class BatteryStats implements Parcelable { final long mobileTxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); final long wifiRxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); final long wifiTxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); final long btRxTotalBytes = getNetworkActivityBytes(NETWORK_BT_RX_DATA, which); final long btTxTotalBytes = getNetworkActivityBytes(NETWORK_BT_TX_DATA, which); dumpLine(pw, 0 /* uid */, category, GLOBAL_NETWORK_DATA, mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets); mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets, btRxTotalBytes, btTxTotalBytes); // Dump Modem controller stats dumpControllerActivityLine(pw, 0 /* uid */, category, GLOBAL_MODEM_CONTROLLER_DATA, Loading Loading @@ -3017,14 +3035,18 @@ public abstract class BatteryStats implements Parcelable { final int mobileActiveCount = u.getMobileRadioActiveCount(which); final long wifiPacketsRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); final long wifiPacketsTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); final long btBytesRx = u.getNetworkActivityBytes(NETWORK_BT_RX_DATA, which); final long btBytesTx = u.getNetworkActivityBytes(NETWORK_BT_TX_DATA, which); if (mobileBytesRx > 0 || mobileBytesTx > 0 || wifiBytesRx > 0 || wifiBytesTx > 0 || mobilePacketsRx > 0 || mobilePacketsTx > 0 || wifiPacketsRx > 0 || wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0) { || wifiPacketsTx > 0 || mobileActiveTime > 0 || mobileActiveCount > 0 || btBytesRx > 0 || btBytesTx > 0) { dumpLine(pw, uid, category, NETWORK_DATA, mobileBytesRx, mobileBytesTx, wifiBytesRx, wifiBytesTx, mobilePacketsRx, mobilePacketsTx, wifiPacketsRx, wifiPacketsTx, mobileActiveTime, mobileActiveCount); mobileActiveTime, mobileActiveCount, btBytesRx, btBytesTx); } // Dump modem controller data, per UID. Loading @@ -3046,6 +3068,9 @@ public abstract class BatteryStats implements Parcelable { dumpControllerActivityLine(pw, uid, category, WIFI_CONTROLLER_DATA, u.getWifiControllerActivity(), which); dumpControllerActivityLine(pw, uid, category, BLUETOOTH_CONTROLLER_DATA, u.getBluetoothControllerActivity(), which); if (u.hasUserActivity()) { args = new Object[Uid.NUM_USER_ACTIVITY_TYPES]; boolean hasData = false; Loading Loading @@ -3668,6 +3693,12 @@ public abstract class BatteryStats implements Parcelable { pw.print(" Bluetooth total received: "); pw.print(formatBytesLocked(btRxTotalBytes)); pw.print(", sent: "); pw.println(formatBytesLocked(btTxTotalBytes)); final long bluetoothScanTimeMs = getBluetoothScanTime(rawRealtime, which) / 1000; sb.setLength(0); sb.append(prefix); sb.append(" Bluetooth scan time: "); formatTimeMs(sb, bluetoothScanTimeMs); pw.println(sb.toString()); printControllerActivity(pw, sb, prefix, "Bluetooth", getBluetoothControllerActivity(), which); Loading Loading @@ -3793,6 +3824,10 @@ public abstract class BatteryStats implements Parcelable { pw.print(" wifi="); printmAh(pw, bs.wifiPowerMah); } if (bs.bluetoothPowerMah != 0) { pw.print(" bt="); printmAh(pw, bs.bluetoothPowerMah); } if (bs.gpsPowerMah != 0) { pw.print(" gps="); printmAh(pw, bs.gpsPowerMah); Loading Loading @@ -4035,6 +4070,9 @@ public abstract class BatteryStats implements Parcelable { pw.println(" sent"); } uidActivity |= printTimer(pw, sb, u.getBluetoothScanTimer(), rawRealtime, which, prefix, "Bluetooth Scan"); if (u.hasUserActivity()) { boolean hasData = false; for (int i=0; i<Uid.NUM_USER_ACTIVITY_TYPES; i++) { Loading
core/java/com/android/internal/app/IBatteryStats.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -124,4 +124,5 @@ interface IBatteryStats { void noteBleScanStarted(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteResetBleScan(); }
core/java/com/android/internal/os/BatterySipper.java +9 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class BatterySipper implements Comparable<BatterySipper> { public long wakeLockTimeMs; public long cameraTimeMs; public long flashlightTimeMs; public long bluetoothRunningTimeMs; public long mobileRxPackets; public long mobileTxPackets; Loading @@ -56,6 +57,8 @@ public class BatterySipper implements Comparable<BatterySipper> { public long mobileTxBytes; public long wifiRxBytes; public long wifiTxBytes; public long btRxBytes; public long btTxBytes; public double percent; public double noCoveragePercent; public String[] mPackages; Loading @@ -71,6 +74,7 @@ public class BatterySipper implements Comparable<BatterySipper> { public double sensorPowerMah; public double cameraPowerMah; public double flashlightPowerMah; public double bluetoothPowerMah; public enum DrainType { IDLE, Loading Loading @@ -142,6 +146,7 @@ public class BatterySipper implements Comparable<BatterySipper> { wakeLockTimeMs += other.wakeLockTimeMs; cameraTimeMs += other.cameraTimeMs; flashlightTimeMs += other.flashlightTimeMs; bluetoothRunningTimeMs += other.bluetoothRunningTimeMs; mobileRxPackets += other.mobileRxPackets; mobileTxPackets += other.mobileTxPackets; mobileActive += other.mobileActive; Loading @@ -152,6 +157,8 @@ public class BatterySipper implements Comparable<BatterySipper> { mobileTxBytes += other.mobileTxBytes; wifiRxBytes += other.wifiRxBytes; wifiTxBytes += other.wifiTxBytes; btRxBytes += other.btRxBytes; btTxBytes += other.btTxBytes; wifiPowerMah += other.wifiPowerMah; gpsPowerMah += other.gpsPowerMah; cpuPowerMah += other.cpuPowerMah; Loading @@ -160,6 +167,7 @@ public class BatterySipper implements Comparable<BatterySipper> { wakeLockPowerMah += other.wakeLockPowerMah; cameraPowerMah += other.cameraPowerMah; flashlightPowerMah += other.flashlightPowerMah; bluetoothPowerMah += other.bluetoothPowerMah; } /** Loading @@ -169,6 +177,6 @@ public class BatterySipper implements Comparable<BatterySipper> { public double sumPower() { return totalPowerMah = usagePowerMah + wifiPowerMah + gpsPowerMah + cpuPowerMah + sensorPowerMah + mobileRadioPowerMah + wakeLockPowerMah + cameraPowerMah + flashlightPowerMah; flashlightPowerMah + bluetoothPowerMah; } }
core/java/com/android/internal/os/BatteryStatsImpl.java +303 −45 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/java/com/android/internal/os/BluetoothPowerCalculator.java +38 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ public class BluetoothPowerCalculator extends PowerCalculator { private final double mIdleMa; private final double mRxMa; private final double mTxMa; private double mAppTotalPowerMah = 0; private long mAppTotalTimeMs = 0; public BluetoothPowerCalculator(PowerProfile profile) { mIdleMa = profile.getAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE); Loading @@ -34,7 +36,31 @@ public class BluetoothPowerCalculator extends PowerCalculator { @Override public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, long rawUptimeUs, int statsType) { // No per-app distribution yet. final BatteryStats.ControllerActivityCounter counter = u.getBluetoothControllerActivity(); if (counter == null) { return; } final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(statsType); final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(statsType); final long txTimeMs = counter.getTxTimeCounters()[0].getCountLocked(statsType); final long totalTimeMs = idleTimeMs + txTimeMs + rxTimeMs; double powerMah = counter.getPowerCounter().getCountLocked(statsType) / (double)(1000*60*60); if (powerMah == 0) { powerMah = ((idleTimeMs * mIdleMa) + (rxTimeMs * mRxMa) + (txTimeMs * mTxMa)) / (1000*60*60); } app.bluetoothPowerMah = powerMah; app.bluetoothRunningTimeMs = totalTimeMs; app.btRxBytes = u.getNetworkActivityBytes(BatteryStats.NETWORK_BT_RX_DATA, statsType); app.btTxBytes = u.getNetworkActivityBytes(BatteryStats.NETWORK_BT_TX_DATA, statsType); mAppTotalPowerMah += powerMah; mAppTotalTimeMs += totalTimeMs; } @Override Loading @@ -56,12 +82,21 @@ public class BluetoothPowerCalculator extends PowerCalculator { / (1000*60*60); } // Subtract what the apps used, but clamp to 0. powerMah = Math.max(0, powerMah - mAppTotalPowerMah); if (DEBUG && powerMah != 0) { Log.d(TAG, "Bluetooth active: time=" + (totalTimeMs) + " power=" + BatteryStatsHelper.makemAh(powerMah)); } app.usagePowerMah = powerMah; app.usageTimeMs = totalTimeMs; app.bluetoothPowerMah = powerMah; app.bluetoothRunningTimeMs = Math.max(0, totalTimeMs - mAppTotalTimeMs); } @Override public void reset() { mAppTotalPowerMah = 0; mAppTotalTimeMs = 0; } }