Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbca76cd authored by Adam Lesinski's avatar Adam Lesinski Committed by Android Git Automerger
Browse files

am 1b57758a: Merge "Fix Array Index Out of Bounds in BatteryStatsImpl" into mnc-dr-dev

* commit '1b57758a':
  Fix Array Index Out of Bounds in BatteryStatsImpl
parents 9ce68b24 1b57758a
Loading
Loading
Loading
Loading
+13 −4
Original line number Original line Diff line number Diff line
@@ -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.
     * wakelocks. If the screen is on, we just assign the actual cpu time an app used.
     */
     */
    public void updateCpuTimeLocked() {
    public void updateCpuTimeLocked() {
        if (mPowerProfile == null) {
            return;
        }

        if (DEBUG_ENERGY_CPU) {
        if (DEBUG_ENERGY_CPU) {
            Slog.d(TAG, "!Cpu updating!");
            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
                        // Add the cpu speeds to this UID. These are used as a ratio
                        // for computing the power this UID used.
                        // for computing the power this UID used.
                        if (u.mCpuClusterSpeed == null) {
                        final int numClusters = mPowerProfile.getNumCpuClusters();
                            u.mCpuClusterSpeed = new LongSamplingCounter[clusterSpeeds.length][];
                        if (u.mCpuClusterSpeed == null || u.mCpuClusterSpeed.length !=
                                numClusters) {
                            u.mCpuClusterSpeed = new LongSamplingCounter[numClusters][];
                        }
                        }


                        for (int cluster = 0; cluster < clusterSpeeds.length; cluster++) {
                        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] =
                                u.mCpuClusterSpeed[cluster] =
                                        new LongSamplingCounter[clusterSpeeds[cluster].length];
                                        new LongSamplingCounter[speedsInCluster];
                            }
                            }


                            final LongSamplingCounter[] cpuSpeeds = u.mCpuClusterSpeed[cluster];
                            final LongSamplingCounter[] cpuSpeeds = u.mCpuClusterSpeed[cluster];