diff options
| author | 2025-02-20 10:48:47 -0800 | |
|---|---|---|
| committer | 2025-02-20 10:49:28 -0800 | |
| commit | 38a4c123fd29f2694e628e2ee5a2a6c2eff89d72 (patch) | |
| tree | 0696f285b04b519f0a0ce6b246990058fb1a6955 | |
| parent | 9456c277e22d8310a5b9d1f34bca513809cb5322 (diff) | |
Fix initialization timing for MobileRadio energy consumer config
Bug: 397689294
Flag: EXEMPT bugfix
Test: atest PowerStatsTests;atest PowerStatsTestsRavenwood
Change-Id: I9b1f29eb0f05c234a95883fd2670cd395211f89b
| -rw-r--r-- | services/core/java/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessor.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessor.java b/services/core/java/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessor.java index ad628e4632e1..4344c32b897a 100644 --- a/services/core/java/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessor.java +++ b/services/core/java/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessor.java @@ -39,6 +39,21 @@ class PhoneCallPowerStatsProcessor extends PowerStatsProcessor { mTmpDeviceStats = new long[mDescriptor.statsArrayLength]; } + private boolean unpackMobileRadioStatsDescriptor(PowerStats.Descriptor descriptor) { + if (descriptor == null) { + return false; + } + + if (descriptor.equals(mMobileRadioStatsDescriptor)) { + return true; + } + + mMobileRadioStatsDescriptor = descriptor; + mMobileRadioStatsLayout = new MobileRadioPowerStatsLayout(mMobileRadioStatsDescriptor); + mTmpMobileRadioDeviceStats = new long[mMobileRadioStatsDescriptor.statsArrayLength]; + return true; + } + @Override void finish(PowerComponentAggregatedPowerStats stats, long timestampMs) { stats.setPowerStatsDescriptor(mDescriptor); @@ -50,16 +65,8 @@ class PhoneCallPowerStatsProcessor extends PowerStatsProcessor { return; } - if (mMobileRadioStatsDescriptor == null) { - mMobileRadioStatsDescriptor = mobileRadioStats.getPowerStatsDescriptor(); - if (mMobileRadioStatsDescriptor == null) { - return; - } - - mMobileRadioStatsLayout = - new MobileRadioPowerStatsLayout( - mMobileRadioStatsDescriptor); - mTmpMobileRadioDeviceStats = new long[mMobileRadioStatsDescriptor.statsArrayLength]; + if (!unpackMobileRadioStatsDescriptor(mobileRadioStats.getPowerStatsDescriptor())) { + return; } MultiStateStats.States[] deviceStateConfig = |