From ab5c471b0b57343728de56bd0965ecc30dcaf583 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Thu, 6 Oct 2016 14:37:15 -0700 Subject: [PATCH] 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 --- wifi/1.0/default/wifi_chip.cpp | 8 +++--- wifi/1.0/default/wifi_legacy_hal.cpp | 41 ++++++++++++++++++++-------- wifi/1.0/default/wifi_legacy_hal.h | 14 +++++++--- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp index b5bd4148be..719a6b93c4 100644 --- a/wifi/1.0/default/wifi_chip.cpp +++ b/wifi/1.0/default/wifi_chip.cpp @@ -79,7 +79,7 @@ Return WifiChip::requestChipDebugInfo() { IWifiChipEventCallback::ChipDebugInfo result; std::pair 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 @@ Return WifiChip::requestChipDebugInfo() { } 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 WifiChip::requestDriverDebugDump() { return Void(); std::pair> 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 WifiChip::requestFirmwareDebugDump() { return Void(); std::pair> 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 a6df996fc1..553a058135 100644 --- a/wifi/1.0/default/wifi_legacy_hal.cpp +++ b/wifi/1.0/default/wifi_legacy_hal.cpp @@ -25,12 +25,6 @@ #include 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 @@ wifi_error WifiLegacyHal::stop( return WIFI_SUCCESS; } -std::pair 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 buffer; + property_get("wifi.direct.interface", buffer.data(), "p2p0"); + return buffer.data(); +} + +std::string WifiLegacyHal::getStaIfaceName() { + std::array buffer; + property_get("wifi.interface", buffer.data(), "wlan0"); + return buffer.data(); +} + +std::pair WifiLegacyHal::getDriverVersion() { std::array buffer; buffer.fill(0); wifi_error status = global_func_table_.wifi_get_driver_version( @@ -128,7 +146,7 @@ std::pair WifiLegacyHal::getWlanDriverVersion() { return std::make_pair(status, buffer.data()); } -std::pair WifiLegacyHal::getWlanFirmwareVersion() { +std::pair WifiLegacyHal::getFirmwareVersion() { std::array buffer; buffer.fill(0); wifi_error status = global_func_table_.wifi_get_firmware_version( @@ -137,7 +155,7 @@ std::pair WifiLegacyHal::getWlanFirmwareVersion() { } std::pair> -WifiLegacyHal::requestWlanDriverMemoryDump() { +WifiLegacyHal::requestDriverMemoryDump() { std::vector driver_dump; on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer, int buffer_size) { @@ -150,7 +168,7 @@ WifiLegacyHal::requestWlanDriverMemoryDump() { } std::pair> -WifiLegacyHal::requestWlanFirmwareMemoryDump() { +WifiLegacyHal::requestFirmwareMemoryDump() { std::vector firmware_dump; on_firmware_memory_dump_internal_callback = [&firmware_dump]( char* buffer, int buffer_size) { @@ -163,8 +181,7 @@ WifiLegacyHal::requestWlanFirmwareMemoryDump() { } 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 f691b9ba5c..3585975b10 100644 --- a/wifi/1.0/default/wifi_legacy_hal.h +++ b/wifi/1.0/default/wifi_legacy_hal.h @@ -35,15 +35,21 @@ namespace implementation { 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& on_complete_callback); // Wrappers for all the functions in the legacy HAL function table. - std::pair getWlanDriverVersion(); - std::pair getWlanFirmwareVersion(); - std::pair> requestWlanDriverMemoryDump(); - std::pair> requestWlanFirmwareMemoryDump(); + std::pair getDriverVersion(); + std::pair getFirmwareVersion(); + std::pair> requestDriverMemoryDump(); + std::pair> requestFirmwareMemoryDump(); private: static const uint32_t kMaxVersionStringLength;