Automated import from //branches/donutburger/...@142396,142396
This commit is contained in:

committed by
The Android Open Source Project
parent
585ee96b91
commit
6a5687ebf5
@@ -18,6 +18,7 @@ package com.android.settings.battery_history;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Formatter;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -73,7 +74,7 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
|
|
||||||
private BatteryStats mStats;
|
private BatteryStats mStats;
|
||||||
private int mWhich = BatteryStats.STATS_UNPLUGGED;
|
private int mWhich = BatteryStats.STATS_UNPLUGGED;
|
||||||
private int mType = CPU_USAGE;
|
private int mType = MISC_USAGE;
|
||||||
|
|
||||||
private GraphableButton[] mButtons;
|
private GraphableButton[] mButtons;
|
||||||
IBatteryStats mBatteryInfo;
|
IBatteryStats mBatteryInfo;
|
||||||
@@ -401,6 +402,7 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
|
|
||||||
class MiscUsage extends Graphable {
|
class MiscUsage extends Graphable {
|
||||||
int mInfoLabelRes;
|
int mInfoLabelRes;
|
||||||
|
String mInfoLabel;
|
||||||
double[] mUsage;
|
double[] mUsage;
|
||||||
double mTotalRealtime;
|
double mTotalRealtime;
|
||||||
|
|
||||||
@@ -415,6 +417,17 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
mTotalRealtime = totalRealtime;
|
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() {
|
public String getLabel() {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
@@ -432,7 +445,7 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getInfo(StringBuilder info) {
|
public void getInfo(StringBuilder info) {
|
||||||
info.append(getString(mInfoLabelRes));
|
info.append(mInfoLabel != null ? mInfoLabel : getString(mInfoLabelRes));
|
||||||
info.append(' ');
|
info.append(' ');
|
||||||
formatTime(mUsage[0], info);
|
formatTime(mUsage[0], info);
|
||||||
info.append(" (");
|
info.append(" (");
|
||||||
@@ -656,6 +669,19 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
Collections.sort(mWakelockUsage);
|
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() {
|
private void processMiscUsage() {
|
||||||
mMiscUsage.clear();
|
mMiscUsage.clear();
|
||||||
|
|
||||||
@@ -666,7 +692,8 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
long time = mStats.computeBatteryUptime(SystemClock.uptimeMillis() * 1000, mWhich) / 1000;
|
long time = mStats.computeBatteryUptime(SystemClock.uptimeMillis() * 1000, mWhich) / 1000;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
mMiscUsage.add(new MiscUsage(getString(
|
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,
|
R.string.battery_history_awake,
|
||||||
time, whichRealtime));
|
time, whichRealtime));
|
||||||
}
|
}
|
||||||
@@ -674,7 +701,8 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
time = mStats.getScreenOnTime(batteryRealtime, mWhich) / 1000;
|
time = mStats.getScreenOnTime(batteryRealtime, mWhich) / 1000;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
mMiscUsage.add(new MiscUsage(getString(
|
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,
|
R.string.battery_history_screen_on,
|
||||||
time, whichRealtime));
|
time, whichRealtime));
|
||||||
}
|
}
|
||||||
@@ -682,11 +710,36 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
time = mStats.getPhoneOnTime(batteryRealtime, mWhich) / 1000;
|
time = mStats.getPhoneOnTime(batteryRealtime, mWhich) / 1000;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
mMiscUsage.add(new MiscUsage(getString(
|
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,
|
R.string.battery_history_phone_on,
|
||||||
time, whichRealtime));
|
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);
|
Collections.sort(mMiscUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,12 +868,22 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
|
|
||||||
setContentView(R.layout.battery_history);
|
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);
|
mGraphLayout = (LinearLayout) findViewById(R.id.graphLayout);
|
||||||
mTextLayout = (LinearLayout) findViewById(R.id.textLayout);
|
mTextLayout = (LinearLayout) findViewById(R.id.textLayout);
|
||||||
mDetailsText = (TextView) findViewById(R.id.detailsText);
|
mDetailsText = (TextView) findViewById(R.id.detailsText);
|
||||||
mMessageText = (TextView) findViewById(R.id.messageText);
|
mMessageText = (TextView) findViewById(R.id.messageText);
|
||||||
|
|
||||||
mTypeSpinner = (Spinner) findViewById(R.id.typeSpinner);
|
mTypeSpinner = (Spinner) findViewById(R.id.typeSpinner);
|
||||||
|
mTypeSpinner.setSelection(mType);
|
||||||
mTypeSpinner.setOnItemSelectedListener(this);
|
mTypeSpinner.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
mWhichSpinner = (Spinner) findViewById(R.id.whichSpinner);
|
mWhichSpinner = (Spinner) findViewById(R.id.whichSpinner);
|
||||||
@@ -845,14 +908,6 @@ public class BatteryHistory extends Activity implements OnClickListener, OnItemS
|
|||||||
mBatteryInfo = IBatteryStats.Stub.asInterface(
|
mBatteryInfo = IBatteryStats.Stub.asInterface(
|
||||||
ServiceManager.getService("batteryinfo"));
|
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) {
|
if (mStats == null) {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
@@ -15,11 +15,11 @@ public class GraphableButton extends Button {
|
|||||||
static {
|
static {
|
||||||
sPaint[0] = new Paint();
|
sPaint[0] = new Paint();
|
||||||
sPaint[0].setStyle(Paint.Style.FILL);
|
sPaint[0].setStyle(Paint.Style.FILL);
|
||||||
sPaint[0].setColor(Color.BLUE);
|
sPaint[0].setColor(0xFF0080FF);
|
||||||
|
|
||||||
sPaint[1] = new Paint();
|
sPaint[1] = new Paint();
|
||||||
sPaint[1].setStyle(Paint.Style.FILL);
|
sPaint[1].setStyle(Paint.Style.FILL);
|
||||||
sPaint[1].setColor(Color.RED);
|
sPaint[1].setColor(0xFFFF6060);
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] mValues;
|
double[] mValues;
|
||||||
|
Reference in New Issue
Block a user