summaryrefslogtreecommitdiffstats
path: root/libwifi_hal
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-09-09 13:28:03 -0700
committerChristopher Wiley <wiley@google.com>2016-09-09 15:56:28 -0700
commitf41e52f5ad89310d867a00c12f2cf146703ad574 (patch)
tree4a08129e1b38a1747464261ccc9428cf20e0f14f /libwifi_hal
parent09044adabba28c56b48922d105994d30e7ab015e (diff)
downloadandroid_frameworks_opt_net_wifi-f41e52f5ad89310d867a00c12f2cf146703ad574.tar.gz
android_frameworks_opt_net_wifi-f41e52f5ad89310d867a00c12f2cf146703ad574.tar.bz2
android_frameworks_opt_net_wifi-f41e52f5ad89310d867a00c12f2cf146703ad574.zip
Expose a method to take control of firmware path
Rather than exposing the firmware path directly, expose a helper method. This method can be static, since we call it once from wificond's main() and cannot effectively unittest changing filesystem permissions. Hide the firmware path again after this change. Bug: 31225859 Test: Can connect to networks on bullhead with this change. Change-Id: I1b1640f552f78ede2adb7e1273d69cc606543c7b
Diffstat (limited to 'libwifi_hal')
-rw-r--r--libwifi_hal/Android.mk1
-rw-r--r--libwifi_hal/driver_tool.cpp19
-rw-r--r--libwifi_hal/include/wifi_hal/driver_tool.h4
3 files changed, 22 insertions, 2 deletions
diff --git a/libwifi_hal/Android.mk b/libwifi_hal/Android.mk
index f93015902..1ed59882f 100644
--- a/libwifi_hal/Android.mk
+++ b/libwifi_hal/Android.mk
@@ -106,6 +106,7 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include \
$(call include-path-for, libhardware_legacy)
LOCAL_SHARED_LIBRARIES := \
+ libbase \
libcutils \
liblog \
libnl \
diff --git a/libwifi_hal/driver_tool.cpp b/libwifi_hal/driver_tool.cpp
index 6b0b7522b..c05c00080 100644
--- a/libwifi_hal/driver_tool.cpp
+++ b/libwifi_hal/driver_tool.cpp
@@ -16,6 +16,9 @@
#include "wifi_hal/driver_tool.h"
+#include <android-base/logging.h>
+#include <private/android_filesystem_config.h>
+
#include "hardware_legacy/wifi.h"
namespace android {
@@ -25,7 +28,21 @@ 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::TakeOwnershipOfFirmwareReload() {
+ if (!wifi_get_fw_path(kFirmwareModeSta) &&
+ !wifi_get_fw_path(kFirmwareModeAp) &&
+ !wifi_get_fw_path(kFirmwareModeP2p)) {
+ return true; // HAL doesn't think we need to load firmware for any mode.
+ }
+
+ if (chown(WIFI_DRIVER_FW_PATH_PARAM, AID_WIFI, AID_WIFI) != 0) {
+ PLOG(ERROR) << "Error changing ownership of '" << WIFI_DRIVER_FW_PATH_PARAM
+ << "' to wifi:wifi";
+ return false;
+ }
+
+ return true;
+}
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 376d17d93..e0941c0f9 100644
--- a/libwifi_hal/include/wifi_hal/driver_tool.h
+++ b/libwifi_hal/include/wifi_hal/driver_tool.h
@@ -27,7 +27,9 @@ class DriverTool {
static const int kFirmwareModeAp;
static const int kFirmwareModeP2p;
- static const char kFirmwareReloadPath[];
+ // Change the owner of the firmware reload path to wifi:wifi if
+ // firmware reload is supported.
+ static bool TakeOwnershipOfFirmwareReload();
DriverTool() = default;
virtual ~DriverTool() = default;