From a1b47c4e729fa0fff9d6e2ab78a2a0305d6c8b9d Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Tue, 12 May 2020 16:29:48 +0900 Subject: [PATCH] Create interface first when enable Wi-Fi Change-Id: Id801b6dd6bfcfaa2cb2daefed9e6c37d7cb861bc --- gsupplicant/supplicant.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ packaging/connman.spec | 2 +- 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 759e165..b16625c 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -452,6 +452,10 @@ struct assoc_count_data { static unsigned int last_connected_bss_timeout = 0; #endif +static void interface_get_params(DBusMessageIter *iter, void *user_data); +static void interface_get_result(const char *error, + DBusMessageIter *iter, void *user_data); + static int network_remove(struct interface_data *data); #if defined TIZEN_EXT_WIFI_MESH @@ -5484,11 +5488,29 @@ static void interface_create_result(const char *error, struct interface_create_data *data = user_data; const char *path = NULL; int err; +#if defined TIZEN_EXT + int ret; +#endif SUPPLICANT_DBG(""); if (error) { g_message("error %s", error); +#if defined TIZEN_EXT + SUPPLICANT_DBG("error %s", error); + if (strcmp(error, "fi.w1.wpa_supplicant1.InterfaceExists") == 0) { + SUPPLICANT_DBG("Send method: GetInterface"); + ret = supplicant_dbus_method_call(SUPPLICANT_PATH, + SUPPLICANT_INTERFACE, + "GetInterface", + interface_get_params, + interface_get_result, user_data, + NULL); + if (ret < 0) + interface_create_data_free(data); + return; + } +#endif err = -EIO; goto done; } @@ -5570,6 +5592,53 @@ static void interface_create_params(DBusMessageIter *iter, void *user_data) supplicant_dbus_dict_close(iter, &dict); } +#if defined TIZEN_EXT +static void interface_get_state(const char *key, DBusMessageIter *iter, + void *user_data) +{ + struct interface_create_data *data = user_data; + GSupplicantInterface *interface = NULL; + const char *str = NULL; + + SUPPLICANT_DBG("key[%s]", key); + + if (!data) { + SUPPLICANT_DBG("data is NULL"); + return; + } + + interface = data->interface; + if (!interface) { + SUPPLICANT_DBG("interface is NULL"); + return; + } + + if (iter) + dbus_message_iter_get_basic(iter, &str); + + if (str) { + if (string2state(str) != interface->state) + interface->state = string2state(str); + } + + if (interface->state == G_SUPPLICANT_STATE_DISABLED) + interface->ready = FALSE; + else + interface->ready = TRUE; + + SUPPLICANT_DBG("state %s (%d)", str, interface->state); + + if (data->callback) { + data->callback(0, interface, data->user_data); +#if defined TIZEN_EXT_WIFI_MESH + callback_mesh_support(interface); +#endif + } + + interface_create_data_free(data); +} +#endif + static void interface_get_result(const char *error, DBusMessageIter *iter, void *user_data) { @@ -5597,6 +5666,16 @@ static void interface_get_result(const char *error, goto done; } +#if defined TIZEN_EXT + data->interface = interface; + err = supplicant_dbus_property_get(path, + SUPPLICANT_INTERFACE ".Interface", + "State", interface_get_state, data, NULL); + + if (err == 0) + return; +#endif + if (data->callback) { data->callback(0, interface, data->user_data); #if !defined TIZEN_EXT @@ -5781,6 +5860,7 @@ int g_supplicant_interface_create(const char *ifname, const char *driver, data->callback = callback; data->user_data = user_data; +#if !defined TIZEN_EXT ret = supplicant_dbus_method_call(SUPPLICANT_PATH, SUPPLICANT_INTERFACE, "GetInterface", @@ -5789,6 +5869,16 @@ int g_supplicant_interface_create(const char *ifname, const char *driver, NULL); if (ret < 0) interface_create_data_free(data); +#else + ret = supplicant_dbus_method_call(SUPPLICANT_PATH, + SUPPLICANT_INTERFACE, + "CreateInterface", + interface_create_params, + interface_create_result, data, + NULL); + if (ret < 0) + interface_create_data_free(data); +#endif return ret; } diff --git a/packaging/connman.spec b/packaging/connman.spec index 6fa2f94..a21b846 100644 --- a/packaging/connman.spec +++ b/packaging/connman.spec @@ -5,7 +5,7 @@ Name: connman Version: 1.37 -Release: 39 +Release: 40 License: GPL-2.0+ Summary: Connection Manager Url: http://connman.net -- 2.7.4