Automated import from //branches/donutburger/...@142396,142396
diff --git a/src/com/android/settings/battery_history/BatteryHistory.java b/src/com/android/settings/battery_history/BatteryHistory.java
index dcf6cbf..ad6479a 100644
--- a/src/com/android/settings/battery_history/BatteryHistory.java
+++ b/src/com/android/settings/battery_history/BatteryHistory.java
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Formatter;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -73,7 +74,7 @@
private BatteryStats mStats;
private int mWhich = BatteryStats.STATS_UNPLUGGED;
- private int mType = CPU_USAGE;
+ private int mType = MISC_USAGE;
private GraphableButton[] mButtons;
IBatteryStats mBatteryInfo;
@@ -401,6 +402,7 @@
class MiscUsage extends Graphable {
int mInfoLabelRes;
+ String mInfoLabel;
double[] mUsage;
double mTotalRealtime;
@@ -415,6 +417,17 @@
mTotalRealtime = totalRealtime;
}
+ public MiscUsage(String name, String infoLabel, long value,
+ long totalRealtime) {
+ mName = name;
+
+ mInfoLabel = infoLabel;
+
+ mUsage = new double[2];
+ mUsage[0] = value;
+ mTotalRealtime = totalRealtime;
+ }
+
public String getLabel() {
return mName;
}
@@ -432,7 +445,7 @@
}
public void getInfo(StringBuilder info) {
- info.append(getString(mInfoLabelRes));
+ info.append(mInfoLabel != null ? mInfoLabel : getString(mInfoLabelRes));
info.append(' ');
formatTime(mUsage[0], info);
info.append(" (");
@@ -656,6 +669,19 @@
Collections.sort(mWakelockUsage);
}
+ private final StringBuilder mFormatBuilder = new StringBuilder(8);
+ private final Formatter mFormatter = new Formatter(mFormatBuilder);
+
+ private final String formatRatio(long num, long den) {
+ if (den == 0L) {
+ return "---%";
+ }
+ float perc = ((float)num) / ((float)den) * 100;
+ mFormatBuilder.setLength(0);
+ mFormatter.format("%.1f%%", perc);
+ return mFormatBuilder.toString();
+ }
+
private void processMiscUsage() {
mMiscUsage.clear();
@@ -666,7 +692,8 @@
long time = mStats.computeBatteryUptime(SystemClock.uptimeMillis() * 1000, mWhich) / 1000;
if (time > 0) {
mMiscUsage.add(new MiscUsage(getString(
- R.string.battery_history_awake_label),
+ R.string.battery_history_awake_label)
+ + " (" + formatRatio(time, whichRealtime) + ")",
R.string.battery_history_awake,
time, whichRealtime));
}
@@ -674,7 +701,8 @@
time = mStats.getScreenOnTime(batteryRealtime, mWhich) / 1000;
if (time > 0) {
mMiscUsage.add(new MiscUsage(getString(
- R.string.battery_history_screen_on_label),
+ R.string.battery_history_screen_on_label)
+ + " (" + formatRatio(time, whichRealtime) + ")",
R.string.battery_history_screen_on,
time, whichRealtime));
}
@@ -682,11 +710,36 @@
time = mStats.getPhoneOnTime(batteryRealtime, mWhich) / 1000;
if (time > 0) {
mMiscUsage.add(new MiscUsage(getString(
- R.string.battery_history_phone_on_label),
+ R.string.battery_history_phone_on_label)
+ + " (" + formatRatio(time, whichRealtime) + ")",
R.string.battery_history_phone_on,
time, whichRealtime));
}
+ time = mStats.getWifiOnTime(batteryRealtime, mWhich) / 1000;
+ if (time > 0) {
+ mMiscUsage.add(new MiscUsage("Wifi On ("
+ + formatRatio(time, whichRealtime) + ")",
+ "Time spent with Wifi on:",
+ time, whichRealtime));
+ }
+
+ time = mStats.getWifiRunningTime(batteryRealtime, mWhich) / 1000;
+ if (time > 0) {
+ mMiscUsage.add(new MiscUsage("Wifi Running ("
+ + formatRatio(time, whichRealtime) + ")",
+ "Time spent with Wifi running:",
+ time, whichRealtime));
+ }
+
+ time = mStats.getBluetoothOnTime(batteryRealtime, mWhich) / 1000;
+ if (time > 0) {
+ mMiscUsage.add(new MiscUsage("Bluetooth On ("
+ + formatRatio(time, whichRealtime) + ")",
+ "Time spent with Bluetooth on:",
+ time, whichRealtime));
+ }
+
Collections.sort(mMiscUsage);
}
@@ -815,12 +868,22 @@
setContentView(R.layout.battery_history);
+ mStats = (BatteryStats)getLastNonConfigurationInstance();
+ if (icicle != null) {
+ if (mStats == null) {
+ mStats = (BatteryStats)icicle.getParcelable("stats");
+ }
+ mType = icicle.getInt("type");
+ mWhich = icicle.getInt("which");
+ }
+
mGraphLayout = (LinearLayout) findViewById(R.id.graphLayout);
mTextLayout = (LinearLayout) findViewById(R.id.textLayout);
mDetailsText = (TextView) findViewById(R.id.detailsText);
mMessageText = (TextView) findViewById(R.id.messageText);
mTypeSpinner = (Spinner) findViewById(R.id.typeSpinner);
+ mTypeSpinner.setSelection(mType);
mTypeSpinner.setOnItemSelectedListener(this);
mWhichSpinner = (Spinner) findViewById(R.id.whichSpinner);
@@ -845,14 +908,6 @@
mBatteryInfo = IBatteryStats.Stub.asInterface(
ServiceManager.getService("batteryinfo"));
- mStats = (BatteryStats)getLastNonConfigurationInstance();
- if (icicle != null) {
- if (mStats == null) {
- mStats = (BatteryStats)icicle.getParcelable("stats");
- }
- mType = icicle.getInt("type");
- mWhich = icicle.getInt("which");
- }
if (mStats == null) {
load();
}
diff --git a/src/com/android/settings/battery_history/GraphableButton.java b/src/com/android/settings/battery_history/GraphableButton.java
index 39028d0..fb90a0d 100644
--- a/src/com/android/settings/battery_history/GraphableButton.java
+++ b/src/com/android/settings/battery_history/GraphableButton.java
@@ -15,11 +15,11 @@
static {
sPaint[0] = new Paint();
sPaint[0].setStyle(Paint.Style.FILL);
- sPaint[0].setColor(Color.BLUE);
+ sPaint[0].setColor(0xFF0080FF);
sPaint[1] = new Paint();
sPaint[1].setStyle(Paint.Style.FILL);
- sPaint[1].setColor(Color.RED);
+ sPaint[1].setColor(0xFFFF6060);
}
double[] mValues;