wpa_supplicant(hidl): Check for template conf files in /system
For older devices (like gce), the template conf files are kept in
/system instead of /vendor. So, check for the template file in both
/vendor & /system.
Also, since template path is the same for P2P & STA, removed that as a
param from |ensureConfigFileExists|.
Bug: 36645291
Test: Locally tested wifi enable on GCE
Test: Treehugger tests should pass now.
Change-Id: Ia1f94f327d1901fd2ef7a1c10a84e813cd9833a6
diff --git a/wpa_supplicant/hidl/1.1/supplicant.cpp b/wpa_supplicant/hidl/1.1/supplicant.cpp
index b08940d..43d1e21 100644
--- a/wpa_supplicant/hidl/1.1/supplicant.cpp
+++ b/wpa_supplicant/hidl/1.1/supplicant.cpp
@@ -28,7 +28,9 @@
constexpr char kP2pIfaceConfOverlayPath[] =
"/vendor/etc/wifi/p2p_supplicant_overlay.conf";
// Migrate conf files for existing devices.
-constexpr char kTemplateConfPath[] =
+constexpr char kSystemTemplateConfPath[] =
+ "/system/etc/wifi/wpa_supplicant.conf";
+constexpr char kVendorTemplateConfPath[] =
"/vendor/etc/wifi/wpa_supplicant.conf";
constexpr char kOldStaIfaceConfPath[] =
"/data/misc/wifi/wpa_supplicant.conf";
@@ -92,7 +94,6 @@
*/
int ensureConfigFileExists(
const std::string& config_file_path,
- const std::string& template_config_file_path,
const std::string& old_config_file_path)
{
int ret = access(config_file_path.c_str(), R_OK | W_OK);
@@ -126,11 +127,21 @@
unlink(config_file_path.c_str());
return -1;
}
- ret = copyFileIfItExists(template_config_file_path, config_file_path);
+ ret = copyFileIfItExists(kVendorTemplateConfPath, config_file_path);
if (ret == 0) {
wpa_printf(
MSG_INFO, "Copied template conf file from %s to %s",
- template_config_file_path.c_str(), config_file_path.c_str());
+ kVendorTemplateConfPath, config_file_path.c_str());
+ return 0;
+ } else if (ret == -1) {
+ unlink(config_file_path.c_str());
+ return -1;
+ }
+ ret = copyFileIfItExists(kSystemTemplateConfPath, config_file_path);
+ if (ret == 0) {
+ wpa_printf(
+ MSG_INFO, "Copied template conf file from %s to %s",
+ kSystemTemplateConfPath, config_file_path.c_str());
return 0;
} else if (ret == -1) {
unlink(config_file_path.c_str());
@@ -263,8 +274,7 @@
iface_params.driver = kIfaceDriverName;
if (iface_info.type == IfaceType::P2P) {
if (ensureConfigFileExists(
- kP2pIfaceConfPath, kTemplateConfPath,
- kOldP2pIfaceConfPath) != 0) {
+ kP2pIfaceConfPath, kOldP2pIfaceConfPath) != 0) {
wpa_printf(
MSG_ERROR, "Conf file does not exists: %s",
kP2pIfaceConfPath);
@@ -276,8 +286,7 @@
iface_params.confanother = kP2pIfaceConfOverlayPath;
} else {
if (ensureConfigFileExists(
- kStaIfaceConfPath, kTemplateConfPath,
- kOldStaIfaceConfPath) != 0) {
+ kStaIfaceConfPath, kOldStaIfaceConfPath) != 0) {
wpa_printf(
MSG_ERROR, "Conf file does not exists: %s",
kStaIfaceConfPath);