diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-06-19 21:13:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-19 21:13:43 +0000 |
commit | b6a092990cd9076f860ef1d97ef50a668c3d7a5b (patch) | |
tree | 17abe02da5cd5ffebf4d6a4b7628f8d644f55bd5 /core | |
parent | a309f4a04199e935c60b91d3ac9565cbbee600ee (diff) | |
parent | 9425fe21c9a8ab894e4a3b12a418564c4349394e (diff) | |
download | frameworks_base-b6a092990cd9076f860ef1d97ef50a668c3d7a5b.zip frameworks_base-b6a092990cd9076f860ef1d97ef50a668c3d7a5b.tar.gz frameworks_base-b6a092990cd9076f860ef1d97ef50a668c3d7a5b.tar.bz2 |
Merge "BatteryStats: Record doze wake locks" into mnc-dev
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/BatteryStats.java | 32 | ||||
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 40 |
2 files changed, 59 insertions, 13 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index eb6e1c2..593f804 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -65,7 +65,7 @@ public abstract class BatteryStats implements Parcelable { * A constant indicating a window wake lock timer. */ public static final int WAKE_TYPE_WINDOW = 2; - + /** * A constant indicating a sensor timer. */ @@ -142,6 +142,11 @@ public abstract class BatteryStats implements Parcelable { public static final int CAMERA_TURNED_ON = 17; /** + * A constant indicating a doze wake lock timer. + */ + public static final int WAKE_TYPE_DOZE = 18; + + /** * Include all of the data in the stats, including previously saved data. */ public static final int STATS_SINCE_CHARGED = 0; @@ -3834,6 +3839,7 @@ public abstract class BatteryStats implements Parcelable { final ArrayMap<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); long totalFullWakelock = 0, totalPartialWakelock = 0, totalWindowWakelock = 0; + long totalDozeWakelock = 0; int countWakelock = 0; for (int iw=wakelocks.size()-1; iw>=0; iw--) { final Uid.Wakelock wl = wakelocks.valueAt(iw); @@ -3848,19 +3854,21 @@ public abstract class BatteryStats implements Parcelable { "partial", which, linePrefix); linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), rawRealtime, "window", which, linePrefix); - if (true || !linePrefix.equals(": ")) { - sb.append(" realtime"); - // Only print out wake locks that were held - pw.println(sb.toString()); - uidActivity = true; - countWakelock++; - } + linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_DOZE), rawRealtime, + "doze", which, linePrefix); + sb.append(" realtime"); + pw.println(sb.toString()); + uidActivity = true; + countWakelock++; + totalFullWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_FULL), rawRealtime, which); totalPartialWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_PARTIAL), rawRealtime, which); totalWindowWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_WINDOW), rawRealtime, which); + totalDozeWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_DOZE), + rawRealtime, which); } if (countWakelock > 1) { if (totalFullWakelock != 0 || totalPartialWakelock != 0 @@ -3890,6 +3898,14 @@ public abstract class BatteryStats implements Parcelable { formatTimeMs(sb, totalWindowWakelock); sb.append("window"); } + if (totalDozeWakelock != 0) { + if (needComma) { + sb.append(","); + } + needComma = true; + formatTimeMs(sb, totalDozeWakelock); + sb.append("doze"); + } sb.append(" realtime"); pw.println(sb.toString()); } diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 229079f..83ce5f6 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -106,7 +106,7 @@ public final class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version - private static final int VERSION = 128 + (USE_OLD_HISTORY ? 1000 : 0); + private static final int VERSION = 129 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; @@ -208,6 +208,7 @@ public final class BatteryStatsImpl extends BatteryStats { final ArrayList<StopwatchTimer> mPartialTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mFullTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mWindowTimers = new ArrayList<>(); + final ArrayList<StopwatchTimer> mDozeTimers = new ArrayList<>(); final SparseArray<ArrayList<StopwatchTimer>> mSensorTimers = new SparseArray<>(); final ArrayList<StopwatchTimer> mWifiRunningTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mFullWifiLockTimers = new ArrayList<>(); @@ -5648,6 +5649,11 @@ public final class BatteryStatsImpl extends BatteryStats { StopwatchTimer mTimerWindow; /** + * How long (in ms) this uid has had a doze wake lock. + */ + StopwatchTimer mTimerDoze; + + /** * Reads a possibly null Timer from a Parcel. The timer is associated with the * proper timer pool from the given BatteryStatsImpl object. * @@ -5674,6 +5680,9 @@ public final class BatteryStatsImpl extends BatteryStats { if (mTimerWindow != null) { wlactive |= !mTimerWindow.reset(false); } + if (mTimerDoze != null) { + wlactive |= !mTimerDoze.reset(false); + } if (!wlactive) { if (mTimerFull != null) { mTimerFull.detach(); @@ -5687,6 +5696,10 @@ public final class BatteryStatsImpl extends BatteryStats { mTimerWindow.detach(); mTimerWindow = null; } + if (mTimerDoze != null) { + mTimerDoze.detach(); + mTimerDoze = null; + } } return !wlactive; } @@ -5694,16 +5707,16 @@ public final class BatteryStatsImpl extends BatteryStats { void readFromParcelLocked(TimeBase timeBase, TimeBase screenOffTimeBase, Parcel in) { mTimerPartial = readTimerFromParcel(WAKE_TYPE_PARTIAL, mPartialTimers, screenOffTimeBase, in); - mTimerFull = readTimerFromParcel(WAKE_TYPE_FULL, - mFullTimers, timeBase, in); - mTimerWindow = readTimerFromParcel(WAKE_TYPE_WINDOW, - mWindowTimers, timeBase, in); + mTimerFull = readTimerFromParcel(WAKE_TYPE_FULL, mFullTimers, timeBase, in); + mTimerWindow = readTimerFromParcel(WAKE_TYPE_WINDOW, mWindowTimers, timeBase, in); + mTimerDoze = readTimerFromParcel(WAKE_TYPE_DOZE, mDozeTimers, timeBase, in); } void writeToParcelLocked(Parcel out, long elapsedRealtimeUs) { Timer.writeTimerToParcel(out, mTimerPartial, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerFull, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerWindow, elapsedRealtimeUs); + Timer.writeTimerToParcel(out, mTimerDoze, elapsedRealtimeUs); } @Override @@ -5712,6 +5725,7 @@ public final class BatteryStatsImpl extends BatteryStats { case WAKE_TYPE_FULL: return mTimerFull; case WAKE_TYPE_PARTIAL: return mTimerPartial; case WAKE_TYPE_WINDOW: return mTimerWindow; + case WAKE_TYPE_DOZE: return mTimerDoze; default: throw new IllegalArgumentException("type = " + type); } } @@ -5743,6 +5757,13 @@ public final class BatteryStatsImpl extends BatteryStats { mTimerWindow = t; } return t; + case WAKE_TYPE_DOZE: + t = mTimerDoze; + if (t == null) { + t = new StopwatchTimer(Uid.this, WAKE_TYPE_DOZE, + mDozeTimers, mOnBatteryTimeBase); + mTimerDoze = t; + } default: throw new IllegalArgumentException("type=" + type); } @@ -6599,6 +6620,9 @@ public final class BatteryStatsImpl extends BatteryStats { if (in.readInt() != 0) { wl.getStopwatchTimer(WAKE_TYPE_WINDOW).readSummaryFromParcelLocked(in); } + if (in.readInt() != 0) { + wl.getStopwatchTimer(WAKE_TYPE_DOZE).readSummaryFromParcelLocked(in); + } } public StopwatchTimer getSensorTimerLocked(int sensor, boolean create) { @@ -9586,6 +9610,12 @@ public final class BatteryStatsImpl extends BatteryStats { } else { out.writeInt(0); } + if (wl.mTimerDoze != null) { + out.writeInt(1); + wl.mTimerDoze.writeSummaryFromParcelLocked(out, NOWREAL_SYS); + } else { + out.writeInt(0); + } } final ArrayMap<String, StopwatchTimer> syncStats = u.mSyncStats.getMap(); |