Add time estimates to batterystats dump.
Also fix some java docs.
Change-Id: Ie705f236db6f06e34fa5581c20852e5c8f7c2c17
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 @@
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 @@
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 @@
* 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 @@
* 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.