summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2018-08-24 15:26:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-08-24 15:26:50 +0000
commit43e88f1ca96d4bbcd044c5837794c344aca750c6 (patch)
tree33538b45545e8366b4e30fd6bf76360586eae65f
parente6a42731c0fa1792db3b8d6c22b5913322ed08e8 (diff)
parent708d500e48c78ac59b9d9819afb7a85ebe24a214 (diff)
downloadandroid_frameworks_opt_net_wifi-43e88f1ca96d4bbcd044c5837794c344aca750c6.tar.gz
android_frameworks_opt_net_wifi-43e88f1ca96d4bbcd044c5837794c344aca750c6.tar.bz2
android_frameworks_opt_net_wifi-43e88f1ca96d4bbcd044c5837794c344aca750c6.zip
Merge "Wifi: Remove early setting of driver status to ok"
-rw-r--r--libwifi_hal/wifi_hal_common.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/libwifi_hal/wifi_hal_common.cpp b/libwifi_hal/wifi_hal_common.cpp
index 413daf7da..d4774bda7 100644
--- a/libwifi_hal/wifi_hal_common.cpp
+++ b/libwifi_hal/wifi_hal_common.cpp
@@ -43,6 +43,7 @@ extern "C" int delete_module(const char *, unsigned int);
#endif
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
+static bool is_driver_loaded = false;
#ifdef WIFI_DRIVER_MODULE_PATH
static const char DRIVER_MODULE_NAME[] = WIFI_DRIVER_MODULE_NAME;
static const char DRIVER_MODULE_TAG[] = WIFI_DRIVER_MODULE_NAME " ";
@@ -117,10 +118,14 @@ int is_wifi_driver_loaded() {
char line[sizeof(DRIVER_MODULE_TAG) + 10];
#endif
- if (!property_get(DRIVER_PROP_NAME, driver_status, NULL) ||
- strcmp(driver_status, "ok") != 0) {
+ if (!property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
return 0; /* driver not loaded */
}
+
+ if (!is_driver_loaded) {
+ return 0;
+ } /* driver not loaded */
+
#ifdef WIFI_DRIVER_MODULE_PATH
/*
* If the property says the driver is loaded, check to
@@ -130,7 +135,10 @@ int is_wifi_driver_loaded() {
*/
if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
PLOG(WARNING) << "Could not open " << MODULE_FILE;
- property_set(DRIVER_PROP_NAME, "unloaded");
+ is_driver_loaded = false;
+ if (strcmp(driver_status, "unloaded") != 0) {
+ property_set(DRIVER_PROP_NAME, "unloaded");
+ }
return 0;
}
while ((fgets(line, sizeof(line), proc)) != NULL) {
@@ -140,7 +148,10 @@ int is_wifi_driver_loaded() {
}
}
fclose(proc);
- property_set(DRIVER_PROP_NAME, "unloaded");
+ is_driver_loaded = false;
+ if (strcmp(driver_status, "unloaded") != 0) {
+ property_set(DRIVER_PROP_NAME, "unloaded");
+ }
return 0;
#else
return 1;
@@ -163,7 +174,7 @@ int wifi_load_driver() {
if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0) return -1;
#endif
- property_set(DRIVER_PROP_NAME, "ok");
+ is_driver_loaded = true;
return 0;
}
@@ -192,6 +203,7 @@ int wifi_unload_driver() {
if (wifi_change_driver_state(WIFI_DRIVER_STATE_OFF) < 0) return -1;
}
#endif
+ is_driver_loaded = false;
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
#endif