summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDedy Lansky <dlansky@codeaurora.org>2015-09-10 17:09:49 +0300
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:19:15 -0600
commit69e94ce171e0a937a5e40229aafd8f1a65a0a671 (patch)
tree215a1776058cd8575806ff0db3d91a58eeea14c9
parent4584c1f9d780fd8f2412187c04d592041f4760b6 (diff)
downloadhardware_libhardware_legacy-69e94ce171e0a937a5e40229aafd8f1a65a0a671.zip
hardware_libhardware_legacy-69e94ce171e0a937a5e40229aafd8f1a65a0a671.tar.gz
hardware_libhardware_legacy-69e94ce171e0a937a5e40229aafd8f1a65a0a671.tar.bz2
wifi: generalize ensure_config_file_exists()
ensure_config_file_exists gets config_file_template as argument instead of using hard coded SUPP_CONFIG_TEMPLATE Change-Id: I52b0c21d47254b5fa62e53ac71552d5dbfc445df
-rw-r--r--include/hardware_legacy/wifi.h5
-rw-r--r--wifi/wifi.c12
2 files changed, 11 insertions, 6 deletions
diff --git a/include/hardware_legacy/wifi.h b/include/hardware_legacy/wifi.h
index 93f0383..a60718d 100644
--- a/include/hardware_legacy/wifi.h
+++ b/include/hardware_legacy/wifi.h
@@ -150,6 +150,11 @@ int wifi_change_fw_path(const char *fwpath);
#define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin"
int ensure_entropy_file_exists();
+/**
+* Check and create if necessary the desired configuration file
+*/
+int ensure_config_file_exists(const char *config_file, const char *config_file_template);
+
#if __cplusplus
}; // extern "C"
#endif
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 880f6fc..89e9397 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -374,7 +374,7 @@ int ensure_entropy_file_exists()
return 0;
}
-int ensure_config_file_exists(const char *config_file)
+int ensure_config_file_exists(const char *config_file, const char *config_file_template)
{
char buf[2048];
int srcfd, destfd;
@@ -395,9 +395,9 @@ int ensure_config_file_exists(const char *config_file)
return -1;
}
- srcfd = TEMP_FAILURE_RETRY(open(SUPP_CONFIG_TEMPLATE, O_RDONLY));
+ srcfd = TEMP_FAILURE_RETRY(open(config_file_template, O_RDONLY));
if (srcfd < 0) {
- ALOGE("Cannot open \"%s\": %s", SUPP_CONFIG_TEMPLATE, strerror(errno));
+ ALOGE("Cannot open \"%s\": %s", config_file_template, strerror(errno));
return -1;
}
@@ -410,7 +410,7 @@ int ensure_config_file_exists(const char *config_file)
while ((nread = TEMP_FAILURE_RETRY(read(srcfd, buf, sizeof(buf)))) != 0) {
if (nread < 0) {
- ALOGE("Error reading \"%s\": %s", SUPP_CONFIG_TEMPLATE, strerror(errno));
+ ALOGE("Error reading \"%s\": %s", config_file_template, strerror(errno));
close(srcfd);
close(destfd);
unlink(config_file);
@@ -451,7 +451,7 @@ int wifi_start_supplicant(int p2p_supported)
strcpy(supplicant_prop_name, P2P_PROP_NAME);
/* Ensure p2p config file is created */
- if (ensure_config_file_exists(P2P_CONFIG_FILE) < 0) {
+ if (ensure_config_file_exists(P2P_CONFIG_FILE, SUPP_CONFIG_TEMPLATE) < 0) {
ALOGE("Failed to create a p2p config file");
return -1;
}
@@ -468,7 +468,7 @@ int wifi_start_supplicant(int p2p_supported)
}
/* Before starting the daemon, make sure its config file exists */
- if (ensure_config_file_exists(SUPP_CONFIG_FILE) < 0) {
+ if (ensure_config_file_exists(SUPP_CONFIG_FILE, SUPP_CONFIG_TEMPLATE) < 0) {
ALOGE("Wi-Fi will not be enabled");
return -1;
}