From: Yunhee Seo Date: Thu, 15 Jun 2023 07:51:24 +0000 (+0900) Subject: display: Relocate set_lcd_timeout()/reset_lcd_timeout() X-Git-Tag: accepted/tizen/unified/dev/20230726.115933~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce59c93fa1c66b5469990aa519830693d97406ca;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Relocate set_lcd_timeout()/reset_lcd_timeout() set_lcd_timeout(), reset_lcd_timeout() is only used by dbus_setlcdtimeout call. However, it is unclear where it is being used. Furthermore, those functions' work flow overlap with set custom timeout, state transition. Thus, these functions are moved to display-dbus.c After that, it will be refactored. Change-Id: Iad32a524cc4fc8d8548258766236921be22dc94f Signed-off-by: Yunhee Seo --- diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index a109de9..b144e11 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -88,8 +88,6 @@ static struct battery_plugin *battery_plgn; static int (*fp_get_charging_status) (int *val); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; -static char *custom_change_name; - static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; @@ -609,75 +607,6 @@ static const char *errMSG[INIT_END] = { [INIT_DBUS] = "d-bus init error", }; -int set_lcd_timeout(int on, int dim, const char *name) -{ - unsigned int custom_normal_timeout = 0; - unsigned int custom_dim_timeout = 0; - - if (on == 0 && dim == 0) { - _I("LCD timeout changed: default setting"); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - } else if (on < 0 || dim < 0) { - _E("Failed to set value(on=%d dim=%d).", on, dim); - return -EINVAL; - } else { - _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); - display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); - } - /* Apply new backlight time */ - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - - if (custom_change_name) { - free(custom_change_name); - custom_change_name = 0; - } - - display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); - display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); - if (custom_normal_timeout == 0 && custom_dim_timeout == 0) - return 0; - - custom_change_name = strndup(name, strlen(name)); - if (!custom_change_name) { - _E("Failed to malloc."); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - return -ENOMEM; - } - - return 0; -} - -void reset_lcd_timeout(GDBusConnection *conn, - const gchar *sender, - const gchar *unique_name, - gpointer data) -{ - if (!sender) - return; - - if (!custom_change_name) - return; - - if (strcmp(sender, custom_change_name)) - return; - - _I("reset lcd timeout: Set default timeout. sender=%s", sender); - - free(custom_change_name); - custom_change_name = 0; - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); -} - static int delayed_init_done(void *data) { static bool done = false; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index dd3b864..f0ff545 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -90,8 +90,6 @@ static int (*fp_get_charging_status) (int *val); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; -static char *custom_change_name; - static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; @@ -618,75 +616,6 @@ static const char *errMSG[INIT_END] = { [INIT_DBUS] = "d-bus init error", }; -int set_lcd_timeout(int on, int dim, const char *name) -{ - unsigned int custom_normal_timeout = 0; - unsigned int custom_dim_timeout = 0; - - if (on == 0 && dim == 0) { - _I("LCD timeout changed: default setting"); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - } else if (on < 0 || dim < 0) { - _E("Failed to set value(on=%d dim=%d).", on, dim); - return -EINVAL; - } else { - _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); - display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); - } - /* Apply new backlight time */ - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - - if (custom_change_name) { - free(custom_change_name); - custom_change_name = 0; - } - - display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); - display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); - if (custom_normal_timeout == 0 && custom_dim_timeout == 0) - return 0; - - custom_change_name = strndup(name, strlen(name)); - if (!custom_change_name) { - _E("Failed to malloc."); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - return -ENOMEM; - } - - return 0; -} - -void reset_lcd_timeout(GDBusConnection *conn, - const gchar *sender, - const gchar *unique_name, - gpointer data) -{ - if (!sender) - return; - - if (!custom_change_name) - return; - - if (strcmp(sender, custom_change_name)) - return; - - _I("reset lcd timeout: Set default timeout. sender=%s", sender); - - free(custom_change_name); - custom_change_name = 0; - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); -} - static int delayed_init_done(void *data) { static bool done = false; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 20465d5..65f76e7 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -88,8 +88,6 @@ static int (*fp_get_charging_status) (int *val); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; -static char *custom_change_name; - static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; @@ -608,75 +606,6 @@ static const char *errMSG[INIT_END] = { [INIT_DBUS] = "d-bus init error", }; -int set_lcd_timeout(int on, int dim, const char *name) -{ - unsigned int custom_normal_timeout = 0; - unsigned int custom_dim_timeout = 0; - - if (on == 0 && dim == 0) { - _I("LCD timeout changed: default setting"); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - } else if (on < 0 || dim < 0) { - _E("Failed to set value(on=%d dim=%d).", on, dim); - return -EINVAL; - } else { - _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); - display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); - } - /* Apply new backlight time */ - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - - if (custom_change_name) { - free(custom_change_name); - custom_change_name = 0; - } - - display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); - display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); - if (custom_normal_timeout == 0 && custom_dim_timeout == 0) - return 0; - - custom_change_name = strndup(name, strlen(name)); - if (!custom_change_name) { - _E("Failed to malloc."); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - return -ENOMEM; - } - - return 0; -} - -void reset_lcd_timeout(GDBusConnection *conn, - const gchar *sender, - const gchar *unique_name, - gpointer data) -{ - if (!sender) - return; - - if (!custom_change_name) - return; - - if (strcmp(sender, custom_change_name)) - return; - - _I("reset lcd timeout: Set default timeout. sender=%s", sender); - - free(custom_change_name); - custom_change_name = 0; - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); -} - static int delayed_init_done(void *data) { static bool done = false; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 4eb15ca..3662293 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -98,7 +98,6 @@ static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; -static char *custom_change_name; static guint transit_timer; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -1239,75 +1238,6 @@ static const char *errMSG[INIT_END] = { [INIT_DBUS] = "d-bus init error", }; -int set_lcd_timeout(int on, int dim, const char *name) -{ - unsigned int custom_normal_timeout = 0; - unsigned int custom_dim_timeout = 0; - - if (on == 0 && dim == 0) { - _I("LCD timeout changed: default setting"); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - } else if (on < 0 || dim < 0) { - _E("Failed to set value(on=%d dim=%d).", on, dim); - return -EINVAL; - } else { - _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); - display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); - } - /* Apply new backlight time */ - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); - - if (custom_change_name) { - free(custom_change_name); - custom_change_name = 0; - } - - display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); - display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); - if (custom_normal_timeout == 0 && custom_dim_timeout == 0) - return 0; - - custom_change_name = strndup(name, strlen(name)); - if (!custom_change_name) { - _E("Failed to malloc."); - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - return -ENOMEM; - } - - return 0; -} - -void reset_lcd_timeout(GDBusConnection *conn, - const gchar *sender, - const gchar *unique_name, - gpointer data) -{ - if (!sender) - return; - - if (!custom_change_name) - return; - - if (strcmp(sender, custom_change_name)) - return; - - _I("reset lcd timeout: Set default timeout. sender=%s", sender); - - free(custom_change_name); - custom_change_name = 0; - display_state_transition_set_custom_timeout(S_NORMAL, 0); - display_state_transition_set_custom_timeout(S_LCDDIM, 0); - - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); -} - static int delayed_init_done(void *data) { static bool done = false; diff --git a/src/display/core.h b/src/display/core.h index cb6ef6a..4b8d73a 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -106,10 +106,6 @@ typedef struct { extern int poll_callback(int condition, PMMsg *data); extern struct state state[S_END]; -void reset_lcd_timeout(GDBusConnection *conn, - const gchar *sender, - const gchar *unique_name, - gpointer data); /* setting.c */ int get_lock_screen_bg_state(void); @@ -120,7 +116,6 @@ void set_lock_screen_bg_state(bool state); /* core.c */ int delete_condition(enum state_t state); int custom_lcdoff(enum device_flags flag); -int set_lcd_timeout(int on, int dim, const char *name); void broadcast_lcd_off_late(enum device_flags flags); /* auto-brightness.c */ diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 4f58cf1..69840fa 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -73,6 +73,7 @@ #define EXPIRED_POPUP_ID "_REQUEST_ID_" static struct display_plugin *disp_plgn; +static char *custom_change_name; static GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, @@ -713,6 +714,76 @@ error: return g_variant_new("(i)", ret); } +/* FIXME: these functions should be removed or refactored after discussion */ +static int set_lcd_timeout(int on, int dim, const char *name) +{ + unsigned int custom_normal_timeout = 0; + unsigned int custom_dim_timeout = 0; + + if (on == 0 && dim == 0) { + _I("LCD timeout changed: default setting"); + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); + } else if (on < 0 || dim < 0) { + _E("Failed to set value(on=%d dim=%d).", on, dim); + return -EINVAL; + } else { + _I("LCD timeout changed: on=%ds dim=%ds", on, dim); + display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); + display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); + } + /* Apply new backlight time */ + display_state_transition_update_display_state_timeout_by_priority(); + if (get_pm_cur_state() == S_NORMAL) + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); + + if (custom_change_name) { + free(custom_change_name); + custom_change_name = 0; + } + + display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); + display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); + if (custom_normal_timeout == 0 && custom_dim_timeout == 0) + return 0; + + custom_change_name = strndup(name, strlen(name)); + if (!custom_change_name) { + _E("Failed to malloc."); + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); + return -ENOMEM; + } + + return 0; +} + +static void reset_lcd_timeout(GDBusConnection *conn, + const gchar *sender, + const gchar *unique_name, + gpointer data) +{ + if (!sender) + return; + + if (!custom_change_name) + return; + + if (strcmp(sender, custom_change_name)) + return; + + _I("reset lcd timeout: Set default timeout. sender=%s", sender); + + free(custom_change_name); + custom_change_name = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); + + display_state_transition_update_display_state_timeout_by_priority(); + if (get_pm_cur_state() == S_NORMAL) + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); +} + static GVariant *dbus_setlcdtimeout(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)