_E("Failed to add abnormal check timer.");
}
-static int display_changed(void *data)
-{
- static enum state_t state;
-
- if (!data)
- return state;
-
- state = *(int *)data;
-
- return state;
-}
-
static void battery_notification_init(void *data)
{
struct battery_plugin *plugin = (struct battery_plugin *)data;
plugin->check_power_supply_noti = check_power_supply_noti;
plugin->update_ovp = update_ovp;
- plugin->display_changed = display_changed;
-
ret = gdbus_signal_subscribe(NULL, DEVICED_PATH_SYSNOTI,
DEVICED_INTERFACE_SYSNOTI, SIGNAL_CHARGEERR_RESPONSE, abnormal_popup_dbus_signal_handler, NULL, NULL);
if (ret <= 0)
_E("Failed to init dbus signal: %d", ret);
-
- register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
}
static const struct battery_ops battery_notification_ops = {
static struct battery_status *battery;
-static int display_changed(void *data)
+static void launch_health_popup_by_display_state(int display_state)
{
- static enum state_t old;
- static enum state_t state;
+ static enum state_t old = S_START;
- if (!data)
- return state;
-
- old = state;
- state = *(int *)data;
-
- if (battery->health != HEALTH_LOW && battery->health != HEALTH_HIGH)
- return state;
+ if (battery->health != HEALTH_LOW && battery->health != HEALTH_HIGH) {
+ old = display_state;
+ return;
+ }
/* relaunch health popup on LCDON */
- if ((old == S_SLEEP || old == S_LCDOFF)
- && (state == S_LCDDIM || state == S_NORMAL))
+ if ((old == S_SLEEP || old == S_LCDOFF || old == S_START)
+ && (display_state == S_LCDDIM || display_state == S_NORMAL))
relaunch_health_popup();
-
- return state;
+ old = display_state;
}
static int check_power_supply_noti(void)
_D("Add plugins for battery notification.");
plugin->check_power_supply_noti = check_power_supply_noti;
plugin->update_ovp = update_ovp;
- plugin->display_changed = display_changed;
-
- register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
+ plugin->launch_health_popup_by_display_state =
+ launch_health_popup_by_display_state;
}
static const struct battery_ops battery_notification_ops = {
static guint power_timer;
static device_notifier_state_e old_state = -1;
+static enum state_t g_display_state = S_NORMAL;
+
bool battery_initialized;
bool battery_do_not_disturb(void);
return done;
}
+/**
+ * FIXME: Getting display state shoule be done by display module function.
+ * After refactoring display module, it should be changed to use getter in display module.
+ */
+static int handle_display_state_changed(void *data)
+{
+ if (!data) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
+ g_display_state = *(int *)data;
+
+ if (battery_plgn->launch_health_popup_by_display_state)
+ battery_plgn->launch_health_popup_by_display_state(g_display_state);
+
+ return 0;
+}
+
bool battery_do_not_disturb(void)
{
int block = 0, theater = 0, night = 0;
int r;
- if (battery_plgn->display_changed) {
- if (battery_plgn->display_changed(NULL) == S_LCDOFF) {
- r = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &block);
- if (r < 0)
- _E("Failed to set vconf value for blockmode wearable: %d", vconf_get_ext_errno());
- r = vconf_get_bool(VCONFKEY_SETAPPL_THEATER_MODE_ENABLE, &theater);
- if (r < 0)
- _E("Failed to set vconf value for theator mode enable: %d", vconf_get_ext_errno());
- r = vconf_get_bool(VCONFKEY_SETAPPL_GOODNIGHT_MODE_ENABLE, &night);
- if (r < 0)
- _E("Failed to set vconf value for goodnight mode enable: %d", vconf_get_ext_errno());
- }
+ if (g_display_state == S_LCDOFF) {
+ r = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, &block);
+ if (r < 0)
+ _E("Failed to set vconf value for blockmode wearable: %d", vconf_get_ext_errno());
+ r = vconf_get_bool(VCONFKEY_SETAPPL_THEATER_MODE_ENABLE, &theater);
+ if (r < 0)
+ _E("Failed to set vconf value for theator mode enable: %d", vconf_get_ext_errno());
+ r = vconf_get_bool(VCONFKEY_SETAPPL_GOODNIGHT_MODE_ENABLE, &night);
+ if (r < 0)
+ _E("Failed to set vconf value for goodnight mode enable: %d", vconf_get_ext_errno());
}
if (block != 0 || theater != 0 || night != 0) {
register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+ register_notifier(DEVICE_NOTIFIER_LCD, handle_display_state_changed);
ret_dbus = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret_dbus < 0)