summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-09-30 16:45:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-30 16:45:26 +0000
commitc3014c8cf8932cb6a482e985edc7def97c50eede (patch)
tree60534b74fa1c28b2e0f4584ec387473c5a952f7f
parente3206407a5968dcf6690793f047bdfede0424df5 (diff)
parentfb3809ca63c17ac09162e08ee3eef0bdae16dc73 (diff)
downloadframeworks_base-c3014c8cf8932cb6a482e985edc7def97c50eede.zip
frameworks_base-c3014c8cf8932cb6a482e985edc7def97c50eede.tar.gz
frameworks_base-c3014c8cf8932cb6a482e985edc7def97c50eede.tar.bz2
Merge "Fix issue #17705755: Battery stats resets at incorrect times" into lmp-dev
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 42fc613..c00d209 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -6732,7 +6732,6 @@ public final class BatteryStatsImpl extends BatteryStats {
Message m = mHandler.obtainMessage(MSG_REPORT_POWER_CHANGE);
m.arg1 = onBattery ? 1 : 0;
mHandler.sendMessage(m);
- mOnBattery = mOnBatteryInternal = onBattery;
final long uptime = mSecUptime * 1000;
final long realtime = mSecRealtime * 1000;
@@ -6745,10 +6744,11 @@ public final class BatteryStatsImpl extends BatteryStats {
boolean reset = false;
if (!mNoAutoReset && (oldStatus == BatteryManager.BATTERY_STATUS_FULL
|| level >= 90
- || getLowDischargeAmountSinceCharge() >= 60)
- || (getHighDischargeAmountSinceCharge() >= 60
- && mHistoryBuffer.dataSize() >= MAX_HISTORY_BUFFER)) {
+ || (mDischargeCurrentLevel < 20 && level >= 80)
+ || (getHighDischargeAmountSinceCharge() >= 200
+ && mHistoryBuffer.dataSize() >= MAX_HISTORY_BUFFER))) {
Slog.i(TAG, "Resetting battery stats: level=" + level + " status=" + oldStatus
+ + " dischargeLevel=" + mDischargeCurrentLevel
+ " lowAmount=" + getLowDischargeAmountSinceCharge()
+ " highAmount=" + getHighDischargeAmountSinceCharge());
// Before we write, collect a snapshot of the final aggregated
@@ -6785,6 +6785,7 @@ public final class BatteryStatsImpl extends BatteryStats {
reset = true;
mNumDischargeStepDurations = 0;
}
+ mOnBattery = mOnBatteryInternal = onBattery;
mLastDischargeStepLevel = level;
mMinDischargeStepLevel = level;
mLastDischargeStepTime = -1;
@@ -6812,6 +6813,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mDischargeAmountScreenOff = 0;
updateTimeBasesLocked(true, !screenOn, uptime, realtime);
} else {
+ mOnBattery = mOnBatteryInternal = onBattery;
pullPendingStateUpdatesLocked();
mHistoryCur.batteryLevel = (byte)level;
mHistoryCur.states |= HistoryItem.STATE_BATTERY_PLUGGED_FLAG;