From 79f08fb2511f23256a2ebe090c227a32198d2422 Mon Sep 17 00:00:00 2001 From: Tej Singh Date: Wed, 28 Jun 2023 23:57:49 -0700 Subject: [PATCH] Log plug state chage & other events at boot Logs plugged state changed, charging state changed, and battery level to statsd at boot. These events used to be logged at boot, but the logic was changed in ag/19715391. This is a partial revert of ag/19715391 to restore the logic to the old behavior. Bug: 289301086 Test: manually verified the atoms were logged at boot Change-Id: Ia5136531ec4fa1014b44bcf2701af543b66bfe45 Merged-In: Ia5136531ec4fa1014b44bcf2701af543b66bfe45 --- .../android/server/power/stats/BatteryStatsImpl.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java b/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java index 4a57592aa1aeb..27329e20bc8d9 100644 --- a/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java +++ b/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java @@ -14613,17 +14613,13 @@ public class BatteryStatsImpl extends BatteryStats { // Inform StatsLog of setBatteryState changes. private void reportChangesToStatsLog(final int status, final int plugType, final int level) { - if (!mHaveBatteryLevel) { - return; - } - - if (mBatteryStatus != status) { + if (!mHaveBatteryLevel || mBatteryStatus != status) { FrameworkStatsLog.write(FrameworkStatsLog.CHARGING_STATE_CHANGED, status); } - if (mBatteryPlugType != plugType) { + if (!mHaveBatteryLevel || mBatteryPlugType != plugType) { FrameworkStatsLog.write(FrameworkStatsLog.PLUGGED_STATE_CHANGED, plugType); } - if (mBatteryLevel != level) { + if (!mHaveBatteryLevel || mBatteryLevel != level) { FrameworkStatsLog.write(FrameworkStatsLog.BATTERY_LEVEL_CHANGED, level); } }