diff options
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 7ebbdfb..709ec12 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -244,7 +244,7 @@ static int set_battery_soc_leds(int soc) static int old_color = 0; for (i = 0; i < (int)ARRAY_SIZE(soc_leds); i++) { - if (soc < soc_leds[i].soc) + if (soc <= soc_leds[i].soc) break; } color = soc_leds[i].color; @@ -666,14 +666,17 @@ static void handle_input_state(struct charger *charger, int64_t now) static void handle_power_supply_state(struct charger *charger, int64_t now) { static int old_soc = 0; - int soc; + int soc = 0; if (!charger->have_battery_state) return; healthd_board_mode_charger_battery_update(batt_prop); - soc = get_battery_capacity(); + if (batt_prop && batt_prop->batteryLevel >= 0) { + soc = batt_prop->batteryLevel; + } + if (old_soc != soc) { old_soc = soc; set_battery_soc_leds(soc); |