Merge "Fix problems with determining when to kill apps for wake usage." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
567722eee1
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import android.util.Log;
|
||||
import android.util.Printer;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TimeUtils;
|
||||
|
||||
/**
|
||||
* A class providing access to battery usage statistics, including information on
|
||||
@@ -1576,8 +1577,10 @@ public abstract class BatteryStats implements Parcelable {
|
||||
Uid.Proc.ExcessiveWake ew = ps.getExcessiveWake(e);
|
||||
if (ew != null) {
|
||||
pw.print(prefix); pw.print(" * Killed for wake lock use: ");
|
||||
pw.print(ew.usedTime); pw.print("ms over ");
|
||||
pw.print(ew.overTime); pw.print("ms (");
|
||||
TimeUtils.formatDuration(ew.usedTime, pw);
|
||||
pw.print(" over ");
|
||||
TimeUtils.formatDuration(ew.overTime, pw);
|
||||
pw.print(" (");
|
||||
pw.print((ew.usedTime*100)/ew.overTime);
|
||||
pw.println("%)");
|
||||
}
|
||||
|
||||
@@ -192,10 +192,11 @@ public class Looper {
|
||||
pw.println(prefix + "mQueue=" + ((mQueue != null) ? mQueue : "(null"));
|
||||
if (mQueue != null) {
|
||||
synchronized (mQueue) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
Message msg = mQueue.mMessages;
|
||||
int n = 0;
|
||||
while (msg != null) {
|
||||
pw.println(prefix + " Message " + n + ": " + msg);
|
||||
pw.println(prefix + " Message " + n + ": " + msg.toString(now));
|
||||
n++;
|
||||
msg = msg.next;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.os;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.TimeUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -366,13 +367,17 @@ public final class Message implements Parcelable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return toString(SystemClock.uptimeMillis());
|
||||
}
|
||||
|
||||
String toString(long now) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
||||
b.append("{ what=");
|
||||
b.append(what);
|
||||
|
||||
b.append(" when=");
|
||||
b.append(when);
|
||||
TimeUtils.formatDuration(when-now, b);
|
||||
|
||||
if (arg1 != 0) {
|
||||
b.append(" arg1=");
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -130,4 +131,128 @@ public class TimeUtils {
|
||||
public static String getTimeZoneDatabaseVersion() {
|
||||
return ZoneInfoDB.getVersion();
|
||||
}
|
||||
|
||||
private static final int SECONDS_PER_MINUTE = 60;
|
||||
private static final int SECONDS_PER_HOUR = 60 * 60;
|
||||
private static final int SECONDS_PER_DAY = 24 * 60 * 60;
|
||||
|
||||
/** @hide Just for debugging; not internationalized. */
|
||||
public static void formatDuration(long duration, StringBuilder builder) {
|
||||
if (duration == 0) {
|
||||
builder.append("0");
|
||||
return;
|
||||
}
|
||||
if (duration > 0) {
|
||||
builder.append("+");
|
||||
} else {
|
||||
builder.append("-");
|
||||
duration = -duration;
|
||||
}
|
||||
|
||||
int millis = (int)(duration%1000);
|
||||
int seconds = (int) Math.floor(duration / 1000);
|
||||
int days = 0, hours = 0, minutes = 0;
|
||||
|
||||
if (seconds > SECONDS_PER_DAY) {
|
||||
days = seconds / SECONDS_PER_DAY;
|
||||
seconds -= days * SECONDS_PER_DAY;
|
||||
}
|
||||
if (seconds > SECONDS_PER_HOUR) {
|
||||
hours = seconds / SECONDS_PER_HOUR;
|
||||
seconds -= hours * SECONDS_PER_HOUR;
|
||||
}
|
||||
if (seconds > SECONDS_PER_MINUTE) {
|
||||
minutes = seconds / SECONDS_PER_MINUTE;
|
||||
seconds -= minutes * SECONDS_PER_MINUTE;
|
||||
}
|
||||
|
||||
boolean doall = false;
|
||||
if (days > 0) {
|
||||
builder.append(days);
|
||||
builder.append('d');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || hours > 0) {
|
||||
builder.append(hours);
|
||||
builder.append('h');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || minutes > 0) {
|
||||
builder.append(minutes);
|
||||
builder.append('m');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || seconds > 0) {
|
||||
builder.append(seconds);
|
||||
builder.append('s');
|
||||
doall = true;
|
||||
}
|
||||
builder.append(millis);
|
||||
builder.append("ms");
|
||||
}
|
||||
|
||||
/** @hide Just for debugging; not internationalized. */
|
||||
public static void formatDuration(long duration, PrintWriter pw) {
|
||||
if (duration == 0) {
|
||||
pw.print("0");
|
||||
return;
|
||||
}
|
||||
if (duration > 0) {
|
||||
pw.print("+");
|
||||
} else {
|
||||
pw.print("-");
|
||||
duration = -duration;
|
||||
}
|
||||
|
||||
int millis = (int)(duration%1000);
|
||||
int seconds = (int) Math.floor(duration / 1000);
|
||||
int days = 0, hours = 0, minutes = 0;
|
||||
|
||||
if (seconds > SECONDS_PER_DAY) {
|
||||
days = seconds / SECONDS_PER_DAY;
|
||||
seconds -= days * SECONDS_PER_DAY;
|
||||
}
|
||||
if (seconds > SECONDS_PER_HOUR) {
|
||||
hours = seconds / SECONDS_PER_HOUR;
|
||||
seconds -= hours * SECONDS_PER_HOUR;
|
||||
}
|
||||
if (seconds > SECONDS_PER_MINUTE) {
|
||||
minutes = seconds / SECONDS_PER_MINUTE;
|
||||
seconds -= minutes * SECONDS_PER_MINUTE;
|
||||
}
|
||||
|
||||
boolean doall = false;
|
||||
if (days > 0) {
|
||||
pw.print(days);
|
||||
pw.print('d');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || hours > 0) {
|
||||
pw.print(hours);
|
||||
pw.print('h');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || minutes > 0) {
|
||||
pw.print(minutes);
|
||||
pw.print('m');
|
||||
doall = true;
|
||||
}
|
||||
if (doall || seconds > 0) {
|
||||
pw.print(seconds);
|
||||
pw.print('s');
|
||||
doall = true;
|
||||
}
|
||||
pw.print(millis);
|
||||
pw.print("ms");
|
||||
}
|
||||
|
||||
|
||||
/** @hide Just for debugging; not internationalized. */
|
||||
public static void formatDuration(long time, long now, PrintWriter pw) {
|
||||
if (time == 0) {
|
||||
pw.print("--");
|
||||
return;
|
||||
}
|
||||
formatDuration(time-now, pw);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user