Merge "Add min and max learned battery capacity to batterystats." into oc-dev
This commit is contained in:
@@ -1365,8 +1365,6 @@ public abstract class BatteryStats implements Parcelable {
|
||||
public static final int EVENT_WAKEUP_AP = 0x0013;
|
||||
// Event for reporting that a specific partial wake lock has been held for a long duration.
|
||||
public static final int EVENT_LONG_WAKE_LOCK = 0x0014;
|
||||
// Event reporting the new estimated (learned) capacity of the battery in mAh.
|
||||
public static final int EVENT_ESTIMATED_BATTERY_CAP = 0x0015;
|
||||
|
||||
// Number of event types.
|
||||
public static final int EVENT_COUNT = 0x0016;
|
||||
@@ -2500,6 +2498,16 @@ public abstract class BatteryStats implements Parcelable {
|
||||
*/
|
||||
public abstract int getEstimatedBatteryCapacity();
|
||||
|
||||
/**
|
||||
* @return The minimum learned battery capacity in uAh.
|
||||
*/
|
||||
public abstract int getMinLearnedBatteryCapacity();
|
||||
|
||||
/**
|
||||
* @return The maximum learned battery capacity in uAh.
|
||||
*/
|
||||
public abstract int getMaxLearnedBatteryCapacity() ;
|
||||
|
||||
/**
|
||||
* Return the array of discharge step durations.
|
||||
*/
|
||||
@@ -2990,13 +2998,14 @@ public abstract class BatteryStats implements Parcelable {
|
||||
final String category = STAT_NAMES[which];
|
||||
|
||||
// Dump "battery" stat
|
||||
dumpLine(pw, 0 /* uid */, category, BATTERY_DATA,
|
||||
dumpLine(pw, 0 /* uid */, category, BATTERY_DATA,
|
||||
which == STATS_SINCE_CHARGED ? getStartCount() : "N/A",
|
||||
whichBatteryRealtime / 1000, whichBatteryUptime / 1000,
|
||||
totalRealtime / 1000, totalUptime / 1000,
|
||||
getStartClockTime(),
|
||||
whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000,
|
||||
getEstimatedBatteryCapacity());
|
||||
getEstimatedBatteryCapacity(),
|
||||
getMinLearnedBatteryCapacity(), getMaxLearnedBatteryCapacity());
|
||||
|
||||
|
||||
// Calculate wakelock times across all uids.
|
||||
@@ -3583,6 +3592,25 @@ public abstract class BatteryStats implements Parcelable {
|
||||
pw.println(sb.toString());
|
||||
}
|
||||
|
||||
final int minLearnedBatteryCapacity = getMinLearnedBatteryCapacity();
|
||||
if (minLearnedBatteryCapacity > 0) {
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
sb.append(" Min learned battery capacity: ");
|
||||
sb.append(BatteryStatsHelper.makemAh(minLearnedBatteryCapacity / 1000));
|
||||
sb.append(" mAh");
|
||||
pw.println(sb.toString());
|
||||
}
|
||||
final int maxLearnedBatteryCapacity = getMaxLearnedBatteryCapacity();
|
||||
if (maxLearnedBatteryCapacity > 0) {
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
sb.append(" Max learned battery capacity: ");
|
||||
sb.append(BatteryStatsHelper.makemAh(maxLearnedBatteryCapacity / 1000));
|
||||
sb.append(" mAh");
|
||||
pw.println(sb.toString());
|
||||
}
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
sb.append(" Time on battery: ");
|
||||
|
||||
@@ -114,7 +114,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
|
||||
|
||||
// Current on-disk Parcel version
|
||||
private static final int VERSION = 154 + (USE_OLD_HISTORY ? 1000 : 0);
|
||||
private static final int VERSION = 155 + (USE_OLD_HISTORY ? 1000 : 0);
|
||||
|
||||
// Maximum number of items we will record in the history.
|
||||
private static final int MAX_HISTORY_ITEMS = 2000;
|
||||
@@ -565,9 +565,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
private int mEstimatedBatteryCapacity = -1;
|
||||
|
||||
// Last learned capacity reported by BatteryService in
|
||||
// setBatteryState().
|
||||
private int mLastChargeFullUAh = 0;
|
||||
private int mMinLearnedBatteryCapacity = -1;
|
||||
private int mMaxLearnedBatteryCapacity = -1;
|
||||
|
||||
private final NetworkStats.Entry mTmpNetworkStatsEntry = new NetworkStats.Entry();
|
||||
|
||||
@@ -605,6 +604,16 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
return mEstimatedBatteryCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinLearnedBatteryCapacity() {
|
||||
return mMinLearnedBatteryCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLearnedBatteryCapacity() {
|
||||
return mMaxLearnedBatteryCapacity;
|
||||
}
|
||||
|
||||
public BatteryStatsImpl() {
|
||||
this(new SystemClocks());
|
||||
}
|
||||
@@ -8832,6 +8841,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
} else {
|
||||
mEstimatedBatteryCapacity = -1;
|
||||
}
|
||||
mMinLearnedBatteryCapacity = -1;
|
||||
mMaxLearnedBatteryCapacity = -1;
|
||||
mInteractiveTimer.reset(false);
|
||||
mPowerSaveModeEnabledTimer.reset(false);
|
||||
mLastIdleTimeStart = elapsedRealtimeMillis;
|
||||
@@ -10193,15 +10204,12 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mRecordingHistory = DEBUG;
|
||||
}
|
||||
|
||||
if (differsByMoreThan(chargeFullUAh, mLastChargeFullUAh, 100)) {
|
||||
mLastChargeFullUAh = chargeFullUAh;
|
||||
addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_ESTIMATED_BATTERY_CAP,
|
||||
"", chargeFullUAh / 1000);
|
||||
if (mMinLearnedBatteryCapacity == -1) {
|
||||
mMinLearnedBatteryCapacity = chargeFullUAh;
|
||||
} else {
|
||||
Math.min(mMinLearnedBatteryCapacity, chargeFullUAh);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean differsByMoreThan(int left, int right, int diff) {
|
||||
return Math.abs(left - right) > diff;
|
||||
mMaxLearnedBatteryCapacity = Math.max(mMaxLearnedBatteryCapacity, chargeFullUAh);
|
||||
}
|
||||
|
||||
public long getAwakeTimeBattery() {
|
||||
@@ -10814,6 +10822,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mDischargeCurrentLevel = in.readInt();
|
||||
mCurrentBatteryLevel = in.readInt();
|
||||
mEstimatedBatteryCapacity = in.readInt();
|
||||
mMinLearnedBatteryCapacity = in.readInt();
|
||||
mMaxLearnedBatteryCapacity = in.readInt();
|
||||
mLowDischargeAmountSinceCharge = in.readInt();
|
||||
mHighDischargeAmountSinceCharge = in.readInt();
|
||||
mDischargeAmountScreenOnSinceCharge = in.readInt();
|
||||
@@ -11189,6 +11199,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
out.writeInt(mDischargeCurrentLevel);
|
||||
out.writeInt(mCurrentBatteryLevel);
|
||||
out.writeInt(mEstimatedBatteryCapacity);
|
||||
out.writeInt(mMinLearnedBatteryCapacity);
|
||||
out.writeInt(mMaxLearnedBatteryCapacity);
|
||||
out.writeInt(getLowDischargeAmountSinceCharge());
|
||||
out.writeInt(getHighDischargeAmountSinceCharge());
|
||||
out.writeInt(getDischargeAmountScreenOnSinceCharge());
|
||||
@@ -11581,6 +11593,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mRealtimeStart = in.readLong();
|
||||
mOnBattery = in.readInt() != 0;
|
||||
mEstimatedBatteryCapacity = in.readInt();
|
||||
mMinLearnedBatteryCapacity = in.readInt();
|
||||
mMaxLearnedBatteryCapacity = in.readInt();
|
||||
mOnBatteryInternal = false; // we are no longer really running.
|
||||
mOnBatteryTimeBase.readFromParcel(in);
|
||||
mOnBatteryScreenOffTimeBase.readFromParcel(in);
|
||||
@@ -11775,6 +11789,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
out.writeLong(mRealtimeStart);
|
||||
out.writeInt(mOnBattery ? 1 : 0);
|
||||
out.writeInt(mEstimatedBatteryCapacity);
|
||||
out.writeInt(mMinLearnedBatteryCapacity);
|
||||
out.writeInt(mMaxLearnedBatteryCapacity);
|
||||
mOnBatteryTimeBase.writeToParcel(out, uSecUptime, uSecRealtime);
|
||||
mOnBatteryScreenOffTimeBase.writeToParcel(out, uSecUptime, uSecRealtime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user