From efb9952f5f32e037ea6d03dc3a0537101cb44c2d Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 7 Mar 2024 10:47:43 +0900 Subject: [PATCH] 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. [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 --- plugins/mobile/battery/battery-notification.c | 10 ---------- src/battery/battery-ops.h | 2 -- src/battery/power-supply.c | 12 ++++++++++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 1186cb5..1278242 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 39db934..93cfdeb 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 55b9ff8..bd05bab 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(); } } -- 2.7.4