power: Preserve battery current and charge averages.
In order to make battery time-to-empty and time-to-full
estimates less variable, split the rolling average of
current samples into separate averages collected while on
line and battery power. Also stop clearing the previous
collected-on-battery samples when resuming from suspend or
switching between power sources. Continue clearing previous
collected-on-charger samples, since the current delivered is
highly variable.
Record signed current samples instead of the
previously-unsigned ones so that averages will remain
accurate while alternating between charging and discharging
with a low-power charger connected.
Additionally, introduce new max_charge_samples and
max_current_samples prefs that control the number of samples
that are averaged together.
BUG=chromium:349973
TEST=updated existing tests; also manually verified on lumpy
Change-Id: Iba52048cfb76b1dfcf441e544f71513e81f3caff
Reviewed-on: https://chromium-review.googlesource.com/203462
Tested-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
8 files changed