#include <ITapiSim.h>
#include <TapiUtility.h>
#include <stdio.h>
+#include <stdlib.h>
#include <tzplatform_config.h>
#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
#endif
#define WLAN_MAC_INFO tzplatform_mkpath(TZ_SYS_ETC, "/.mac.info")
+#define WLAN_MAC_ADDRESS_FILEPATH "/sys/class/net/wlan0/address"
#define WLAN_MAC_ADDR_MAX 20
#define VCONF_WIFI_BSSID_ADDRESS "db/wifi/bssid_address"
{
int err = 0;
+ INFO("remove driver and supplicant");
if (wifi_firmware_recovery_mode != TRUE &&
netconfig_wifi_is_wps_enabled() == TRUE) {
DBG("Wi-Fi WPS mode");
wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_OFF);
+ // reset service state
+ wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+
if (wifi_firmware_recovery_mode == TRUE) {
if (wifi_power_on() < 0)
ERR("Failed to recover Wi-Fi firmware");
FILE *fp = fopen(WLAN_MAC_INFO, "r");
if (fp == NULL) {
- ERR("Fail to open file");
- return;
+ ERR("Fail to open %s", WLAN_MAC_INFO);
+ fp = fopen(WLAN_MAC_ADDRESS_FILEPATH, "r");
+ if (fp == NULL) {
+ ERR("Fail to open %s", WLAN_MAC_ADDRESS_FILEPATH);
+ return;
+ }
}
fseek(fp, 0L, SEEK_SET);
fclose(fp);
}
-int netconfig_wifi_driver_and_supplicant(gboolean enable)
-{
- /* There are 3 thumb rules for Wi-Fi power management
- * 1. Do not make exposed API to control wpa_supplicant and driver directly.
- * It probably breaks ConnMan technology operation.
- *
- * 2. Do not remove driver and wpa_supplicant if ConnMan already enabled.
- * It breaks ConnMan technology operation.
- *
- * 3. Final the best rule: make it as simple as possible.
- * Simple code enables easy maintenance and reduces logical errors.
- */
- if (enable == TRUE)
- return _load_driver_and_supplicant();
- else {
- if (connman_wifi_technology_state == TRUE)
- return -ENOSYS;
-
- return _load_driver_and_supplicant();
- }
-}
-
void netconfig_wifi_disable_technology_state_by_only_connman_signal(void)
{
/* Important: it's only done by ConnMan technology signal update */
wifi_tech_state_e tech_state;
tech_state = wifi_state_get_technology_state();
- if (tech_state >= NETCONFIG_WIFI_TECH_POWERED)
+ if (tech_state >= NETCONFIG_WIFI_TECH_POWERED) {
+ /* There can be a scenario where wifi is automatically *
+ * activated by connman if wifi was powered in last boot. *
+ * So we should update connman_wifi_technology_state variable *
+ * if it is found that wifi_tech_state variable is *
+ * NETCONFIG_WIFI_TECH_POWERED and connman_wifi_technology_state *
+ * variable is FALSE. Earlier connman_wifi_technology_state *
+ * variable was only updated when wifi was Powered on from *
+ * net-config resulting in variable not getting updated. *
+ * This caused wifi to not get deactivated after reboot if *
+ * last power state was activated */
+ ERR("Net-Config WiFi connman technology state %d",
+ connman_wifi_technology_state);
+ if (connman_wifi_technology_state == FALSE)
+ connman_wifi_technology_state = TRUE;
return -EALREADY;
+ }
if (__is_wifi_restricted() == TRUE)
return -EPERM;
if (__netconfig_get_random_mac(rand_mac_add, ETH_MAC_ADDR_SIZE) == -1) {
ERR("Could not generate the Random Mac address");
- g_free(mac_addr);
+ free(mac_addr);
return;
}
if (rv < 0)
ERR("Unable to execute system command");
- g_free(mac_addr);
+ free(mac_addr);
}