Fix not to defer processing lowbat on realoff 54/237854/1
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 6 Jul 2020 04:46:31 +0000 (13:46 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 6 Jul 2020 06:03:44 +0000 (06:03 +0000)
If uevent continues to occur shorter than 1.5s on realoff state,
it defers processing lowbattery infinitely and makes poweroff sequence
unreachable. For that case, added exception to process lowbat
immediately when the battery state is realoff.

Change-Id: I90354fa261f73aa2e5b8451078576fcc070166a8
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
(cherry picked from commit c07e2dda8467cd2df6ccea80f3449e1a05993f31)

src/battery/lowbat-handler.c

index 7e56f44..d3aa3b4 100644 (file)
@@ -740,15 +740,25 @@ static gboolean low_battery_charge_status(void *data)
 
 static int lowbat_execute(void *data)
 {
+       int capacity = *(int *)data;
+
        /* In battery kernel side, it has a requirement that battery charging event must get quickly.
         * So deviced receives the discharging and charging event within 1.5 sec,
         * added a timer to wait for the second signal, if there is no second signal then execute
         * the lowbat_execute.
         */
-       if (low_batt_sig_timer)
+       if (low_batt_sig_timer) {
                g_source_remove(low_batt_sig_timer);
+               low_batt_sig_timer = 0;
+       }
 
-       low_batt_sig_timer = g_timeout_add(1500, low_battery_charge_status, data);
+       /* Do lowbat_process immediately rather deferring it when poweroff is needed.
+        * This prevents poweroff from being delayed infinitely when the uevent continues
+        * to occur shorter than 1.5 seconds on realoff capacity */
+       if (capacity <= battery_info.realoff)
+               low_battery_charge_status(data);
+       else
+               low_batt_sig_timer = g_timeout_add(1500, low_battery_charge_status, data);
 
        return 0;
 }