summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/fuelgauge
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-10-03 18:34:27 -0700
committerDianne Hackborn <hackbod@google.com>2011-10-03 18:37:44 -0700
commitc174ec64f9cf7bbb8c1f2ff5b6c4168401d7c6cf (patch)
tree165b917f54f9663062f4009809d907d9ba6983c1 /src/com/android/settings/fuelgauge
parentdd98ff192cb0170927f58645591ac2d54d34cc65 (diff)
downloadpackages_apps_settings-c174ec64f9cf7bbb8c1f2ff5b6c4168401d7c6cf.zip
packages_apps_settings-c174ec64f9cf7bbb8c1f2ff5b6c4168401d7c6cf.tar.gz
packages_apps_settings-c174ec64f9cf7bbb8c1f2ff5b6c4168401d7c6cf.tar.bz2
Account for all wake lock usage.
Wake locks can be held outside of what we measure in battery stats, by things not going through the power manager. Account for this by computing the total wake time that is not covered by known wake locks and screen on time, and blame this on Android OS. Change-Id: Idf2907bc35f8c35f92155671c8dba521ae9ea804
Diffstat (limited to 'src/com/android/settings/fuelgauge')
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 6ff3e0e..41286ef 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -414,6 +414,8 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
}
final double averageCostPerByte = getAverageDataCost();
long uSecTime = mStats.computeBatteryRealtime(SystemClock.elapsedRealtime() * 1000, which);
+ long appWakelockTime = 0;
+ BatterySipper osApp = null;
mStatsPeriod = uSecTime;
SparseArray<? extends Uid> uidStats = mStats.getUidStats();
final int NU = uidStats.size();
@@ -488,6 +490,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
}
}
wakelockTime /= 1000; // convert to millis
+ appWakelockTime += wakelockTime;
// Add cost of holding a wake lock
power += (wakelockTime
@@ -535,7 +538,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
if (DEBUG) Log.i(TAG, "UID " + u.getUid() + ": power=" + power);
// Add the app to the list if it is consuming power
- if (power != 0) {
+ if (power != 0 || u.getUid() == 0) {
BatterySipper app = new BatterySipper(getActivity(), mRequestQueue, mHandler,
packageWithHighestDrain, DrainType.APP, 0, u,
new double[] {power});
@@ -553,6 +556,9 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
} else {
mUsageList.add(app);
}
+ if (u.getUid() == 0) {
+ osApp = app;
+ }
}
if (u.getUid() == Process.WIFI_UID) {
mWifiPower += power;
@@ -564,6 +570,25 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
}
if (DEBUG) Log.i(TAG, "Added power = " + power);
}
+
+ // The device has probably been awake for longer than the screen on
+ // time and application wake lock time would account for. Assign
+ // this remainder to the OS, if possible.
+ if (osApp != null) {
+ long wakeTimeMillis = mStats.computeBatteryUptime(
+ SystemClock.uptimeMillis() * 1000, which) / 1000;
+ wakeTimeMillis -= appWakelockTime - (mStats.getScreenOnTime(
+ SystemClock.elapsedRealtime(), which) / 1000);
+ if (wakeTimeMillis > 0) {
+ double power = (wakeTimeMillis
+ * mPowerProfile.getAveragePower(PowerProfile.POWER_CPU_AWAKE)) / 1000;
+ osApp.wakeLockTime += wakeTimeMillis;
+ osApp.value += power;
+ osApp.values[0] += power;
+ if (osApp.value > mMaxPower) mMaxPower = osApp.value;
+ mTotalPower += power;
+ }
+ }
}
private void addPhoneUsage(long uSecNow) {