diff options
Diffstat (limited to 'com/android/internal/os/CpuPowerCalculator.java')
-rw-r--r-- | com/android/internal/os/CpuPowerCalculator.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/com/android/internal/os/CpuPowerCalculator.java b/com/android/internal/os/CpuPowerCalculator.java index bb743c15..a34e7f50 100644 --- a/com/android/internal/os/CpuPowerCalculator.java +++ b/com/android/internal/os/CpuPowerCalculator.java @@ -31,8 +31,7 @@ public class CpuPowerCalculator extends PowerCalculator { @Override public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, - long rawUptimeUs, int statsType) { - + long rawUptimeUs, int statsType) { app.cpuTimeMs = (u.getUserCpuTimeUs(statsType) + u.getSystemCpuTimeUs(statsType)) / 1000; final int numClusters = mProfile.getNumCpuClusters(); @@ -42,7 +41,7 @@ public class CpuPowerCalculator extends PowerCalculator { for (int speed = 0; speed < speedsForCluster; speed++) { final long timeUs = u.getTimeAtCpuSpeed(cluster, speed, statsType); final double cpuSpeedStepPower = timeUs * - mProfile.getAveragePowerForCpu(cluster, speed); + mProfile.getAveragePowerForCpuCore(cluster, speed); if (DEBUG) { Log.d(TAG, "UID " + u.getUid() + ": CPU cluster #" + cluster + " step #" + speed + " timeUs=" + timeUs + " power=" @@ -51,6 +50,25 @@ public class CpuPowerCalculator extends PowerCalculator { cpuPowerMaUs += cpuSpeedStepPower; } } + cpuPowerMaUs += u.getCpuActiveTime() * mProfile.getAveragePower( + PowerProfile.POWER_CPU_ACTIVE); + long[] cpuClusterTimes = u.getCpuClusterTimes(); + if (cpuClusterTimes != null) { + if (cpuClusterTimes.length == numClusters) { + for (int i = 0; i < numClusters; i++) { + double power = cpuClusterTimes[i] * mProfile.getAveragePowerForCpuCluster(i); + cpuPowerMaUs += power; + if (DEBUG) { + Log.d(TAG, "UID " + u.getUid() + ": CPU cluster #" + i + " clusterTimeUs=" + + cpuClusterTimes[i] + " power=" + + BatteryStatsHelper.makemAh(power / MICROSEC_IN_HR)); + } + } + } else { + Log.w(TAG, "UID " + u.getUid() + " CPU cluster # mismatch: Power Profile # " + + numClusters + " actual # " + cpuClusterTimes.length); + } + } app.cpuPowerMah = cpuPowerMaUs / MICROSEC_IN_HR; if (DEBUG && (app.cpuTimeMs != 0 || app.cpuPowerMah != 0)) { |