diff options
| author | Dmitri Plotnikov <dplotnikov@google.com> | 2021-03-08 20:17:48 -0800 |
|---|---|---|
| committer | Dmitri Plotnikov <dplotnikov@google.com> | 2021-03-08 20:17:48 -0800 |
| commit | 2d0ff3d3bda22d5c5ba5a5412b8d5612affdb4dc (patch) | |
| tree | e5896c0658535a51d8a7052f058330b9da031df7 /core/java | |
| parent | cf2929ffe94c4c8c9ff7848f8e30efcc23030d38 (diff) | |
Prevent crash when power profile has incorrect freq counts
Bug: 179750543
Test: build and launch Settings
Change-Id: I9ede5caf0001deff0067eabd9520af9d315ac95f
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/os/SystemServicePowerCalculator.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/SystemServicePowerCalculator.java b/core/java/com/android/internal/os/SystemServicePowerCalculator.java index 5c0eeb2f54f9..b4d5f97a14e7 100644 --- a/core/java/com/android/internal/os/SystemServicePowerCalculator.java +++ b/core/java/com/android/internal/os/SystemServicePowerCalculator.java @@ -134,7 +134,8 @@ public class SystemServicePowerCalculator extends PowerCalculator { // TODO(179210707): additionally account for CPU active and per cluster battery use double powerMah = 0; - for (int i = 0; i < mPowerEstimators.length; i++) { + final int size = Math.min(mPowerEstimators.length, systemServiceTimeAtCpuSpeeds.length); + for (int i = 0; i < size; i++) { powerMah += mPowerEstimators[i].calculatePower(systemServiceTimeAtCpuSpeeds[i]); } |
