summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-11-18 18:43:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-18 18:43:29 +0000
commit9522055f1d10b30158b772885bf4befe06fb2a08 (patch)
tree29318c20f2b9ccd492878f228fc46d7533f72739
parent5e3b4f1786c4108861f7a00e8bc76dd226693492 (diff)
parentad6a99b32a0d062c967019e5cd9858071a9c6617 (diff)
downloadframeworks_base-9522055f1d10b30158b772885bf4befe06fb2a08.zip
frameworks_base-9522055f1d10b30158b772885bf4befe06fb2a08.tar.gz
frameworks_base-9522055f1d10b30158b772885bf4befe06fb2a08.tar.bz2
Merge "Add time estimates to batterystats dump." into lmp-mr1-dev
-rw-r--r--core/java/android/os/BatteryStats.java71
-rw-r--r--core/java/android/provider/Settings.java6
2 files changed, 74 insertions, 3 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 461469c..4709443 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -3669,6 +3669,45 @@ public abstract class BatteryStats implements Parcelable {
pw.print(suffix);
}
+ private static boolean dumpTimeEstimate(PrintWriter pw, String label, long[] steps,
+ int count, long modesOfInterest, long modeValues) {
+ if (count <= 0) {
+ return false;
+ }
+ long total = 0;
+ int numOfInterest = 0;
+ for (int i=0; i<count; i++) {
+ long initMode = (steps[i] & STEP_LEVEL_INITIAL_MODE_MASK)
+ >> STEP_LEVEL_INITIAL_MODE_SHIFT;
+ long modMode = (steps[i] & STEP_LEVEL_MODIFIED_MODE_MASK)
+ >> STEP_LEVEL_MODIFIED_MODE_SHIFT;
+ // If the modes of interest didn't change during this step period...
+ if ((modMode&modesOfInterest) == 0) {
+ // And the mode values during this period match those we are measuring...
+ if ((initMode&modesOfInterest) == modeValues) {
+ // Then this can be used to estimate the total time!
+ numOfInterest++;
+ total += steps[i] & STEP_LEVEL_TIME_MASK;
+ }
+ }
+ }
+ if (numOfInterest <= 0) {
+ return false;
+ }
+
+ // The estimated time is the average time we spend in each level, multipled
+ // by 100 -- the total number of battery levels
+ long estimatedTime = (total / numOfInterest) * 100;
+
+ pw.print(label);
+ StringBuilder sb = new StringBuilder(64);
+ formatTimeMs(sb, estimatedTime);
+ pw.print(sb);
+ pw.println();
+
+ return true;
+ }
+
private static boolean dumpDurationSteps(PrintWriter pw, String header, long[] steps,
int count, boolean checkin) {
if (count <= 0) {
@@ -3923,6 +3962,38 @@ public abstract class BatteryStats implements Parcelable {
TimeUtils.formatDuration(timeRemaining / 1000, pw);
pw.println();
}
+ dumpTimeEstimate(pw, " Estimated screen off time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_OFF-1));
+ dumpTimeEstimate(pw, " Estimated screen off power save time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_OFF-1)|STEP_LEVEL_MODE_POWER_SAVE);
+ dumpTimeEstimate(pw, " Estimated screen on time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_ON-1));
+ dumpTimeEstimate(pw, " Estimated screen on power save time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_ON-1)|STEP_LEVEL_MODE_POWER_SAVE);
+ dumpTimeEstimate(pw, " Estimated screen doze time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_DOZE-1));
+ dumpTimeEstimate(pw, " Estimated screen doze power save time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_DOZE-1)|STEP_LEVEL_MODE_POWER_SAVE);
+ dumpTimeEstimate(pw, " Estimated screen doze suspend time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_DOZE_SUSPEND-1));
+ dumpTimeEstimate(pw, " Estimated screen doze suspend power save time: ",
+ getDischargeStepDurationsArray(), getNumDischargeStepDurations(),
+ STEP_LEVEL_MODE_SCREEN_STATE|STEP_LEVEL_MODE_POWER_SAVE,
+ (Display.STATE_DOZE_SUSPEND-1)|STEP_LEVEL_MODE_POWER_SAVE);
pw.println();
}
if (dumpDurationSteps(pw, "Charge step durations:", getChargeStepDurationsArray(),
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 1f45f0a..0be4aea 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -984,8 +984,8 @@ public final class Settings {
* InputDeviceIdentifier. This field is used by some activities to jump straight into the
* settings for the given device.
* <p>
- * Example: The {@link #INPUT_METHOD_SETTINGS} intent opens the keyboard layout dialog for the
- * given device.
+ * Example: The {@link #ACTION_INPUT_METHOD_SETTINGS} intent opens the keyboard layout
+ * dialog for the given device.
* @hide
*/
public static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
@@ -4816,7 +4816,7 @@ public final class Settings {
* The timeout in milliseconds before the device fully goes to sleep after
* a period of inactivity. This value sets an upper bound on how long the device
* will stay awake or dreaming without user activity. It should generally
- * be longer than {@link #SCREEN_OFF_TIMEOUT} as otherwise the device
+ * be longer than {@link Settings.System#SCREEN_OFF_TIMEOUT} as otherwise the device
* will sleep before it ever has a chance to dream.
* <p>
* Use -1 to disable this timeout.