Merge "Update to follow BatteryStats."
This commit is contained in:
committed by
Android (Google) Code Review
commit
09a3c1f949
@@ -3616,13 +3616,13 @@
|
|||||||
<!-- Label for Phone usage time -->
|
<!-- Label for Phone usage time -->
|
||||||
<string name="usage_type_phone" product="default">Phone</string>
|
<string name="usage_type_phone" product="default">Phone</string>
|
||||||
<!-- Label for mobile network data sent [CHAR LIMIT=32] -->
|
<!-- Label for mobile network data sent [CHAR LIMIT=32] -->
|
||||||
<string name="usage_type_data_send">Mobile data sent</string>
|
<string name="usage_type_data_send">Mobile packets sent</string>
|
||||||
<!-- Label for mobile network data received [CHAR LIMIT=32] -->
|
<!-- Label for mobile network data received [CHAR LIMIT=32] -->
|
||||||
<string name="usage_type_data_recv">Mobile data received</string>
|
<string name="usage_type_data_recv">Mobile packets received</string>
|
||||||
<!-- Label for Wi-Fi network data sent [CHAR LIMIT=32] -->
|
<!-- Label for Wi-Fi network data sent [CHAR LIMIT=32] -->
|
||||||
<string name="usage_type_data_wifi_send">Wi\u2011Fi data sent</string>
|
<string name="usage_type_data_wifi_send">Wi\u2011Fi packets sent</string>
|
||||||
<!-- Label for Wi-Fi network data received [CHAR LIMIT=32] -->
|
<!-- Label for Wi-Fi network data received [CHAR LIMIT=32] -->
|
||||||
<string name="usage_type_data_wifi_recv">Wi\u2011Fi data received</string>
|
<string name="usage_type_data_wifi_recv">Wi\u2011Fi packets received</string>
|
||||||
<!-- Label for Audio usage time -->
|
<!-- Label for Audio usage time -->
|
||||||
<string name="usage_type_audio">Audio</string>
|
<string name="usage_type_audio">Audio</string>
|
||||||
<!-- Label for Video usage time -->
|
<!-- Label for Video usage time -->
|
||||||
|
@@ -361,7 +361,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
final HistoryItem rec = new HistoryItem();
|
final HistoryItem rec = new HistoryItem();
|
||||||
while (stats.getNextHistoryLocked(rec)) {
|
while (stats.getNextHistoryLocked(rec)) {
|
||||||
pos++;
|
pos++;
|
||||||
if (rec.cmd == HistoryItem.CMD_UPDATE) {
|
if (rec.isDeltaData()) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
mHistStart = rec.time;
|
mHistStart = rec.time;
|
||||||
@@ -523,7 +523,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
if (mStats.startIteratingHistoryLocked()) {
|
if (mStats.startIteratingHistoryLocked()) {
|
||||||
final HistoryItem rec = new HistoryItem();
|
final HistoryItem rec = new HistoryItem();
|
||||||
while (mStats.getNextHistoryLocked(rec) && i < N) {
|
while (mStats.getNextHistoryLocked(rec) && i < N) {
|
||||||
if (rec.cmd == BatteryStats.HistoryItem.CMD_UPDATE) {
|
if (rec.isDeltaData()) {
|
||||||
x = (int)(((rec.time-timeStart)*w)/timeChange);
|
x = (int)(((rec.time-timeStart)*w)/timeChange);
|
||||||
y = mLevelTop + levelh - ((rec.batteryLevel-batLow)*(levelh-1))/batChange;
|
y = mLevelTop + levelh - ((rec.batteryLevel-batLow)*(levelh-1))/batChange;
|
||||||
|
|
||||||
|
@@ -53,6 +53,10 @@ public class BatterySipper implements Comparable<BatterySipper> {
|
|||||||
long wifiRunningTime;
|
long wifiRunningTime;
|
||||||
long cpuFgTime;
|
long cpuFgTime;
|
||||||
long wakeLockTime;
|
long wakeLockTime;
|
||||||
|
long mobileRxPackets;
|
||||||
|
long mobileTxPackets;
|
||||||
|
long wifiRxPackets;
|
||||||
|
long wifiTxPackets;
|
||||||
long mobileRxBytes;
|
long mobileRxBytes;
|
||||||
long mobileTxBytes;
|
long mobileTxBytes;
|
||||||
long wifiRxBytes;
|
long wifiRxBytes;
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.fuelgauge;
|
package com.android.settings.fuelgauge;
|
||||||
|
|
||||||
import static android.os.BatteryStats.NETWORK_MOBILE_RX_BYTES;
|
import static android.os.BatteryStats.NETWORK_MOBILE_RX_DATA;
|
||||||
import static android.os.BatteryStats.NETWORK_MOBILE_TX_BYTES;
|
import static android.os.BatteryStats.NETWORK_MOBILE_TX_DATA;
|
||||||
import static android.os.BatteryStats.NETWORK_WIFI_RX_BYTES;
|
import static android.os.BatteryStats.NETWORK_WIFI_RX_DATA;
|
||||||
import static android.os.BatteryStats.NETWORK_WIFI_TX_BYTES;
|
import static android.os.BatteryStats.NETWORK_WIFI_TX_DATA;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -222,10 +222,10 @@ public class BatteryStatsHelper {
|
|||||||
sipper.wakeLockTime,
|
sipper.wakeLockTime,
|
||||||
sipper.gpsTime,
|
sipper.gpsTime,
|
||||||
sipper.wifiRunningTime,
|
sipper.wifiRunningTime,
|
||||||
sipper.mobileRxBytes,
|
sipper.mobileRxPackets,
|
||||||
sipper.mobileTxBytes,
|
sipper.mobileTxPackets,
|
||||||
sipper.wifiRxBytes,
|
sipper.wifiRxPackets,
|
||||||
sipper.wifiTxBytes,
|
sipper.wifiTxPackets,
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
@@ -275,10 +275,10 @@ public class BatteryStatsHelper {
|
|||||||
sipper.cpuTime,
|
sipper.cpuTime,
|
||||||
sipper.cpuFgTime,
|
sipper.cpuFgTime,
|
||||||
sipper.wakeLockTime,
|
sipper.wakeLockTime,
|
||||||
sipper.mobileRxBytes,
|
sipper.mobileRxPackets,
|
||||||
sipper.mobileTxBytes,
|
sipper.mobileTxPackets,
|
||||||
sipper.wifiRxBytes,
|
sipper.wifiRxPackets,
|
||||||
sipper.wifiTxBytes,
|
sipper.wifiTxPackets,
|
||||||
};
|
};
|
||||||
} break;
|
} break;
|
||||||
case BLUETOOTH:
|
case BLUETOOTH:
|
||||||
@@ -298,10 +298,10 @@ public class BatteryStatsHelper {
|
|||||||
sipper.cpuTime,
|
sipper.cpuTime,
|
||||||
sipper.cpuFgTime,
|
sipper.cpuFgTime,
|
||||||
sipper.wakeLockTime,
|
sipper.wakeLockTime,
|
||||||
sipper.mobileRxBytes,
|
sipper.mobileRxPackets,
|
||||||
sipper.mobileTxBytes,
|
sipper.mobileTxPackets,
|
||||||
sipper.wifiRxBytes,
|
sipper.wifiRxPackets,
|
||||||
sipper.wifiTxBytes,
|
sipper.wifiTxPackets,
|
||||||
};
|
};
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
@@ -371,8 +371,8 @@ public class BatteryStatsHelper {
|
|||||||
for (int p = 0; p < speedSteps; p++) {
|
for (int p = 0; p < speedSteps; p++) {
|
||||||
powerCpuNormal[p] = mPowerProfile.getAveragePower(PowerProfile.POWER_CPU_ACTIVE, p);
|
powerCpuNormal[p] = mPowerProfile.getAveragePower(PowerProfile.POWER_CPU_ACTIVE, p);
|
||||||
}
|
}
|
||||||
final double mobilePowerPerByte = getMobilePowerPerByte();
|
final double mobilePowerPerPacket = getMobilePowerPerPacket();
|
||||||
final double wifiPowerPerByte = getWifiPowerPerByte();
|
final double wifiPowerPerPacket = getWifiPowerPerPacket();
|
||||||
long uSecTime = mStats.computeBatteryRealtime(SystemClock.elapsedRealtime() * 1000, which);
|
long uSecTime = mStats.computeBatteryRealtime(SystemClock.elapsedRealtime() * 1000, which);
|
||||||
long appWakelockTime = 0;
|
long appWakelockTime = 0;
|
||||||
BatterySipper osApp = null;
|
BatterySipper osApp = null;
|
||||||
@@ -463,16 +463,20 @@ public class BatteryStatsHelper {
|
|||||||
if (DEBUG && p != 0) Log.i(TAG, String.format("wakelock power=%.2f", p));
|
if (DEBUG && p != 0) Log.i(TAG, String.format("wakelock power=%.2f", p));
|
||||||
|
|
||||||
// Add cost of mobile traffic
|
// Add cost of mobile traffic
|
||||||
final long mobileRx = u.getNetworkActivityCount(NETWORK_MOBILE_RX_BYTES, mStatsType);
|
final long mobileRx = u.getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, mStatsType);
|
||||||
final long mobileTx = u.getNetworkActivityCount(NETWORK_MOBILE_TX_BYTES, mStatsType);
|
final long mobileTx = u.getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, mStatsType);
|
||||||
p = (mobileRx + mobileTx) * mobilePowerPerByte;
|
final long mobileRxB = u.getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, mStatsType);
|
||||||
|
final long mobileTxB = u.getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, mStatsType);
|
||||||
|
p = (mobileRx + mobileTx) * mobilePowerPerPacket;
|
||||||
power += p;
|
power += p;
|
||||||
if (DEBUG && p != 0) Log.i(TAG, String.format("mobile power=%.2f", p));
|
if (DEBUG && p != 0) Log.i(TAG, String.format("mobile power=%.2f", p));
|
||||||
|
|
||||||
// Add cost of wifi traffic
|
// Add cost of wifi traffic
|
||||||
final long wifiRx = u.getNetworkActivityCount(NETWORK_WIFI_RX_BYTES, mStatsType);
|
final long wifiRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, mStatsType);
|
||||||
final long wifiTx = u.getNetworkActivityCount(NETWORK_WIFI_TX_BYTES, mStatsType);
|
final long wifiTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, mStatsType);
|
||||||
p = (wifiRx + wifiTx) * wifiPowerPerByte;
|
final long wifiRxB = u.getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, mStatsType);
|
||||||
|
final long wifiTxB = u.getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, mStatsType);
|
||||||
|
p = (wifiRx + wifiTx) * wifiPowerPerPacket;
|
||||||
power += p;
|
power += p;
|
||||||
if (DEBUG && p != 0) Log.i(TAG, String.format("wifi power=%.2f", p));
|
if (DEBUG && p != 0) Log.i(TAG, String.format("wifi power=%.2f", p));
|
||||||
|
|
||||||
@@ -545,10 +549,14 @@ public class BatteryStatsHelper {
|
|||||||
app.wifiRunningTime = wifiRunningTimeMs;
|
app.wifiRunningTime = wifiRunningTimeMs;
|
||||||
app.cpuFgTime = cpuFgTime;
|
app.cpuFgTime = cpuFgTime;
|
||||||
app.wakeLockTime = wakelockTime;
|
app.wakeLockTime = wakelockTime;
|
||||||
app.mobileRxBytes = mobileRx;
|
app.mobileRxPackets = mobileRx;
|
||||||
app.mobileTxBytes = mobileTx;
|
app.mobileTxPackets = mobileTx;
|
||||||
app.wifiRxBytes = wifiRx;
|
app.wifiRxPackets = wifiRx;
|
||||||
app.wifiTxBytes = wifiTx;
|
app.wifiTxPackets = wifiTx;
|
||||||
|
app.mobileRxBytes = mobileRxB;
|
||||||
|
app.mobileTxBytes = mobileTxB;
|
||||||
|
app.wifiRxBytes = wifiRxB;
|
||||||
|
app.wifiTxBytes = wifiTxB;
|
||||||
if (u.getUid() == Process.WIFI_UID) {
|
if (u.getUid() == Process.WIFI_UID) {
|
||||||
mWifiSippers.add(app);
|
mWifiSippers.add(app);
|
||||||
} else if (u.getUid() == Process.BLUETOOTH_UID) {
|
} else if (u.getUid() == Process.BLUETOOTH_UID) {
|
||||||
@@ -670,6 +678,10 @@ public class BatteryStatsHelper {
|
|||||||
bs.wifiRunningTime += wbs.wifiRunningTime;
|
bs.wifiRunningTime += wbs.wifiRunningTime;
|
||||||
bs.cpuFgTime += wbs.cpuFgTime;
|
bs.cpuFgTime += wbs.cpuFgTime;
|
||||||
bs.wakeLockTime += wbs.wakeLockTime;
|
bs.wakeLockTime += wbs.wakeLockTime;
|
||||||
|
bs.mobileRxPackets += wbs.mobileRxPackets;
|
||||||
|
bs.mobileTxPackets += wbs.mobileTxPackets;
|
||||||
|
bs.wifiRxPackets += wbs.wifiRxPackets;
|
||||||
|
bs.wifiTxPackets += wbs.wifiTxPackets;
|
||||||
bs.mobileRxBytes += wbs.mobileRxBytes;
|
bs.mobileRxBytes += wbs.mobileRxBytes;
|
||||||
bs.mobileTxBytes += wbs.mobileTxBytes;
|
bs.mobileTxBytes += wbs.mobileTxBytes;
|
||||||
bs.wifiRxBytes += wbs.wifiRxBytes;
|
bs.wifiRxBytes += wbs.wifiRxBytes;
|
||||||
@@ -743,33 +755,33 @@ public class BatteryStatsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return estimated power (in mAs) of sending a byte with the mobile radio.
|
* Return estimated power (in mAs) of sending or receiving a packet with the mobile radio.
|
||||||
*/
|
*/
|
||||||
private double getMobilePowerPerByte() {
|
private double getMobilePowerPerPacket() {
|
||||||
final long MOBILE_BPS = 200000; // TODO: Extract average bit rates from system
|
final long MOBILE_BPS = 200000; // TODO: Extract average bit rates from system
|
||||||
final double MOBILE_POWER = mPowerProfile.getAveragePower(PowerProfile.POWER_RADIO_ACTIVE)
|
final double MOBILE_POWER = mPowerProfile.getAveragePower(PowerProfile.POWER_RADIO_ACTIVE)
|
||||||
/ 3600;
|
/ 3600;
|
||||||
|
|
||||||
final long mobileRx = mStats.getNetworkActivityCount(NETWORK_MOBILE_RX_BYTES, mStatsType);
|
final long mobileRx = mStats.getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, mStatsType);
|
||||||
final long mobileTx = mStats.getNetworkActivityCount(NETWORK_MOBILE_TX_BYTES, mStatsType);
|
final long mobileTx = mStats.getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, mStatsType);
|
||||||
final long mobileData = mobileRx + mobileTx;
|
final long mobileData = mobileRx + mobileTx;
|
||||||
|
|
||||||
final long radioDataUptimeMs = mStats.getRadioDataUptime() / 1000;
|
final long radioDataUptimeMs = mStats.getRadioDataUptime() / 1000;
|
||||||
final long mobileBps = radioDataUptimeMs != 0
|
final double mobilePps = radioDataUptimeMs != 0
|
||||||
? mobileData * 8 * 1000 / radioDataUptimeMs
|
? mobileData / (double)radioDataUptimeMs
|
||||||
: MOBILE_BPS;
|
: (((double)MOBILE_BPS) / 8 / 2048);
|
||||||
|
|
||||||
return MOBILE_POWER / (mobileBps / 8);
|
return MOBILE_POWER / mobilePps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return estimated power (in mAs) of sending a byte with the Wi-Fi radio.
|
* Return estimated power (in mAs) of sending a byte with the Wi-Fi radio.
|
||||||
*/
|
*/
|
||||||
private double getWifiPowerPerByte() {
|
private double getWifiPowerPerPacket() {
|
||||||
final long WIFI_BPS = 1000000; // TODO: Extract average bit rates from system
|
final long WIFI_BPS = 1000000; // TODO: Extract average bit rates from system
|
||||||
final double WIFI_POWER = mPowerProfile.getAveragePower(PowerProfile.POWER_WIFI_ACTIVE)
|
final double WIFI_POWER = mPowerProfile.getAveragePower(PowerProfile.POWER_WIFI_ACTIVE)
|
||||||
/ 3600;
|
/ 3600;
|
||||||
return WIFI_POWER / (WIFI_BPS / 8);
|
return WIFI_POWER / (((double)WIFI_BPS) / 8 / 2048);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMiscUsage() {
|
private void processMiscUsage() {
|
||||||
|
@@ -322,8 +322,8 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
|
|||||||
case R.string.usage_type_data_send:
|
case R.string.usage_type_data_send:
|
||||||
case R.string.usage_type_data_wifi_recv:
|
case R.string.usage_type_data_wifi_recv:
|
||||||
case R.string.usage_type_data_wifi_send:
|
case R.string.usage_type_data_wifi_send:
|
||||||
final long bytes = (long) (mValues[i]);
|
final long packets = (long) (mValues[i]);
|
||||||
value = Formatter.formatFileSize(getActivity(), bytes);
|
value = Long.toString(packets);
|
||||||
break;
|
break;
|
||||||
case R.string.usage_type_no_coverage:
|
case R.string.usage_type_no_coverage:
|
||||||
final int percentage = (int) Math.floor(mValues[i]);
|
final int percentage = (int) Math.floor(mValues[i]);
|
||||||
|
Reference in New Issue
Block a user