Merge "DO NOT MERGE Cherry-pick of Ie4026a7c back to GB" into gingerbread
This commit is contained in:
@@ -132,6 +132,7 @@ public abstract class BatteryStats implements Parcelable {
|
||||
private static final String NETWORK_DATA = "nt";
|
||||
private static final String USER_ACTIVITY_DATA = "ua";
|
||||
private static final String BATTERY_DATA = "bt";
|
||||
private static final String BATTERY_DISCHARGE_DATA = "dc";
|
||||
private static final String BATTERY_LEVEL_DATA = "lv";
|
||||
private static final String WIFI_LOCK_DATA = "wfl";
|
||||
private static final String MISC_DATA = "m";
|
||||
@@ -800,6 +801,30 @@ public abstract class BatteryStats implements Parcelable {
|
||||
*/
|
||||
public abstract int getHighDischargeAmountSinceCharge();
|
||||
|
||||
/**
|
||||
* Get the amount the battery has discharged while the screen was on,
|
||||
* since the last time power was unplugged.
|
||||
*/
|
||||
public abstract int getDischargeAmountScreenOn();
|
||||
|
||||
/**
|
||||
* Get the amount the battery has discharged while the screen was on,
|
||||
* since the last time the device was charged.
|
||||
*/
|
||||
public abstract int getDischargeAmountScreenOnSinceCharge();
|
||||
|
||||
/**
|
||||
* Get the amount the battery has discharged while the screen was off,
|
||||
* since the last time power was unplugged.
|
||||
*/
|
||||
public abstract int getDischargeAmountScreenOff();
|
||||
|
||||
/**
|
||||
* Get the amount the battery has discharged while the screen was off,
|
||||
* since the last time the device was charged.
|
||||
*/
|
||||
public abstract int getDischargeAmountScreenOffSinceCharge();
|
||||
|
||||
/**
|
||||
* Returns the total, last, or current battery uptime in microseconds.
|
||||
*
|
||||
@@ -1095,6 +1120,17 @@ public abstract class BatteryStats implements Parcelable {
|
||||
getDischargeCurrentLevel());
|
||||
}
|
||||
|
||||
if (which == STATS_SINCE_UNPLUGGED) {
|
||||
dumpLine(pw, 0 /* uid */, category, BATTERY_DISCHARGE_DATA,
|
||||
getDischargeStartLevel()-getDischargeCurrentLevel(),
|
||||
getDischargeStartLevel()-getDischargeCurrentLevel(),
|
||||
getDischargeAmountScreenOn(), getDischargeAmountScreenOff());
|
||||
} else {
|
||||
dumpLine(pw, 0 /* uid */, category, BATTERY_DISCHARGE_DATA,
|
||||
getLowDischargeAmountSinceCharge(), getHighDischargeAmountSinceCharge(),
|
||||
getDischargeAmountScreenOn(), getDischargeAmountScreenOff());
|
||||
}
|
||||
|
||||
if (reqUid < 0) {
|
||||
Map<String, ? extends BatteryStats.Timer> kernelWakelocks = getKernelWakelockStats();
|
||||
if (kernelWakelocks.size() > 0) {
|
||||
@@ -1451,6 +1487,10 @@ public abstract class BatteryStats implements Parcelable {
|
||||
pw.print(prefix); pw.print(" Last discharge cycle end level: ");
|
||||
pw.println(getDischargeCurrentLevel());
|
||||
}
|
||||
pw.print(prefix); pw.print(" Amount discharged while screen on: ");
|
||||
pw.println(getDischargeAmountScreenOn());
|
||||
pw.print(prefix); pw.print(" Amount discharged while screen off: ");
|
||||
pw.println(getDischargeAmountScreenOff());
|
||||
pw.println(" ");
|
||||
} else {
|
||||
pw.print(prefix); pw.println(" Device battery use since last full charge");
|
||||
@@ -1458,6 +1498,10 @@ public abstract class BatteryStats implements Parcelable {
|
||||
pw.println(getLowDischargeAmountSinceCharge());
|
||||
pw.print(prefix); pw.print(" Amount discharged (upper bound): ");
|
||||
pw.println(getHighDischargeAmountSinceCharge());
|
||||
pw.print(prefix); pw.print(" Amount discharged while screen on: ");
|
||||
pw.println(getDischargeAmountScreenOnSinceCharge());
|
||||
pw.print(prefix); pw.print(" Amount discharged while screen off: ");
|
||||
pw.println(getDischargeAmountScreenOffSinceCharge());
|
||||
pw.println(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
|
||||
|
||||
// Current on-disk Parcel version
|
||||
private static final int VERSION = 52;
|
||||
private static final int VERSION = 53;
|
||||
|
||||
// Maximum number of items we will record in the history.
|
||||
private static final int MAX_HISTORY_ITEMS = 2000;
|
||||
@@ -235,6 +235,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
int mDischargeCurrentLevel;
|
||||
int mLowDischargeAmountSinceCharge;
|
||||
int mHighDischargeAmountSinceCharge;
|
||||
int mDischargeScreenOnUnplugLevel;
|
||||
int mDischargeScreenOffUnplugLevel;
|
||||
int mDischargeAmountScreenOn;
|
||||
int mDischargeAmountScreenOnSinceCharge;
|
||||
int mDischargeAmountScreenOff;
|
||||
int mDischargeAmountScreenOffSinceCharge;
|
||||
|
||||
long mLastWriteTime = 0; // Milliseconds
|
||||
|
||||
@@ -1565,6 +1571,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
// Fake a wake lock, so we consider the device waked as long
|
||||
// as the screen is on.
|
||||
noteStartWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
||||
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevels(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,6 +1592,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
|
||||
noteStopWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
||||
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevels(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3897,8 +3913,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mDischargeStartLevel = 0;
|
||||
mDischargeUnplugLevel = 0;
|
||||
mDischargeCurrentLevel = 0;
|
||||
mLowDischargeAmountSinceCharge = 0;
|
||||
mHighDischargeAmountSinceCharge = 0;
|
||||
initDischarge();
|
||||
}
|
||||
|
||||
public BatteryStatsImpl(Parcel p) {
|
||||
@@ -3968,6 +3983,15 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mUnpluggedBatteryUptime = getBatteryUptimeLocked(mUptimeStart);
|
||||
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(mRealtimeStart);
|
||||
}
|
||||
|
||||
void initDischarge() {
|
||||
mLowDischargeAmountSinceCharge = 0;
|
||||
mHighDischargeAmountSinceCharge = 0;
|
||||
mDischargeAmountScreenOn = 0;
|
||||
mDischargeAmountScreenOnSinceCharge = 0;
|
||||
mDischargeAmountScreenOff = 0;
|
||||
mDischargeAmountScreenOffSinceCharge = 0;
|
||||
}
|
||||
|
||||
public void resetAllStatsLocked() {
|
||||
mStartCount = 0;
|
||||
@@ -4005,11 +4029,33 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mKernelWakelockStats.clear();
|
||||
}
|
||||
|
||||
mLowDischargeAmountSinceCharge = 0;
|
||||
mHighDischargeAmountSinceCharge = 0;
|
||||
initDischarge();
|
||||
|
||||
clearHistoryLocked();
|
||||
}
|
||||
|
||||
void updateDischargeScreenLevels(boolean oldScreenOn, boolean newScreenOn) {
|
||||
if (oldScreenOn) {
|
||||
int diff = mDischargeScreenOnUnplugLevel - mDischargeCurrentLevel;
|
||||
if (diff > 0) {
|
||||
mDischargeAmountScreenOn += diff;
|
||||
mDischargeAmountScreenOnSinceCharge += diff;
|
||||
}
|
||||
} else {
|
||||
int diff = mDischargeScreenOffUnplugLevel - mDischargeCurrentLevel;
|
||||
if (diff > 0) {
|
||||
mDischargeAmountScreenOff += diff;
|
||||
mDischargeAmountScreenOffSinceCharge += diff;
|
||||
}
|
||||
}
|
||||
if (newScreenOn) {
|
||||
mDischargeScreenOnUnplugLevel = mDischargeCurrentLevel;
|
||||
mDischargeScreenOffUnplugLevel = 0;
|
||||
} else {
|
||||
mDischargeScreenOnUnplugLevel = 0;
|
||||
mDischargeScreenOffUnplugLevel = mDischargeCurrentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
void setOnBattery(boolean onBattery, int oldStatus, int level) {
|
||||
synchronized(this) {
|
||||
@@ -4045,6 +4091,15 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mUnpluggedBatteryUptime = getBatteryUptimeLocked(uptime);
|
||||
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(realtime);
|
||||
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
||||
if (mScreenOn) {
|
||||
mDischargeScreenOnUnplugLevel = level;
|
||||
mDischargeScreenOffUnplugLevel = 0;
|
||||
} else {
|
||||
mDischargeScreenOnUnplugLevel = 0;
|
||||
mDischargeScreenOffUnplugLevel = level;
|
||||
}
|
||||
mDischargeAmountScreenOn = 0;
|
||||
mDischargeAmountScreenOff = 0;
|
||||
doUnplugLocked(mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
|
||||
} else {
|
||||
updateKernelWakelocksLocked();
|
||||
@@ -4060,6 +4115,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
||||
mHighDischargeAmountSinceCharge += mDischargeUnplugLevel-level;
|
||||
}
|
||||
updateDischargeScreenLevels(mScreenOn, mScreenOn);
|
||||
doPlugLocked(getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
|
||||
}
|
||||
if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) {
|
||||
@@ -4348,6 +4404,50 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDischargeAmountScreenOn() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOn;
|
||||
if (mOnBattery && mScreenOn
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOnUnplugLevel) {
|
||||
val += mDischargeScreenOnUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDischargeAmountScreenOnSinceCharge() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOnSinceCharge;
|
||||
if (mOnBattery && mScreenOn
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOnUnplugLevel) {
|
||||
val += mDischargeScreenOnUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDischargeAmountScreenOff() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOff;
|
||||
if (mOnBattery && !mScreenOn
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOffUnplugLevel) {
|
||||
val += mDischargeScreenOffUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDischargeAmountScreenOffSinceCharge() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOffSinceCharge;
|
||||
if (mOnBattery && !mScreenOn
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOffUnplugLevel) {
|
||||
val += mDischargeScreenOffUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCpuSpeedSteps() {
|
||||
@@ -4654,7 +4754,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mDischargeCurrentLevel = in.readInt();
|
||||
mLowDischargeAmountSinceCharge = in.readInt();
|
||||
mHighDischargeAmountSinceCharge = in.readInt();
|
||||
|
||||
mDischargeAmountScreenOnSinceCharge = in.readInt();
|
||||
mDischargeAmountScreenOffSinceCharge = in.readInt();
|
||||
|
||||
mStartCount++;
|
||||
|
||||
mScreenOn = false;
|
||||
@@ -4849,6 +4951,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
out.writeInt(mDischargeCurrentLevel);
|
||||
out.writeInt(getLowDischargeAmountSinceCharge());
|
||||
out.writeInt(getHighDischargeAmountSinceCharge());
|
||||
out.writeInt(getDischargeAmountScreenOnSinceCharge());
|
||||
out.writeInt(getDischargeAmountScreenOffSinceCharge());
|
||||
|
||||
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
@@ -5088,6 +5192,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mDischargeCurrentLevel = in.readInt();
|
||||
mLowDischargeAmountSinceCharge = in.readInt();
|
||||
mHighDischargeAmountSinceCharge = in.readInt();
|
||||
mDischargeAmountScreenOn = in.readInt();
|
||||
mDischargeAmountScreenOnSinceCharge = in.readInt();
|
||||
mDischargeAmountScreenOff = in.readInt();
|
||||
mDischargeAmountScreenOffSinceCharge = in.readInt();
|
||||
mLastWriteTime = in.readLong();
|
||||
|
||||
mMobileDataRx[STATS_LAST] = in.readLong();
|
||||
@@ -5189,6 +5297,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
out.writeInt(mDischargeCurrentLevel);
|
||||
out.writeInt(mLowDischargeAmountSinceCharge);
|
||||
out.writeInt(mHighDischargeAmountSinceCharge);
|
||||
out.writeInt(mDischargeAmountScreenOn);
|
||||
out.writeInt(mDischargeAmountScreenOnSinceCharge);
|
||||
out.writeInt(mDischargeAmountScreenOff);
|
||||
out.writeInt(mDischargeAmountScreenOffSinceCharge);
|
||||
out.writeLong(mLastWriteTime);
|
||||
|
||||
out.writeLong(getMobileTcpBytesReceived(STATS_SINCE_UNPLUGGED));
|
||||
|
||||
Reference in New Issue
Block a user