battery: Move changed_battery_cf() from plugin to core 16/301216/1
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 6 Sep 2023 07:36:49 +0000 (16:36 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 10 Nov 2023 08:06:39 +0000 (17:06 +0900)
changed_battery_cf() was used to notify with system popup
when the battery is disconnected.
Notifying battery connection status is a general function.
Thus, move changed_battery_cf() to the core battery module
and name is replaced by inform_changed_battery_connection().

Change-Id: I17ccd437be55551f8501606dbe50ddf4461d688d
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 63c3bdd..3c248e5 100644 (file)
@@ -49,7 +49,6 @@
 #define METHOD_CRITICAL_NOTI_OFF    "BatteryCriticalNotiOff"
 
 #define REMOVE_POPUP        "remove_battery_popups"
-#define DISCONNECT_POPUP    "battdisconnect"
 
 enum event_noti_type {
        NOTI_NONE = -1,
@@ -291,13 +290,6 @@ static void clean_lowbat_noti(const char *prev, const char *str)
        _D("Noti_crit(%d) noti_low(%d).", noti_crit, noti_low);
 }
 
-static int changed_battery_cf(int status)
-{
-       if (status == PRESENT_ABNORMAL)
-               return launch_system_app(APP_ABNORMAL, 2, APP_KEY_TYPE, DISCONNECT_POPUP);
-       return launch_system_app(APP_REMOVE, 2, APP_KEY_TYPE, REMOVE_POPUP);
-}
-
 static void remove_health_popup(void)
 {
        int ret;
@@ -375,7 +367,6 @@ static void battery_notification_init(void *data)
        plugin->lowbat_noti_launch = launch_lowbat_noti;
        plugin->lowbat_noti_clean = clean_lowbat_noti;
 
-       plugin->changed_battery_cf = changed_battery_cf;
        plugin->remove_health_popup = remove_health_popup;
        plugin->check_power_supply_noti = check_power_supply_noti;
        plugin->update_ovp = update_ovp;
index 37efd0d..e4f8e9c 100644 (file)
@@ -38,7 +38,6 @@ struct battery_plugin {
        int (*lowbat_noti_launch) (int capacity, int option);
        void (*lowbat_noti_clean) (const char *prev, const char *str);
 
-       int (*changed_battery_cf) (int status);
        void (*remove_health_popup) (void);
 
        void (*launch_health_popup_by_display_state) (int display_state);
index 6014a6f..64589af 100644 (file)
@@ -84,6 +84,9 @@
 #define METHOD_FULL_NOTI_OFF  "BatteryFullNotiOff"
 #define METHOD_CHARGE_NOTI_ON "BatteryChargeNotiOn"
 
+#define REMOVE_POPUP          "remove_battery_popups"
+#define DISCONNECT_POPUP      "battdisconnect"
+
 #define CHARGER_CHARGE_ON_NODE "/sys/class/power_supply/battery/chg_on"
 
 #define RETRY_MAX 5
@@ -409,6 +412,13 @@ static void charger_state_send_system_event(int state)
        event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, str);
 }
 
+static int inform_changed_battery_connection(int status)
+{
+       if (status == PRESENT_ABNORMAL)
+               return launch_system_app(APP_ABNORMAL, 2, APP_KEY_TYPE, DISCONNECT_POPUP);
+       return launch_system_app(APP_REMOVE, 2, APP_KEY_TYPE, REMOVE_POPUP);
+}
+
 static void update_present(enum battery_noti_status status)
 {
 
@@ -424,8 +434,7 @@ static void update_present(enum battery_noti_status status)
                syscommon_notifier_emit_notify(DEVICED_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
                display_lock_request_unlock_with_option(DEVICED_EVENT_MISC_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
        }
-       if (battery_plgn->changed_battery_cf)
-               battery_plgn->changed_battery_cf(battery.present);
+       inform_changed_battery_connection(battery.present);
 }
 
 static void launch_health_popup(void)