Loading core/java/android/os/BatteryStats.java +32 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. */ Loading Loading @@ -2996,7 +3004,8 @@ public abstract class BatteryStats implements Parcelable { totalRealtime / 1000, totalUptime / 1000, getStartClockTime(), whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000, getEstimatedBatteryCapacity()); getEstimatedBatteryCapacity(), getMinLearnedBatteryCapacity(), getMaxLearnedBatteryCapacity()); // Calculate wakelock times across all uids. Loading Loading @@ -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: "); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +28 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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()); } Loading Loading @@ -8832,6 +8841,8 @@ public class BatteryStatsImpl extends BatteryStats { } else { mEstimatedBatteryCapacity = -1; } mMinLearnedBatteryCapacity = -1; mMaxLearnedBatteryCapacity = -1; mInteractiveTimer.reset(false); mPowerSaveModeEnabledTimer.reset(false); mLastIdleTimeStart = elapsedRealtimeMillis; Loading Loading @@ -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() { Loading Loading @@ -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(); Loading Loading @@ -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()); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading
core/java/android/os/BatteryStats.java +32 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. */ Loading Loading @@ -2996,7 +3004,8 @@ public abstract class BatteryStats implements Parcelable { totalRealtime / 1000, totalUptime / 1000, getStartClockTime(), whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000, getEstimatedBatteryCapacity()); getEstimatedBatteryCapacity(), getMinLearnedBatteryCapacity(), getMaxLearnedBatteryCapacity()); // Calculate wakelock times across all uids. Loading Loading @@ -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: "); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +28 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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()); } Loading Loading @@ -8832,6 +8841,8 @@ public class BatteryStatsImpl extends BatteryStats { } else { mEstimatedBatteryCapacity = -1; } mMinLearnedBatteryCapacity = -1; mMaxLearnedBatteryCapacity = -1; mInteractiveTimer.reset(false); mPowerSaveModeEnabledTimer.reset(false); mLastIdleTimeStart = elapsedRealtimeMillis; Loading Loading @@ -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() { Loading Loading @@ -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(); Loading Loading @@ -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()); Loading Loading @@ -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); Loading Loading @@ -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); Loading