battery: Relocate remove_health_popup() from mobile plugin 30/307330/1
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 7 Mar 2024 01:47:43 +0000 (10:47 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 7 Mar 2024 08:28:58 +0000 (17:28 +0900)
*In this description, "core" refers to the deviced module below src.

Move function remove_health_popup from mobile plugin to core battery module.

[Reason]
When the battery health status is abnormal, core battery module reuqests launching popup.
The location where it requests to add or remove pop-ups is different.
Actually, battery health management responsibility should be moved to core battery module.
Because overall battery health is manged in core battery moudle not mobile plugin.
Also, remove_health_popup() is used only power-supply in core battery module.

As explained above, it can be seen that shotgun surgery and feature envy code smells
from the remove_health_popup().

[How to]
Delete the function from the mobile plguin battery module and move it to
the deviced core battery module.

Change-Id: I6e968e53552e41db947218b95ad3b1c98b74cf90
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/mobile/battery/battery-notification.c
src/battery/battery-ops.h
src/battery/power-supply.c

index 1186cb5..1278242 100644 (file)
@@ -46,15 +46,6 @@ static struct display_plugin *disp_plgn;
 static struct battery_status *battery;
 static guint abnormal_timer;
 
-static void remove_health_popup(void)
-{
-       int ret;
-
-       ret = launch_system_app(APP_REMOVE, 2, APP_KEY_TYPE, REMOVE_POPUP);
-       if (ret < 0)
-               _E("Failed to launch remove battery popup(%d)", ret);
-}
-
 static int check_power_supply_noti(void)
 {
        return 1;
@@ -112,7 +103,6 @@ static void battery_notification_init(void *data)
                return;
 
        _D("Add plugins for battery notification.");
-       plugin->remove_health_popup = remove_health_popup;
        plugin->check_power_supply_noti = check_power_supply_noti;
 
        ret = gdbus_signal_subscribe(NULL, DEVICED_PATH_SYSNOTI,
index 39db934..93cfdeb 100644 (file)
@@ -34,8 +34,6 @@ struct battery_ops {
 
 struct battery_plugin {
        void *handle;
-       /* low battery notification */
-       void (*remove_health_popup) (void);
 
        void (*launch_health_popup_by_display_state) (int display_state);
        int (*check_power_supply_noti) (void);
index 55b9ff8..bd05bab 100644 (file)
@@ -413,6 +413,15 @@ static void charger_state_send_system_event(int state)
        event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, str);
 }
 
+static void remove_health_popup(void)
+{
+       int ret = 0;
+
+       ret = launch_system_app(APP_REMOVE, 2, APP_KEY_TYPE, REMOVE_POPUP);
+       if (ret < 0)
+               _W("Failed to launch remove battery popup(%d)", ret);
+}
+
 static int inform_changed_battery_connection(int status)
 {
        if (status == PRESENT_ABNORMAL)
@@ -488,8 +497,7 @@ static void update_health(enum battery_noti_status status)
                        g_source_remove(abnormal_health_popup_timer);
                        abnormal_health_popup_timer = 0;
                }
-               if (battery_plgn->remove_health_popup)
-                       battery_plgn->remove_health_popup();
+               remove_health_popup();
        }
 }