diff options
author | Christopher Wiley <wiley@google.com> | 2016-08-22 10:23:22 -0700 |
---|---|---|
committer | Christopher Wiley <wiley@google.com> | 2016-08-22 18:05:33 -0700 |
commit | 1d3a41b9b46eb573058fdd7422d4ebc5b4f1108f (patch) | |
tree | a976c7d64b1851f861561227c9602bf24438840e | |
parent | b8157c6e5b77e3503757cedcc4e62f49309c106b (diff) |
Allow wificond to run as wifi:wifi
Expose the firmware path from libwifi_hal.
We need to access this at wificond startup to chown the firmware
reload path to wifi:wifi.
Remove some superfluous chown calls. The callsites should only
be used from wificond.
Bug: 29870863
Test: wificond unit and integration tests pass
Change-Id: If2fa38be252999a01f6d967ca8601d1789318103
-rw-r--r-- | libwifi_hal/Android.mk | 4 | ||||
-rw-r--r-- | libwifi_hal/driver_tool.cpp | 2 | ||||
-rw-r--r-- | libwifi_hal/include/wifi_hal/driver_tool.h | 2 | ||||
-rw-r--r-- | libwifi_hal/wifi_hal_common.cpp | 3 | ||||
-rw-r--r-- | libwifi_system/hostapd_manager.cpp | 2 | ||||
-rw-r--r-- | libwifi_system/wifi.cpp | 12 |
6 files changed, 9 insertions, 16 deletions
diff --git a/libwifi_hal/Android.mk b/libwifi_hal/Android.mk index f39617c32..f93015902 100644 --- a/libwifi_hal/Android.mk +++ b/libwifi_hal/Android.mk @@ -43,8 +43,12 @@ endif ifdef WIFI_DRIVER_FW_PATH_P2P wifi_hal_cflags += -DWIFI_DRIVER_FW_PATH_P2P=\"$(WIFI_DRIVER_FW_PATH_P2P)\" endif + +# Some devices use a different path (e.g. devices with broadcom WiFi parts). ifdef WIFI_DRIVER_FW_PATH_PARAM wifi_hal_cflags += -DWIFI_DRIVER_FW_PATH_PARAM=\"$(WIFI_DRIVER_FW_PATH_PARAM)\" +else +wifi_hal_cflags += -DWIFI_DRIVER_FW_PATH_PARAM=\"/sys/module/wlan/parameters/fwpath\" endif ifdef WIFI_DRIVER_STATE_CTRL_PARAM diff --git a/libwifi_hal/driver_tool.cpp b/libwifi_hal/driver_tool.cpp index 688017b5c..6b0b7522b 100644 --- a/libwifi_hal/driver_tool.cpp +++ b/libwifi_hal/driver_tool.cpp @@ -25,6 +25,8 @@ const int DriverTool::kFirmwareModeSta = WIFI_GET_FW_PATH_STA; const int DriverTool::kFirmwareModeAp = WIFI_GET_FW_PATH_AP; const int DriverTool::kFirmwareModeP2p = WIFI_GET_FW_PATH_P2P; +const char DriverTool::kFirmwareReloadPath[] = WIFI_DRIVER_FW_PATH_PARAM; + bool DriverTool::LoadDriver() { return ::wifi_load_driver() == 0; } diff --git a/libwifi_hal/include/wifi_hal/driver_tool.h b/libwifi_hal/include/wifi_hal/driver_tool.h index f1a43cc0c..376d17d93 100644 --- a/libwifi_hal/include/wifi_hal/driver_tool.h +++ b/libwifi_hal/include/wifi_hal/driver_tool.h @@ -27,6 +27,8 @@ class DriverTool { static const int kFirmwareModeAp; static const int kFirmwareModeP2p; + static const char kFirmwareReloadPath[]; + DriverTool() = default; virtual ~DriverTool() = default; diff --git a/libwifi_hal/wifi_hal_common.cpp b/libwifi_hal/wifi_hal_common.cpp index 86d5db7e5..f207eb786 100644 --- a/libwifi_hal/wifi_hal_common.cpp +++ b/libwifi_hal/wifi_hal_common.cpp @@ -38,9 +38,6 @@ extern "C" int delete_module(const char *, unsigned int); #ifndef WIFI_DRIVER_FW_PATH_P2P #define WIFI_DRIVER_FW_PATH_P2P NULL #endif -#ifndef WIFI_DRIVER_FW_PATH_PARAM -#define WIFI_DRIVER_FW_PATH_PARAM "/sys/module/wlan/parameters/fwpath" -#endif #ifndef WIFI_DRIVER_MODULE_ARG #define WIFI_DRIVER_MODULE_ARG "" diff --git a/libwifi_system/hostapd_manager.cpp b/libwifi_system/hostapd_manager.cpp index b92c56bed..62ea7dbfa 100644 --- a/libwifi_system/hostapd_manager.cpp +++ b/libwifi_system/hostapd_manager.cpp @@ -105,7 +105,7 @@ bool HostapdManager::StopHostapd() { bool HostapdManager::WriteHostapdConfig(const string& config) { if (!WriteStringToFile(config, kHostapdConfigFilePath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, - AID_SYSTEM, AID_WIFI)) { + AID_WIFI, AID_WIFI)) { int error = errno; LOG(ERROR) << "Cannot write hostapd config to \"" << kHostapdConfigFilePath << "\": " << strerror(error); diff --git a/libwifi_system/wifi.cpp b/libwifi_system/wifi.cpp index da00ba5b1..49aee188b 100644 --- a/libwifi_system/wifi.cpp +++ b/libwifi_system/wifi.cpp @@ -167,12 +167,6 @@ int ensure_config_file_exists(const char* config_file) { return -1; } - if (chown(config_file, AID_SYSTEM, AID_WIFI) < 0) { - ALOGE("Error changing group ownership of %s to %d: %s", config_file, - AID_WIFI, strerror(errno)); - unlink(config_file); - return -1; - } return 0; } @@ -530,12 +524,6 @@ int ensure_entropy_file_exists() { return -1; } - if (chown(kWiFiEntropyFile, AID_SYSTEM, AID_WIFI) < 0) { - ALOGE("Error changing group ownership of %s to %d: %s", kWiFiEntropyFile, - AID_WIFI, strerror(errno)); - unlink(kWiFiEntropyFile); - return -1; - } return 0; } |