diff options
| author | 2022-06-08 18:38:31 +0800 | |
|---|---|---|
| committer | 2022-06-16 17:45:53 +0000 | |
| commit | eecb54dfeb754bf1dd79233299db94ab5214b7ce (patch) | |
| tree | f80cd3c2d85eaf5065fcad509d62862049fa1471 | |
| parent | 6f701fe9fb3e26ffe22da909f6362b53516dd7b4 (diff) | |
BatteryStatsImpl: Add parcel methods for DisplayBatteryStats.
DisplayBatteryStats didn't have parcel methods and the estimated
multidisplay screen power was always initialized from 0.
The estimated screen power of the app will become inaccurate
after rebooting.
Bug: 235321975
Test: manual test.
1. Unplug the device.
2. Use an app for a while and keep screen on.
3. Capture the first bug report.
4. Reboot the device.
5. Capture the second bug report.
The estimated screen power of the app shouldn't become lower after rebooting the device.
Change-Id: I5d6ad56aa7e1dcd07994b1e1832c19c94e316b72
Merged-In: If74e285102a7350c17c2fc40a205b2031e82f5f4
| -rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index c9b652ca1142..da595fd099fa 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -160,7 +160,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version - static final int VERSION = 200; + static final int VERSION = 201; // The maximum number of names wakelocks we will keep track of // per uid; once the limit is reached, we batch the remaining wakelocks @@ -929,6 +929,28 @@ public class BatteryStatsImpl extends BatteryStats { screenBrightnessTimers[i].reset(false, elapsedRealtimeUs); } } + + /** + * Write data to summary parcel + */ + public void writeSummaryToParcel(Parcel out, long elapsedRealtimeUs) { + screenOnTimer.writeSummaryFromParcelLocked(out, elapsedRealtimeUs); + screenDozeTimer.writeSummaryFromParcelLocked(out, elapsedRealtimeUs); + for (int i = 0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) { + screenBrightnessTimers[i].writeSummaryFromParcelLocked(out, elapsedRealtimeUs); + } + } + + /** + * Read data from summary parcel + */ + public void readSummaryFromParcel(Parcel in) { + screenOnTimer.readSummaryFromParcelLocked(in); + screenDozeTimer.readSummaryFromParcelLocked(in); + for (int i = 0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) { + screenBrightnessTimers[i].readSummaryFromParcelLocked(in); + } + } } DisplayBatteryStats[] mPerDisplayBatteryStats; @@ -15627,6 +15649,10 @@ public class BatteryStatsImpl extends BatteryStats { for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { mScreenBrightnessTimer[i].readSummaryFromParcelLocked(in); } + final int numDisplays = in.readInt(); + for (int i = 0; i < numDisplays; i++) { + mPerDisplayBatteryStats[i].readSummaryFromParcel(in); + } mInteractive = false; mInteractiveTimer.readSummaryFromParcelLocked(in); mPhoneOn = false; @@ -16126,6 +16152,11 @@ public class BatteryStatsImpl extends BatteryStats { for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { mScreenBrightnessTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS); } + final int numDisplays = mPerDisplayBatteryStats.length; + out.writeInt(numDisplays); + for (int i = 0; i < numDisplays; i++) { + mPerDisplayBatteryStats[i].writeSummaryToParcel(out, NOWREAL_SYS); + } mInteractiveTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS); mPowerSaveModeEnabledTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS); out.writeLong(mLongestLightIdleTimeMs); |