summaryrefslogtreecommitdiffstats
path: root/core/java/com/android
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-09-22 18:42:33 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-22 18:42:33 +0000
commitdbca76cda1a2a6fa95c592654f8649cb30b65833 (patch)
treed3f38fefc1d332f1723d3707cd4c3d9696ae4884 /core/java/com/android
parent9ce68b24440a7bc326cad2d09940ccf750eb2b2a (diff)
parent1b57758a1bb814c3a00ec864fe164bfe7861a9ab (diff)
downloadframeworks_base-dbca76cda1a2a6fa95c592654f8649cb30b65833.zip
frameworks_base-dbca76cda1a2a6fa95c592654f8649cb30b65833.tar.gz
frameworks_base-dbca76cda1a2a6fa95c592654f8649cb30b65833.tar.bz2
am 1b57758a: Merge "Fix Array Index Out of Bounds in BatteryStatsImpl" into mnc-dr-dev
* commit '1b57758a1bb814c3a00ec864fe164bfe7861a9ab': Fix Array Index Out of Bounds in BatteryStatsImpl
Diffstat (limited to 'core/java/com/android')
-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 6ccdd08..e39bf60 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];