summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2015-09-22 20:57:50 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-09-22 20:57:50 +0000
commitd548da799117a4b34ccfa57a3f9a535dbdba1da4 (patch)
treed64196d5cbfc4c375eaa7bd9a7822e3480566e92
parent5af7df9503e537d6834752084107b42b453cc4b3 (diff)
parent112c1dc63adbc36b1bd50dac24d1ea39959ef0f2 (diff)
am 112c1dc6: am 6a8d1fd6: am dbca76cd: am 1b57758a: Merge "Fix Array Index Out of Bounds in BatteryStatsImpl" into mnc-dr-dev
* commit '112c1dc63adbc36b1bd50dac24d1ea39959ef0f2': Fix Array Index Out of Bounds in BatteryStatsImpl
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 6ccdd08498ce..e39bf607e53e 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -8044,6 +8044,10 @@ public final class BatteryStatsImpl extends BatteryStats {
* wakelocks. If the screen is on, we just assign the actual cpu time an app used.
*/
public void updateCpuTimeLocked() {
+ if (mPowerProfile == null) {
+ return;
+ }
+
if (DEBUG_ENERGY_CPU) {
Slog.d(TAG, "!Cpu updating!");
}
@@ -8131,14 +8135,19 @@ public final class BatteryStatsImpl extends BatteryStats {
// Add the cpu speeds to this UID. These are used as a ratio
// for computing the power this UID used.
- if (u.mCpuClusterSpeed == null) {
- u.mCpuClusterSpeed = new LongSamplingCounter[clusterSpeeds.length][];
+ final int numClusters = mPowerProfile.getNumCpuClusters();
+ if (u.mCpuClusterSpeed == null || u.mCpuClusterSpeed.length !=
+ numClusters) {
+ u.mCpuClusterSpeed = new LongSamplingCounter[numClusters][];
}
for (int cluster = 0; cluster < clusterSpeeds.length; cluster++) {
- if (u.mCpuClusterSpeed[cluster] == null) {
+ final int speedsInCluster = mPowerProfile.getNumSpeedStepsInCpuCluster(
+ cluster);
+ if (u.mCpuClusterSpeed[cluster] == null || speedsInCluster !=
+ u.mCpuClusterSpeed[cluster].length) {
u.mCpuClusterSpeed[cluster] =
- new LongSamplingCounter[clusterSpeeds[cluster].length];
+ new LongSamplingCounter[speedsInCluster];
}
final LongSamplingCounter[] cpuSpeeds = u.mCpuClusterSpeed[cluster];