am 5ff79c3b: Merge "DO NOT MERGE Cherry-pick of Ie4026a7c back to GB" into gingerbread
* commit '5ff79c3b06d7087153617dc973491fc890700af5': DO NOT MERGE Cherry-pick of Ie4026a7c back to GB
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 NETWORK_DATA = "nt";
|
||||||
private static final String USER_ACTIVITY_DATA = "ua";
|
private static final String USER_ACTIVITY_DATA = "ua";
|
||||||
private static final String BATTERY_DATA = "bt";
|
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 BATTERY_LEVEL_DATA = "lv";
|
||||||
private static final String WIFI_LOCK_DATA = "wfl";
|
private static final String WIFI_LOCK_DATA = "wfl";
|
||||||
private static final String MISC_DATA = "m";
|
private static final String MISC_DATA = "m";
|
||||||
@@ -800,6 +801,30 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public abstract int getHighDischargeAmountSinceCharge();
|
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.
|
* Returns the total, last, or current battery uptime in microseconds.
|
||||||
*
|
*
|
||||||
@@ -1095,6 +1120,17 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
getDischargeCurrentLevel());
|
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) {
|
if (reqUid < 0) {
|
||||||
Map<String, ? extends BatteryStats.Timer> kernelWakelocks = getKernelWakelockStats();
|
Map<String, ? extends BatteryStats.Timer> kernelWakelocks = getKernelWakelockStats();
|
||||||
if (kernelWakelocks.size() > 0) {
|
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.print(prefix); pw.print(" Last discharge cycle end level: ");
|
||||||
pw.println(getDischargeCurrentLevel());
|
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(" ");
|
pw.println(" ");
|
||||||
} else {
|
} else {
|
||||||
pw.print(prefix); pw.println(" Device battery use since last full charge");
|
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.println(getLowDischargeAmountSinceCharge());
|
||||||
pw.print(prefix); pw.print(" Amount discharged (upper bound): ");
|
pw.print(prefix); pw.print(" Amount discharged (upper bound): ");
|
||||||
pw.println(getHighDischargeAmountSinceCharge());
|
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(" ");
|
pw.println(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
|
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
|
||||||
|
|
||||||
// Current on-disk Parcel version
|
// 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.
|
// Maximum number of items we will record in the history.
|
||||||
private static final int MAX_HISTORY_ITEMS = 2000;
|
private static final int MAX_HISTORY_ITEMS = 2000;
|
||||||
@@ -235,6 +235,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
int mDischargeCurrentLevel;
|
int mDischargeCurrentLevel;
|
||||||
int mLowDischargeAmountSinceCharge;
|
int mLowDischargeAmountSinceCharge;
|
||||||
int mHighDischargeAmountSinceCharge;
|
int mHighDischargeAmountSinceCharge;
|
||||||
|
int mDischargeScreenOnUnplugLevel;
|
||||||
|
int mDischargeScreenOffUnplugLevel;
|
||||||
|
int mDischargeAmountScreenOn;
|
||||||
|
int mDischargeAmountScreenOnSinceCharge;
|
||||||
|
int mDischargeAmountScreenOff;
|
||||||
|
int mDischargeAmountScreenOffSinceCharge;
|
||||||
|
|
||||||
long mLastWriteTime = 0; // Milliseconds
|
long mLastWriteTime = 0; // Milliseconds
|
||||||
|
|
||||||
@@ -1567,6 +1573,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
// Fake a wake lock, so we consider the device waked as long
|
// Fake a wake lock, so we consider the device waked as long
|
||||||
// as the screen is on.
|
// as the screen is on.
|
||||||
noteStartWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
noteStartWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
||||||
|
|
||||||
|
// Update discharge amounts.
|
||||||
|
if (mOnBatteryInternal) {
|
||||||
|
updateDischargeScreenLevels(false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1583,6 +1594,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
noteStopWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
noteStopWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
|
||||||
|
|
||||||
|
// Update discharge amounts.
|
||||||
|
if (mOnBatteryInternal) {
|
||||||
|
updateDischargeScreenLevels(true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3899,8 +3915,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mDischargeStartLevel = 0;
|
mDischargeStartLevel = 0;
|
||||||
mDischargeUnplugLevel = 0;
|
mDischargeUnplugLevel = 0;
|
||||||
mDischargeCurrentLevel = 0;
|
mDischargeCurrentLevel = 0;
|
||||||
mLowDischargeAmountSinceCharge = 0;
|
initDischarge();
|
||||||
mHighDischargeAmountSinceCharge = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatteryStatsImpl(Parcel p) {
|
public BatteryStatsImpl(Parcel p) {
|
||||||
@@ -3970,6 +3985,15 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mUnpluggedBatteryUptime = getBatteryUptimeLocked(mUptimeStart);
|
mUnpluggedBatteryUptime = getBatteryUptimeLocked(mUptimeStart);
|
||||||
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(mRealtimeStart);
|
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(mRealtimeStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initDischarge() {
|
||||||
|
mLowDischargeAmountSinceCharge = 0;
|
||||||
|
mHighDischargeAmountSinceCharge = 0;
|
||||||
|
mDischargeAmountScreenOn = 0;
|
||||||
|
mDischargeAmountScreenOnSinceCharge = 0;
|
||||||
|
mDischargeAmountScreenOff = 0;
|
||||||
|
mDischargeAmountScreenOffSinceCharge = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void resetAllStatsLocked() {
|
public void resetAllStatsLocked() {
|
||||||
mStartCount = 0;
|
mStartCount = 0;
|
||||||
@@ -4007,11 +4031,33 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mKernelWakelockStats.clear();
|
mKernelWakelockStats.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
mLowDischargeAmountSinceCharge = 0;
|
initDischarge();
|
||||||
mHighDischargeAmountSinceCharge = 0;
|
|
||||||
|
|
||||||
clearHistoryLocked();
|
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) {
|
void setOnBattery(boolean onBattery, int oldStatus, int level) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
@@ -4047,6 +4093,15 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mUnpluggedBatteryUptime = getBatteryUptimeLocked(uptime);
|
mUnpluggedBatteryUptime = getBatteryUptimeLocked(uptime);
|
||||||
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(realtime);
|
mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(realtime);
|
||||||
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
||||||
|
if (mScreenOn) {
|
||||||
|
mDischargeScreenOnUnplugLevel = level;
|
||||||
|
mDischargeScreenOffUnplugLevel = 0;
|
||||||
|
} else {
|
||||||
|
mDischargeScreenOnUnplugLevel = 0;
|
||||||
|
mDischargeScreenOffUnplugLevel = level;
|
||||||
|
}
|
||||||
|
mDischargeAmountScreenOn = 0;
|
||||||
|
mDischargeAmountScreenOff = 0;
|
||||||
doUnplugLocked(mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
|
doUnplugLocked(mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
|
||||||
} else {
|
} else {
|
||||||
updateKernelWakelocksLocked();
|
updateKernelWakelocksLocked();
|
||||||
@@ -4062,6 +4117,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
||||||
mHighDischargeAmountSinceCharge += mDischargeUnplugLevel-level;
|
mHighDischargeAmountSinceCharge += mDischargeUnplugLevel-level;
|
||||||
}
|
}
|
||||||
|
updateDischargeScreenLevels(mScreenOn, mScreenOn);
|
||||||
doPlugLocked(getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
|
doPlugLocked(getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
|
||||||
}
|
}
|
||||||
if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) {
|
if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) {
|
||||||
@@ -4350,6 +4406,50 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
return val;
|
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
|
@Override
|
||||||
public int getCpuSpeedSteps() {
|
public int getCpuSpeedSteps() {
|
||||||
@@ -4656,7 +4756,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mDischargeCurrentLevel = in.readInt();
|
mDischargeCurrentLevel = in.readInt();
|
||||||
mLowDischargeAmountSinceCharge = in.readInt();
|
mLowDischargeAmountSinceCharge = in.readInt();
|
||||||
mHighDischargeAmountSinceCharge = in.readInt();
|
mHighDischargeAmountSinceCharge = in.readInt();
|
||||||
|
mDischargeAmountScreenOnSinceCharge = in.readInt();
|
||||||
|
mDischargeAmountScreenOffSinceCharge = in.readInt();
|
||||||
|
|
||||||
mStartCount++;
|
mStartCount++;
|
||||||
|
|
||||||
mScreenOn = false;
|
mScreenOn = false;
|
||||||
@@ -4851,6 +4953,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
out.writeInt(mDischargeCurrentLevel);
|
out.writeInt(mDischargeCurrentLevel);
|
||||||
out.writeInt(getLowDischargeAmountSinceCharge());
|
out.writeInt(getLowDischargeAmountSinceCharge());
|
||||||
out.writeInt(getHighDischargeAmountSinceCharge());
|
out.writeInt(getHighDischargeAmountSinceCharge());
|
||||||
|
out.writeInt(getDischargeAmountScreenOnSinceCharge());
|
||||||
|
out.writeInt(getDischargeAmountScreenOffSinceCharge());
|
||||||
|
|
||||||
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
|
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
|
||||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||||
@@ -5090,6 +5194,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mDischargeCurrentLevel = in.readInt();
|
mDischargeCurrentLevel = in.readInt();
|
||||||
mLowDischargeAmountSinceCharge = in.readInt();
|
mLowDischargeAmountSinceCharge = in.readInt();
|
||||||
mHighDischargeAmountSinceCharge = in.readInt();
|
mHighDischargeAmountSinceCharge = in.readInt();
|
||||||
|
mDischargeAmountScreenOn = in.readInt();
|
||||||
|
mDischargeAmountScreenOnSinceCharge = in.readInt();
|
||||||
|
mDischargeAmountScreenOff = in.readInt();
|
||||||
|
mDischargeAmountScreenOffSinceCharge = in.readInt();
|
||||||
mLastWriteTime = in.readLong();
|
mLastWriteTime = in.readLong();
|
||||||
|
|
||||||
mMobileDataRx[STATS_LAST] = in.readLong();
|
mMobileDataRx[STATS_LAST] = in.readLong();
|
||||||
@@ -5191,6 +5299,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
out.writeInt(mDischargeCurrentLevel);
|
out.writeInt(mDischargeCurrentLevel);
|
||||||
out.writeInt(mLowDischargeAmountSinceCharge);
|
out.writeInt(mLowDischargeAmountSinceCharge);
|
||||||
out.writeInt(mHighDischargeAmountSinceCharge);
|
out.writeInt(mHighDischargeAmountSinceCharge);
|
||||||
|
out.writeInt(mDischargeAmountScreenOn);
|
||||||
|
out.writeInt(mDischargeAmountScreenOnSinceCharge);
|
||||||
|
out.writeInt(mDischargeAmountScreenOff);
|
||||||
|
out.writeInt(mDischargeAmountScreenOffSinceCharge);
|
||||||
out.writeLong(mLastWriteTime);
|
out.writeLong(mLastWriteTime);
|
||||||
|
|
||||||
out.writeLong(getMobileTcpBytesReceived(STATS_SINCE_UNPLUGGED));
|
out.writeLong(getMobileTcpBytesReceived(STATS_SINCE_UNPLUGGED));
|
||||||
|
|||||||
Reference in New Issue
Block a user