Android OS battery usage overstated by screen on time

Change-Id: Icbc4b3ecf91bdbb90da3ee0cf1c68bec953d0177
Signed-off-by: Todd Poynor <toddpoynor@google.com>
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 6312682..b813ec6 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -579,11 +579,12 @@
         if (osApp != null) {
             long wakeTimeMillis = mStats.computeBatteryUptime(
                     SystemClock.uptimeMillis() * 1000, which) / 1000;
-            wakeTimeMillis -= appWakelockTime - (mStats.getScreenOnTime(
+            wakeTimeMillis -= appWakelockTime + (mStats.getScreenOnTime(
                     SystemClock.elapsedRealtime(), which) / 1000);
             if (wakeTimeMillis > 0) {
                 double power = (wakeTimeMillis
                         * mPowerProfile.getAveragePower(PowerProfile.POWER_CPU_AWAKE)) / 1000;
+                if (DEBUG) Log.i(TAG, "OS wakeLockTime " + wakeTimeMillis + " power " + power);
                 osApp.wakeLockTime += wakeTimeMillis;
                 osApp.value += power;
                 osApp.values[0] += power;