diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2021-06-22 21:19:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-06-22 21:19:55 +0000 |
commit | cfc8359f34147b7fb75204d7d8f13b3e7a16af6d (patch) | |
tree | d4a59b5ac880a4f7e9d5c61dc742a621cf850a26 | |
parent | 0e7ef13b6a43139112bf6ca3a085a9c4e0fa0e72 (diff) | |
parent | 1beb4fcdbd1e82ba934ebcfacee626d7c16133ec (diff) | |
download | base-cfc8359f34147b7fb75204d7d8f13b3e7a16af6d.tar.gz |
Merge "Fix Bluetooth power accounting after a BT crash" into sc-dev
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 945a6ab11856..dab3e9fa15fa 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -12141,6 +12141,15 @@ public class BatteryStatsImpl extends BatteryStats { } } } + + void reset() { + idleTimeMs = 0; + rxTimeMs = 0; + txTimeMs = 0; + energy = 0; + uidRxBytes.clear(); + uidTxBytes.clear(); + } } private final BluetoothActivityInfoCache mLastBluetoothActivityInfo @@ -12167,6 +12176,15 @@ public class BatteryStatsImpl extends BatteryStats { mHasBluetoothReporting = true; + if (info.getControllerRxTimeMillis() < mLastBluetoothActivityInfo.rxTimeMs + || info.getControllerTxTimeMillis() < mLastBluetoothActivityInfo.txTimeMs + || info.getControllerIdleTimeMillis() < mLastBluetoothActivityInfo.idleTimeMs + || info.getControllerEnergyUsed() < mLastBluetoothActivityInfo.energy) { + // A drop in accumulated Bluetooth stats is a sign of a Bluetooth crash. + // Reset the preserved previous snapshot in order to restart accumulating deltas. + mLastBluetoothActivityInfo.reset(); + } + final long rxTimeMs = info.getControllerRxTimeMillis() - mLastBluetoothActivityInfo.rxTimeMs; final long txTimeMs = |