From: Niraj Kumar Goit Date: Mon, 27 Sep 2021 09:03:06 +0000 (+0530) Subject: Handle supplicant kill event. X-Git-Tag: submit/tizen_6.0/20210927.130905^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2a7f8d4ff3736b1836ed24096f066add78eea87;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Handle supplicant kill event. Change-Id: I3160518201e2f9a96a9701a1ff2271be79587a03 Signed-off-by: Nishant Chaprana --- diff --git a/include/wifi-power.h b/include/wifi-power.h index d190f14..77a4ae5 100755 --- a/include/wifi-power.h +++ b/include/wifi-power.h @@ -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 } diff --git a/src/signal-handler.c b/src/signal-handler.c index 495881b..0a5b8bc 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -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 { @@ -675,6 +675,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); @@ -1536,6 +1539,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++) { diff --git a/src/wifi-power.c b/src/wifi-power.c index c6f12fc..fe8f48c 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -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; }