Handle supplicant kill event. 10/264510/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 23 Sep 2021 12:22:09 +0000 (17:52 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 23 Sep 2021 12:22:09 +0000 (17:52 +0530)
Change-Id: If977a24c7ed8f67f4560aab6816b3c34a6739ba4
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/wifi-power.h
src/signal-handler.c
src/wifi-power.c

index d190f14..77a4ae5 100755 (executable)
@@ -48,6 +48,7 @@ gboolean handle_remove_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
 
 void __netconfig_set_ether_macaddr();
 int __execute_supplicant(gboolean enable);
+void __mark_supplicant_stopped(void);
 
 #ifdef __cplusplus
 }
index 8e214a2..1e45908 100755 (executable)
@@ -85,7 +85,7 @@
 #define SIGNAL_NAME_OWNER_CHANGED              "NameOwnerChanged"
 
 #define MAX_SIG_LEN 64
-#define TOTAL_CONN_SIGNALS 6
+#define TOTAL_CONN_SIGNALS 7
 #define MAX_SOCKET_OPEN_RETRY 5
 
 typedef enum {
@@ -680,6 +680,9 @@ static void _dbus_name_changed_cb(GDBusConnection *conn,
                /* If clatd is terminated unexpectedly, reset and enable clat service. */
                if (NETCONFIG_CELLULAR_ONLINE == cellular_state_get_service_state())
                        netconfig_clatd_reset();
+       } else if (g_strcmp0(name, SUPPLICANT_SERVICE) == 0 && *new == '\0') {
+               DBG("Supplicant destroyed: name %s, old %s, new %s", name, old, new);
+               __mark_supplicant_stopped();
        }
        g_free(name);
        g_free(old);
@@ -1541,6 +1544,18 @@ void register_gdbus_signal(void)
                        NULL,
                        NULL);
 
+       conn_subscription_ids[6] = g_dbus_connection_signal_subscribe(
+                       connection,
+                       DBUS_SERVICE_DBUS,
+                       DBUS_INTERFACE_DBUS,
+                       SIGNAL_NAME_OWNER_CHANGED,
+                       NULL,
+                       SUPPLICANT_SERVICE,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       _dbus_name_changed_cb,
+                       NULL,
+                       NULL);
+
        INFO("Successfully register clat DBus signal filters");
 
        for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
index c6f12fc..fe8f48c 100755 (executable)
@@ -72,6 +72,7 @@ typedef struct {
 
 static gboolean wifi_firmware_recovery_mode = FALSE;
 static int airplane_mode = 0;
+gboolean is_supplicant_running = FALSE;
 
 static gboolean __is_wifi_restricted(void)
 {
@@ -125,6 +126,11 @@ static void __technology_reply(GObject *source_object, GAsyncResult *res, gpoint
        g_free(interface_name);
 }
 
+void __mark_supplicant_stopped(void)
+{
+       is_supplicant_running = FALSE;
+}
+
 int __execute_supplicant(gboolean enable)
 {
        /*
@@ -138,9 +144,8 @@ int __execute_supplicant(gboolean enable)
        char *const args_disable[] = { "/usr/bin/wpa_supp.sh", "stop", NULL };
 #endif
        char *const envs[] = { NULL };
-       static gboolean enabled = FALSE;
 
-       if (enabled == enable)
+       if (is_supplicant_running == enable)
                return -EALREADY;
 
        if (enable == TRUE)
@@ -155,7 +160,7 @@ int __execute_supplicant(gboolean enable)
        DBG("wpa_supplicant %s", enable == TRUE ? "started" : "stopped");
 
        if (enable)
-               enabled = enable;
+               is_supplicant_running = enable;
 
        return 0;
 }