display: Remove battery plugin using from display plugin 56/294756/5
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 26 Jun 2023 05:38:31 +0000 (14:38 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 26 Jun 2023 05:38:31 +0000 (14:38 +0900)
display plugin used get_charging_status() from initialization steps.
To use that function, display plugin loaded battery plugin.
However, that function is not exist in the battery plugin.
Thus, that function loading and accessing is useless work.

Also, loading battery plugin from the display plugin structure should be removed.

This function is added to display-misc.
- void display_misc_set_battery_charging_status_flag(void);
    -> It checks battery charging status and sets CHRGR_FLAG.
    -> This function should be relocated during battery plugin refactoring.

Change-Id: I943768785b654a660982a3017cafd0e41b7b94ed
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/battery/power-supply.h
src/display/display-misc.c
src/display/display-misc.h

index 1ab9da5..5828ccd 100644 (file)
@@ -84,8 +84,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
-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 int default_proc_change_state(unsigned int cond, pid_t pid);
@@ -429,10 +427,6 @@ static void check_seed_status(void)
        int lock_state;
        int lock_screen_timeout = 0;
 
-       /* Charging check */
-       if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
-               set_pm_status_flag(CHRGR_FLAG);
-
        ret = get_setting_brightness(&tmp);
        if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
                _I("Failed to read vconf value for brightness.");
@@ -584,13 +578,6 @@ static int display_probe(void *data)
        init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
-       if (battery_plgn->handle) {
-               fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
-               if (!fp_get_charging_status)
-                       _E("Failed to obtain address of get_charging_status");
-       } else
-               _I("There is no battery module.");
-
        return 0;
 }
 
@@ -886,10 +873,6 @@ static void __CONSTRUCTOR__ initialize(void)
        backlight_ops = get_var_backlight_ops();
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
-
-       battery_plgn = get_var_battery_plugin();
-       if (!battery_plgn)
-               _E("Failed to get battery plugin variable.");
 }
 /**
  * @}
index 47cf451..71fb929 100644 (file)
@@ -85,8 +85,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
-static struct battery_plugin *battery_plgn;
-static int (*fp_get_charging_status) (int *val);
 
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
@@ -438,9 +436,7 @@ static void check_seed_status(void)
        int lock_state;
        int lock_screen_timeout = 0;
 
-       /* Charging check */
-       if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
-               set_pm_status_flag(CHRGR_FLAG);
+       display_misc_set_battery_charging_status_flag();
 
        ret = get_setting_brightness(&tmp);
        if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
@@ -589,13 +585,6 @@ static int display_probe(void *data)
        init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
-       if (battery_plgn->handle) {
-               fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
-               if (!fp_get_charging_status)
-                       _E("Failed to obtain address of get_charging_status");
-       } else
-               _I("There is no battery module.");
-
        return 0;
 }
 
@@ -896,10 +885,6 @@ static void __CONSTRUCTOR__ initialize(void)
        backlight_ops = get_var_backlight_ops();
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
-
-       battery_plgn = get_var_battery_plugin();
-       if (!battery_plgn)
-               _E("Failed to get battery plugin variable.");
 }
 /**
  * @}
index e16cd09..223c38e 100644 (file)
@@ -83,8 +83,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
-static struct battery_plugin *battery_plgn;
-static int (*fp_get_charging_status) (int *val);
 
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
@@ -428,10 +426,6 @@ static void check_seed_status(void)
        int lock_state;
        int lock_screen_timeout = 0;
 
-       /* Charging check */
-       if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
-               set_pm_status_flag(CHRGR_FLAG);
-
        ret = get_setting_brightness(&tmp);
        if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
                _I("Failed to read vconf value for brightness.");
@@ -580,13 +574,6 @@ static int display_probe(void *data)
        init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
-       if (battery_plgn->handle) {
-               fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
-               if (!fp_get_charging_status)
-                       _E("Failed to obtain address of get_charging_status");
-       } else
-               _I("There is no battery module.");
-
        return 0;
 }
 
@@ -882,10 +869,6 @@ static void __CONSTRUCTOR__ initialize(void)
        backlight_ops = get_var_backlight_ops();
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
-
-       battery_plgn = get_var_battery_plugin();
-       if (!battery_plgn)
-               _E("Failed to get battery plugin variable.");
 }
 /**
  * @}
index 150dc3f..e5e7d73 100644 (file)
@@ -92,8 +92,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
-static struct battery_plugin *battery_plgn;
-static int (*fp_get_charging_status) (int *val);
 
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
@@ -1150,9 +1148,7 @@ static void check_seed_status(void)
        int lock_state;
        int lock_screen_timeout = 0;
 
-       /* Charging check */
-       if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
-               set_pm_status_flag(CHRGR_FLAG);
+       display_misc_set_battery_charging_status_flag();
 
        ret = get_setting_brightness(&tmp);
        if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
@@ -1301,13 +1297,6 @@ static int display_probe(void *data)
        init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
-       if (battery_plgn->handle) {
-               fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
-               if (!fp_get_charging_status)
-                        _E("Failed to obtain address of get_charging_status");
-       } else
-               _I("There is no battery module.");
-
        return 0;
 }
 
@@ -1641,10 +1630,6 @@ static void __CONSTRUCTOR__ initialize(void)
        backlight_ops = get_var_backlight_ops();
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
-
-       battery_plgn = get_var_battery_plugin();
-       if (!battery_plgn)
-                _E("Failed to get battery plugin variable.");
 }
 
 /**
index c85cb90..078047a 100644 (file)
@@ -115,6 +115,7 @@ extern bool battery_initialized;
 int power_supply_broadcast(char *sig, int status);
 int battery_pm_change_internal(int pid, int s_bits);
 void relaunch_health_popup(void);
+int get_charging_status(int *val);
 
 #define CHARGER_STATUS_SIGNAL      "ChargerStatus"
 #define CHARGE_NOW_SIGNAL          "ChargeNow"
index 750ddea..e7ed556 100644 (file)
@@ -250,3 +250,12 @@ void display_misc_save_display_log(const char *path)
                close(fd);
        }
 }
+
+/* FIXME: This function should be moved to battery module */
+void display_misc_set_battery_charging_status_flag(void)
+{
+       int charging_status = 0;
+
+       if ((get_charging_status(&charging_status) == 0) && (charging_status > 0))
+               set_pm_status_flag(CHRGR_FLAG);
+}
\ No newline at end of file
index e213f81..afacf7b 100644 (file)
@@ -36,5 +36,6 @@ void display_misc_unregister_battery_health_notifier(void);
 void display_misc_save_display_log(const char *path);
 int display_misc_set_touch_event_blocked(bool blocked);
 bool display_misc_is_touch_event_blocked(void);
+void display_misc_set_battery_charging_status_flag(void);
 
 #endif /* __DISPLAY_MISC_H__ */
\ No newline at end of file