From: Yunhee Seo Date: Wed, 29 May 2024 03:55:57 +0000 (+0900) Subject: battery: Relocate remove_health_popup() from mobile plugin X-Git-Tag: accepted/tizen/unified/20240614.084923~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46fbd77fe43886db8c7015201028b866474104cd;p=platform%2Fcore%2Fsystem%2Fdeviced.git battery: Relocate remove_health_popup() from mobile plugin *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 --- diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 1186cb53..1278242d 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -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, diff --git a/src/battery/battery-ops.h b/src/battery/battery-ops.h index 39db9343..93cfdeb9 100644 --- a/src/battery/battery-ops.h +++ b/src/battery/battery-ops.h @@ -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); diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index b62234cf..1ee162b3 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -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(); } }