From d9f98565b26e6578d280fbac01730311e588e27a Mon Sep 17 00:00:00 2001 From: Adam Bookatz Date: Mon, 19 Apr 2021 19:20:59 -0700 Subject: [PATCH] Fix updateBluetoothStateLocked comments There was confusion as to whether updateBluetoothStateLocked took an ActivityInfo representing a cumulative total or a delta. It is confirmed that it is now a cumulative total. (It had been a delta in the past, but no longer.) Bug: 174818545 Test: N/A (just comments) Change-Id: I62130f22250eb496164f94c0668d1ff65fed7710 --- core/java/com/android/internal/os/BatteryStatsImpl.java | 5 +---- .../com/android/server/am/BatteryExternalStatsWorker.java | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index ac72d290b8b25..31fb806328e51 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -12070,7 +12070,7 @@ public class BatteryStatsImpl extends BatteryStats { /** * Distribute Bluetooth energy info and network traffic to apps. * - * @param info The energy information from the bluetooth controller. + * @param info The accumulated energy information from the bluetooth controller. */ public void updateBluetoothStateLocked(@Nullable final BluetoothActivityEnergyInfo info, final long consumedChargeUC, long elapsedRealtimeMs, long uptimeMs) { @@ -12082,9 +12082,6 @@ public class BatteryStatsImpl extends BatteryStats { return; } if (!mOnBatteryInternal || mIgnoreNextExternalStats) { - // TODO(174818545): mLastBluetoothActivityInfo is actually extremely suspicious. - // Firstly, the following line was originally missing. But even more so, BESW says that - // info is a delta, not a total, so this entire algorithm requires review. mLastBluetoothActivityInfo.set(info); return; } diff --git a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java index 60e8d54676ec0..99fcfa7a49aaf 100644 --- a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java +++ b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java @@ -137,8 +137,8 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { @GuardedBy("mWorkerLock") private PowerStatsInternal mPowerStatsInternal = null; - // WiFi keeps an accumulated total of stats, unlike Bluetooth. - // Keep the last WiFi stats so we can compute a delta. + // WiFi keeps an accumulated total of stats. Keep the last WiFi stats so we can compute a delta. + // (This is unlike Bluetooth, where BatteryStatsImpl is left responsible for taking the delta.) @GuardedBy("mWorkerLock") private WifiActivityEnergyInfo mLastWifiInfo = new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0);