mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
charger v2: Don't report 0 battery charge if we're running off battery
Some batteries report 0 charge when their charge level is very low. powerd has a special interpretation of 0 charge, which causes low-battery shutdown to not occur. Work-around this powerd behavior by never reporting 0 charge if our battery is discharging. BUG=chrome-os-partner:35188 TEST=Manual on Samus. Drain battery to critically low level, verify that powerd correctly shuts down system. BRANCH=Samus Change-Id: I6bd50e038f0e22de7e7de754fa2ea459dc662f35 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241101 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
94515d9ee2
commit
93bb7195a8
@@ -186,8 +186,17 @@ static void update_dynamic_battery_info(void)
|
||||
if (!(curr.batt.flags & BATT_FLAG_BAD_CURRENT))
|
||||
*memmap_rate = ABS(curr.batt.current);
|
||||
|
||||
if (!(curr.batt.flags & BATT_FLAG_BAD_REMAINING_CAPACITY))
|
||||
*memmap_cap = curr.batt.remaining_capacity;
|
||||
if (!(curr.batt.flags & BATT_FLAG_BAD_REMAINING_CAPACITY)) {
|
||||
/*
|
||||
* If we're running off the battery, it must have some charge.
|
||||
* Don't report zero charge, as that has special meaning
|
||||
* to Chrome OS powerd.
|
||||
*/
|
||||
if (curr.batt.remaining_capacity == 0 && !curr.batt_is_charging)
|
||||
*memmap_cap = 1;
|
||||
else
|
||||
*memmap_cap = curr.batt.remaining_capacity;
|
||||
}
|
||||
|
||||
cap_changed = 0;
|
||||
if (!(curr.batt.flags & BATT_FLAG_BAD_FULL_CAPACITY) &&
|
||||
|
||||
Reference in New Issue
Block a user