battery: Relocate remove_health_popup() from mobile plugin 52/311852/1
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 29 May 2024 03:55:57 +0000 (12:55 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 29 May 2024 03:55:57 +0000 (12:55 +0900)
*In this description, "core" refers to the deviced module below src.

Move function remove_health_popup from mobile plugin to core battery module.

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().

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

Change-Id: I8ec91780e2b36cf4dee158b126ed94ed24da4371
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 1186cb5368cf2afe73100f104dd5d39215e928aa..1278242d1964f1bf6cbc0e6196d639ae16ad7ebb 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 39db934325733ab1ffde4ff1700d2f3da77122d4..93cfdeb9db6dd27a80c993c64f5290c6fef898df 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 b62234cfda56db39611ff9621b8c494cf583752c..1ee162b38cbdf8fe9bb16c3532a6158faf2adba3 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();
        }
 }