Merge "Repurpose doze wake lock stats for draw wake lock instead." into mnc-dev

This commit is contained in:
Jeff Brown
2015-06-22 19:29:30 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 28 deletions

View File

@@ -142,9 +142,9 @@ public abstract class BatteryStats implements Parcelable {
public static final int CAMERA_TURNED_ON = 17; public static final int CAMERA_TURNED_ON = 17;
/** /**
* A constant indicating a doze wake lock timer. * A constant indicating a draw wake lock timer.
*/ */
public static final int WAKE_TYPE_DOZE = 18; public static final int WAKE_TYPE_DRAW = 18;
/** /**
* Include all of the data in the stats, including previously saved data. * Include all of the data in the stats, including previously saved data.
@@ -3839,7 +3839,7 @@ public abstract class BatteryStats implements Parcelable {
final ArrayMap<String, ? extends BatteryStats.Uid.Wakelock> wakelocks final ArrayMap<String, ? extends BatteryStats.Uid.Wakelock> wakelocks
= u.getWakelockStats(); = u.getWakelockStats();
long totalFullWakelock = 0, totalPartialWakelock = 0, totalWindowWakelock = 0; long totalFullWakelock = 0, totalPartialWakelock = 0, totalWindowWakelock = 0;
long totalDozeWakelock = 0; long totalDrawWakelock = 0;
int countWakelock = 0; int countWakelock = 0;
for (int iw=wakelocks.size()-1; iw>=0; iw--) { for (int iw=wakelocks.size()-1; iw>=0; iw--) {
final Uid.Wakelock wl = wakelocks.valueAt(iw); final Uid.Wakelock wl = wakelocks.valueAt(iw);
@@ -3854,8 +3854,8 @@ public abstract class BatteryStats implements Parcelable {
"partial", which, linePrefix); "partial", which, linePrefix);
linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), rawRealtime, linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), rawRealtime,
"window", which, linePrefix); "window", which, linePrefix);
linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_DOZE), rawRealtime, linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_DRAW), rawRealtime,
"doze", which, linePrefix); "draw", which, linePrefix);
sb.append(" realtime"); sb.append(" realtime");
pw.println(sb.toString()); pw.println(sb.toString());
uidActivity = true; uidActivity = true;
@@ -3867,7 +3867,7 @@ public abstract class BatteryStats implements Parcelable {
rawRealtime, which); rawRealtime, which);
totalWindowWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_WINDOW), totalWindowWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_WINDOW),
rawRealtime, which); rawRealtime, which);
totalDozeWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_DOZE), totalDrawWakelock += computeWakeLock(wl.getWakeTime(WAKE_TYPE_DRAW),
rawRealtime, which); rawRealtime, which);
} }
if (countWakelock > 1) { if (countWakelock > 1) {
@@ -3898,13 +3898,13 @@ public abstract class BatteryStats implements Parcelable {
formatTimeMs(sb, totalWindowWakelock); formatTimeMs(sb, totalWindowWakelock);
sb.append("window"); sb.append("window");
} }
if (totalDozeWakelock != 0) { if (totalDrawWakelock != 0) {
if (needComma) { if (needComma) {
sb.append(","); sb.append(",");
} }
needComma = true; needComma = true;
formatTimeMs(sb, totalDozeWakelock); formatTimeMs(sb, totalDrawWakelock);
sb.append("doze"); sb.append("draw");
} }
sb.append(" realtime"); sb.append(" realtime");
pw.println(sb.toString()); pw.println(sb.toString());

View File

@@ -208,7 +208,7 @@ public final class BatteryStatsImpl extends BatteryStats {
final ArrayList<StopwatchTimer> mPartialTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mPartialTimers = new ArrayList<>();
final ArrayList<StopwatchTimer> mFullTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mFullTimers = new ArrayList<>();
final ArrayList<StopwatchTimer> mWindowTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mWindowTimers = new ArrayList<>();
final ArrayList<StopwatchTimer> mDozeTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mDrawTimers = new ArrayList<>();
final SparseArray<ArrayList<StopwatchTimer>> mSensorTimers = new SparseArray<>(); final SparseArray<ArrayList<StopwatchTimer>> mSensorTimers = new SparseArray<>();
final ArrayList<StopwatchTimer> mWifiRunningTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mWifiRunningTimers = new ArrayList<>();
final ArrayList<StopwatchTimer> mFullWifiLockTimers = new ArrayList<>(); final ArrayList<StopwatchTimer> mFullWifiLockTimers = new ArrayList<>();
@@ -5649,9 +5649,9 @@ public final class BatteryStatsImpl extends BatteryStats {
StopwatchTimer mTimerWindow; StopwatchTimer mTimerWindow;
/** /**
* How long (in ms) this uid has had a doze wake lock. * How long (in ms) this uid has had a draw wake lock.
*/ */
StopwatchTimer mTimerDoze; StopwatchTimer mTimerDraw;
/** /**
* Reads a possibly null Timer from a Parcel. The timer is associated with the * Reads a possibly null Timer from a Parcel. The timer is associated with the
@@ -5680,8 +5680,8 @@ public final class BatteryStatsImpl extends BatteryStats {
if (mTimerWindow != null) { if (mTimerWindow != null) {
wlactive |= !mTimerWindow.reset(false); wlactive |= !mTimerWindow.reset(false);
} }
if (mTimerDoze != null) { if (mTimerDraw != null) {
wlactive |= !mTimerDoze.reset(false); wlactive |= !mTimerDraw.reset(false);
} }
if (!wlactive) { if (!wlactive) {
if (mTimerFull != null) { if (mTimerFull != null) {
@@ -5696,9 +5696,9 @@ public final class BatteryStatsImpl extends BatteryStats {
mTimerWindow.detach(); mTimerWindow.detach();
mTimerWindow = null; mTimerWindow = null;
} }
if (mTimerDoze != null) { if (mTimerDraw != null) {
mTimerDoze.detach(); mTimerDraw.detach();
mTimerDoze = null; mTimerDraw = null;
} }
} }
return !wlactive; return !wlactive;
@@ -5709,14 +5709,14 @@ public final class BatteryStatsImpl extends BatteryStats {
mPartialTimers, screenOffTimeBase, in); mPartialTimers, screenOffTimeBase, in);
mTimerFull = readTimerFromParcel(WAKE_TYPE_FULL, mFullTimers, timeBase, in); mTimerFull = readTimerFromParcel(WAKE_TYPE_FULL, mFullTimers, timeBase, in);
mTimerWindow = readTimerFromParcel(WAKE_TYPE_WINDOW, mWindowTimers, timeBase, in); mTimerWindow = readTimerFromParcel(WAKE_TYPE_WINDOW, mWindowTimers, timeBase, in);
mTimerDoze = readTimerFromParcel(WAKE_TYPE_DOZE, mDozeTimers, timeBase, in); mTimerDraw = readTimerFromParcel(WAKE_TYPE_DRAW, mDrawTimers, timeBase, in);
} }
void writeToParcelLocked(Parcel out, long elapsedRealtimeUs) { void writeToParcelLocked(Parcel out, long elapsedRealtimeUs) {
Timer.writeTimerToParcel(out, mTimerPartial, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerPartial, elapsedRealtimeUs);
Timer.writeTimerToParcel(out, mTimerFull, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerFull, elapsedRealtimeUs);
Timer.writeTimerToParcel(out, mTimerWindow, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerWindow, elapsedRealtimeUs);
Timer.writeTimerToParcel(out, mTimerDoze, elapsedRealtimeUs); Timer.writeTimerToParcel(out, mTimerDraw, elapsedRealtimeUs);
} }
@Override @Override
@@ -5725,7 +5725,7 @@ public final class BatteryStatsImpl extends BatteryStats {
case WAKE_TYPE_FULL: return mTimerFull; case WAKE_TYPE_FULL: return mTimerFull;
case WAKE_TYPE_PARTIAL: return mTimerPartial; case WAKE_TYPE_PARTIAL: return mTimerPartial;
case WAKE_TYPE_WINDOW: return mTimerWindow; case WAKE_TYPE_WINDOW: return mTimerWindow;
case WAKE_TYPE_DOZE: return mTimerDoze; case WAKE_TYPE_DRAW: return mTimerDraw;
default: throw new IllegalArgumentException("type = " + type); default: throw new IllegalArgumentException("type = " + type);
} }
} }
@@ -5757,13 +5757,14 @@ public final class BatteryStatsImpl extends BatteryStats {
mTimerWindow = t; mTimerWindow = t;
} }
return t; return t;
case WAKE_TYPE_DOZE: case WAKE_TYPE_DRAW:
t = mTimerDoze; t = mTimerDraw;
if (t == null) { if (t == null) {
t = new StopwatchTimer(Uid.this, WAKE_TYPE_DOZE, t = new StopwatchTimer(Uid.this, WAKE_TYPE_DRAW,
mDozeTimers, mOnBatteryTimeBase); mDrawTimers, mOnBatteryTimeBase);
mTimerDoze = t; mTimerDraw = t;
} }
return t;
default: default:
throw new IllegalArgumentException("type=" + type); throw new IllegalArgumentException("type=" + type);
} }
@@ -6621,7 +6622,7 @@ public final class BatteryStatsImpl extends BatteryStats {
wl.getStopwatchTimer(WAKE_TYPE_WINDOW).readSummaryFromParcelLocked(in); wl.getStopwatchTimer(WAKE_TYPE_WINDOW).readSummaryFromParcelLocked(in);
} }
if (in.readInt() != 0) { if (in.readInt() != 0) {
wl.getStopwatchTimer(WAKE_TYPE_DOZE).readSummaryFromParcelLocked(in); wl.getStopwatchTimer(WAKE_TYPE_DRAW).readSummaryFromParcelLocked(in);
} }
} }
@@ -9610,9 +9611,9 @@ public final class BatteryStatsImpl extends BatteryStats {
} else { } else {
out.writeInt(0); out.writeInt(0);
} }
if (wl.mTimerDoze != null) { if (wl.mTimerDraw != null) {
out.writeInt(1); out.writeInt(1);
wl.mTimerDoze.writeSummaryFromParcelLocked(out, NOWREAL_SYS); wl.mTimerDraw.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
} else { } else {
out.writeInt(0); out.writeInt(0);
} }