Fix the issue that wifi tethering security type set error 87/25087/1
authorZhang zhengguang <zhengguang.zhang@intel.com>
Tue, 29 Jul 2014 07:54:33 +0000 (15:54 +0800)
committerZhang zhengguang <zhengguang.zhang@intel.com>
Tue, 29 Jul 2014 08:02:04 +0000 (16:02 +0800)
Before set security type to open, it needs to save the previous
wpa2 passphrase, so that when set security type back to wpa2,
it can recover from the saved passphrase.

Change-Id: Ibf839140d328ea7e19a9447c8c0f0a7fa95d9f21

src/tethering.c

index 1ff3e9d0441866f5bf5361acdcbbbf09d465bd5c..80546c082a5e648be45790185a266bd4af8c337e 100644 (file)
@@ -49,7 +49,7 @@ static void __handle_ssid_visibility_changed(DBusGProxy *proxy, const char *valu
 static void __handle_passphrase_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data);*/
 
 static bool wifi_security_type_changed;
-static const char *wifi_security_wpa2_passphrase;
+static char *wifi_security_wpa2_passphrase;
 
 static void __handle_wifi_tether_changed(struct connman_technology *technology, void *user_data);
 static void __handle_usb_tether_changed(struct connman_technology *technology, void *user_data);
@@ -2206,6 +2206,11 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s
                const char *passphrase = connman_get_wifi_tethering_passphrase(technology);
                if (passphrase == NULL || g_strcmp0(passphrase, "") == 0)
                        return TETHERING_ERROR_INVALID_OPERATION;
+
+               if (wifi_security_wpa2_passphrase != NULL)
+                       g_free(wifi_security_wpa2_passphrase);
+               wifi_security_wpa2_passphrase = strdup(passphrase);
+
                if (connman_set_wifi_tethering_passphrase(technology, "")
                                                 != CONNMAN_LIB_ERR_NONE)
                        return TETHERING_ERROR_OPERATION_FAILED;
@@ -2534,9 +2539,6 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr
 
        connman_set_wifi_tethering_passphrase(technology, passphrase);
 
-       if (passphrase != NULL && g_strcmp0(passphrase, ""))
-               wifi_security_wpa2_passphrase = strdup(passphrase);
-
        return TETHERING_ERROR_NONE;
 }