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;
}