static dd_list *lpe;
static int scenario_count;
+static guint low_batt_sig_timer;
+
static int lowbat_monitor_init(void *data);
static int lowbat_initialized(void *data)
int status = BATTERY_DISABLED;
lowbat_initialized(&status);
+ if (low_batt_sig_timer) {
+ g_source_remove(low_batt_sig_timer);
+ low_batt_sig_timer = 0;
+ }
+}
+
+static gboolean low_battery_charge_status(void *data)
+{
+ low_batt_sig_timer = 0;
+ battery.charging_level = lowbat_monitor(data);
+ if (battery.charging_level > 0 && old_battery.charging_level != battery.charging_level) {
+ if (vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery.charging_level) < 0)
+ _E("Fail to set level.");
+ if (power_supply_broadcast(CHARGE_LEVEL_SIGNAL, battery.charging_level) < 0)
+ _E("power_supply_broadcast failed");
+ }
+ return G_SOURCE_REMOVE;
}
static int lowbat_execute(void *data)
{
- return lowbat_monitor(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) {
+ g_source_remove(low_batt_sig_timer);
+ low_batt_sig_timer = 0;
+ } else {
+ low_batt_sig_timer = g_timeout_add(1500, low_battery_charge_status, data);
+ }
+
+ return 0;
}
static const struct device_ops lowbat_device_ops = {
broadcasted = false;
}
battery.charging_level = lowbat_execute(data);
- if (battery.charging_level > 0 && old_battery.charging_level != battery.charging_level) {
- ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery.charging_level);
- if (ret < 0)
- _E("Failed to set vconf value for battery capacity: %d", vconf_get_ext_errno());
-
- if (power_supply_broadcast(CHARGE_LEVEL_SIGNAL, battery.charging_level) < 0)
- broadcasted = false;
- }
if (update_online()) {
ret = vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, online_status);