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 <yuni.seo@samsung.com>
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;
[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;
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;
[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;
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;
[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;
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
[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;
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);
/* 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 */
#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,
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)