wifi: Remove "Wlan" prefix from wifi_legacy_hal public methods
All the legacy HAL API's in the function table uses the "wlan0"
interface handle for the various operations. But, this is an internal
detail that should be abstracted inside WifiLegacyHal class. So, rename
the public methods to remove the "Wlan" prefix from them.
Also, add methods to fetch the iface names to use for the various types
of HAL.
Bug: 31943042
Test: Compiles
Change-Id: I35a6cdea0ad7cff295d33c0245953258129fba43
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index b5bd414..719a6b9 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -79,7 +79,7 @@
IWifiChipEventCallback::ChipDebugInfo result;
std::pair<wifi_error, std::string> ret =
- legacy_hal_.lock()->getWlanDriverVersion();
+ legacy_hal_.lock()->getDriverVersion();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver version: "
<< LegacyErrorToString(ret.first);
@@ -87,7 +87,7 @@
}
result.driverDescription = ret.second.c_str();
- ret = legacy_hal_.lock()->getWlanFirmwareVersion();
+ ret = legacy_hal_.lock()->getFirmwareVersion();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware version: "
<< LegacyErrorToString(ret.first);
@@ -106,7 +106,7 @@
return Void();
std::pair<wifi_error, std::vector<char>> ret =
- legacy_hal_.lock()->requestWlanDriverMemoryDump();
+ legacy_hal_.lock()->requestDriverMemoryDump();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver debug dump: "
<< LegacyErrorToString(ret.first);
@@ -128,7 +128,7 @@
return Void();
std::pair<wifi_error, std::vector<char>> ret =
- legacy_hal_.lock()->requestWlanFirmwareMemoryDump();
+ legacy_hal_.lock()->requestFirmwareMemoryDump();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware debug dump: "
<< LegacyErrorToString(ret.first);
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index a6df996..553a058 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -25,12 +25,6 @@
#include <wifi_system/interface_tool.h>
namespace {
-std::string getWlanInterfaceName() {
- char buffer[PROPERTY_VALUE_MAX];
- property_get("wifi.interface", buffer, "wlan0");
- return buffer;
-}
-
// Legacy HAL functions accept "C" style function pointers, so use global
// functions to pass to the legacy HAL function and store the corresponding
// std::function methods to be invoked.
@@ -120,7 +114,31 @@
return WIFI_SUCCESS;
}
-std::pair<wifi_error, std::string> WifiLegacyHal::getWlanDriverVersion() {
+std::string WifiLegacyHal::getApIfaceName() {
+ // Fake name. This interface does not exist in legacy HAL
+ // API's.
+ return "ap0";
+}
+
+std::string WifiLegacyHal::getNanIfaceName() {
+ // Fake name. This interface does not exist in legacy HAL
+ // API's.
+ return "nan0";
+}
+
+std::string WifiLegacyHal::getP2pIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.direct.interface", buffer.data(), "p2p0");
+ return buffer.data();
+}
+
+std::string WifiLegacyHal::getStaIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.interface", buffer.data(), "wlan0");
+ return buffer.data();
+}
+
+std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion() {
std::array<char, kMaxVersionStringLength> buffer;
buffer.fill(0);
wifi_error status = global_func_table_.wifi_get_driver_version(
@@ -128,7 +146,7 @@
return std::make_pair(status, buffer.data());
}
-std::pair<wifi_error, std::string> WifiLegacyHal::getWlanFirmwareVersion() {
+std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion() {
std::array<char, kMaxVersionStringLength> buffer;
buffer.fill(0);
wifi_error status = global_func_table_.wifi_get_firmware_version(
@@ -137,7 +155,7 @@
}
std::pair<wifi_error, std::vector<char>>
-WifiLegacyHal::requestWlanDriverMemoryDump() {
+WifiLegacyHal::requestDriverMemoryDump() {
std::vector<char> driver_dump;
on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
int buffer_size) {
@@ -150,7 +168,7 @@
}
std::pair<wifi_error, std::vector<char>>
-WifiLegacyHal::requestWlanFirmwareMemoryDump() {
+WifiLegacyHal::requestFirmwareMemoryDump() {
std::vector<char> firmware_dump;
on_firmware_memory_dump_internal_callback = [&firmware_dump](
char* buffer, int buffer_size) {
@@ -163,8 +181,7 @@
}
wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
- const std::string& ifname_to_find = getWlanInterfaceName();
-
+ const std::string& ifname_to_find = getStaIfaceName();
wifi_interface_handle* iface_handles = nullptr;
int num_iface_handles = 0;
wifi_error status = global_func_table_.wifi_get_ifaces(
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index f691b9b..3585975 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -35,15 +35,21 @@
class WifiLegacyHal {
public:
WifiLegacyHal();
+ // Names to use for the different types of iface.
+ std::string getApIfaceName();
+ std::string getNanIfaceName();
+ std::string getP2pIfaceName();
+ std::string getStaIfaceName();
+
// Initialize the legacy HAL and start the event looper thread.
wifi_error start();
// Deinitialize the legacy HAL and stop the event looper thread.
wifi_error stop(const std::function<void()>& on_complete_callback);
// Wrappers for all the functions in the legacy HAL function table.
- std::pair<wifi_error, std::string> getWlanDriverVersion();
- std::pair<wifi_error, std::string> getWlanFirmwareVersion();
- std::pair<wifi_error, std::vector<char>> requestWlanDriverMemoryDump();
- std::pair<wifi_error, std::vector<char>> requestWlanFirmwareMemoryDump();
+ std::pair<wifi_error, std::string> getDriverVersion();
+ std::pair<wifi_error, std::string> getFirmwareVersion();
+ std::pair<wifi_error, std::vector<char>> requestDriverMemoryDump();
+ std::pair<wifi_error, std::vector<char>> requestFirmwareMemoryDump();
private:
static const uint32_t kMaxVersionStringLength;