From 12847155a97449e084f6142e83f6fc36b9a4ec21 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 3 May 2023 10:53:15 +0900 Subject: [PATCH] display: misc: Relocate stay_touchscreen_off getter and setter Remove and redefine set_stay_touchscreen_off() to reduce plugin duplication These functions are added to below display-touchscreen. void display_misc_set_stay_touchscreen_off(bool on) -> This function sets stay_touchscreen_off variable void display_misc_get_stay_touchscreen_off(bool *on) -> This function gets stay_touchscreen_off value Change-Id: I09df7229111442affab75c43e70ae2038f82c966 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 12 ++---------- plugins/mobile/display/core.c | 12 ++---------- plugins/tv/display/core.c | 12 ++---------- plugins/wearable/display/core.c | 12 ++---------- src/display/{plugin-common => }/core.h | 1 - src/display/display-misc.c | 21 +++++++++++++++++++++ src/display/display-misc.h | 2 ++ src/display/plugin-common/display-dbus.c | 2 +- 8 files changed, 32 insertions(+), 42 deletions(-) rename src/display/{plugin-common => }/core.h (99%) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index e38d9ff..a1e9a29 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -107,7 +107,6 @@ static char *custom_change_name; static guint lock_timeout_id; static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; -static int stay_touchscreen_off = false; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -309,7 +308,9 @@ void lcd_on_procedure(int state, enum device_flags flag) static unsigned long get_lcd_off_flags(void) { unsigned long flags = NORMAL_MODE; + bool stay_touchscreen_off = false; + display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); if (stay_touchscreen_off) flags |= TOUCH_SCREEN_OFF_MODE; @@ -360,15 +361,6 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -void set_stay_touchscreen_off(int val) -{ - _I("Stay touch screen off: %d", val); - stay_touchscreen_off = val; - - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); -} - static void del_state_cond(void *data, enum state_t state) { PmLockNode *tmp = NULL; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 14a24e1..9a1f709 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -109,7 +109,6 @@ static char *custom_change_name; static guint lock_timeout_id; static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; -static int stay_touchscreen_off = false; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -316,7 +315,9 @@ void lcd_on_procedure(int state, enum device_flags flag) static unsigned long get_lcd_off_flags(void) { unsigned long flags = NORMAL_MODE; + bool stay_touchscreen_off = false; + display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); if (stay_touchscreen_off) flags |= TOUCH_SCREEN_OFF_MODE; @@ -367,15 +368,6 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -void set_stay_touchscreen_off(int val) -{ - _I("Stay touch screen off: %d", val); - stay_touchscreen_off = val; - - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); -} - static void del_state_cond(void *data, enum state_t state) { PmLockNode *tmp = NULL; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 0746ae8..e5b1af0 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -107,7 +107,6 @@ static char *custom_change_name; static guint lock_timeout_id; static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; -static int stay_touchscreen_off = false; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -309,7 +308,9 @@ void lcd_on_procedure(int state, enum device_flags flag) static unsigned long get_lcd_off_flags(void) { unsigned long flags = NORMAL_MODE; + bool stay_touchscreen_off = false; + display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); if (stay_touchscreen_off) flags |= TOUCH_SCREEN_OFF_MODE; @@ -360,15 +361,6 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -void set_stay_touchscreen_off(int val) -{ - _I("Stay touch screen off: %d", val); - stay_touchscreen_off = val; - - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); -} - static void del_state_cond(void *data, enum state_t state) { PmLockNode *tmp = NULL; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 8e2d95b..d883963 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -121,7 +121,6 @@ static guint lock_timeout_id; static guint transit_timer; static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; -static int stay_touchscreen_off = false; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial * state because it should be sent from previous state at booting time. @@ -566,12 +565,14 @@ void lcd_on_procedure(int state, enum device_flags flag) static unsigned long get_lcd_off_flags(void) { unsigned long flags = NORMAL_MODE; + bool stay_touchscreen_off = false; if (ambient_get_condition() == true) { flags |= AMBIENT_MODE; flags |= LCD_PHASED_TRANSIT_MODE; } + display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); if (stay_touchscreen_off) flags |= TOUCH_SCREEN_OFF_MODE; @@ -637,15 +638,6 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -void set_stay_touchscreen_off(int val) -{ - _I("Stay touch screen off: %d", val); - stay_touchscreen_off = val; - - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); -} - static void del_state_cond(void *data, enum state_t state) { PmLockNode *tmp = NULL; diff --git a/src/display/plugin-common/core.h b/src/display/core.h similarity index 99% rename from src/display/plugin-common/core.h rename to src/display/core.h index 0bfc4e6..896e399 100644 --- a/src/display/plugin-common/core.h +++ b/src/display/core.h @@ -141,7 +141,6 @@ void update_lcdoff_source(int source); int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name); void save_display_log(const char *path); int custom_lcdon(int timeout); -void set_stay_touchscreen_off(int val); void lcd_on_direct(enum device_flags flags); void lcd_on_procedure(int state, enum device_flags flag); void lcd_off_procedure(enum device_flags flag); diff --git a/src/display/display-misc.c b/src/display/display-misc.c index 5acd18e..d8588f5 100644 --- a/src/display/display-misc.c +++ b/src/display/display-misc.c @@ -22,8 +22,11 @@ #include "shared/log.h" #include "display-misc.h" +#include "display-plugin.h" #include "poll.h" +static bool stay_touchscreen_off = false; + /* FIXME: This fucntion should be relocated under the battery module */ bool display_misc_is_low_battery_state(int val) { @@ -63,3 +66,21 @@ void display_misc_get_process_name(pid_t pid, char *pname) close(cmdline); } + +void display_misc_set_stay_touchscreen_off(bool on) +{ + _I("Stay touch screen off: %d", on); + stay_touchscreen_off = on; + + display_plugin_pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); +} + +void display_misc_get_stay_touchscreen_off(bool *on) +{ + if (!on) { + _E("Invalid parameter to get stay touchscreen off"); + return; + } + + *on = stay_touchscreen_off; +} \ No newline at end of file diff --git a/src/display/display-misc.h b/src/display/display-misc.h index ef4a78e..96518b9 100644 --- a/src/display/display-misc.h +++ b/src/display/display-misc.h @@ -29,5 +29,7 @@ bool display_misc_is_low_battery_state(int val); void display_misc_get_process_name(pid_t pid, char *pname); +void display_misc_set_stay_touchscreen_off(bool on); +void display_misc_get_stay_touchscreen_off(bool *on); #endif /* __DISPLAY_MISC_H__ */ \ No newline at end of file diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 9895b39..3fec333 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -942,7 +942,7 @@ static GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, g_variant_get(param, "(i)", &val); - set_stay_touchscreen_off(val); + display_misc_set_stay_touchscreen_off((bool)val); return g_variant_new("(i)", ret); } -- 2.7.4