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
This commit is contained in:
Roshan Pius
2016-10-06 14:37:15 -07:00
parent cd566bddd7
commit ab5c471b0b
3 changed files with 43 additions and 20 deletions

View File

@@ -79,7 +79,7 @@ Return<void> WifiChip::requestChipDebugInfo() {
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 @@ Return<void> 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<void> WifiChip::requestDriverDebugDump() {
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> WifiChip::requestFirmwareDebugDump() {
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);

View File

@@ -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 @@ wifi_error WifiLegacyHal::stop(
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 @@ std::pair<wifi_error, std::string> WifiLegacyHal::getWlanDriverVersion() {
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::string> WifiLegacyHal::getWlanFirmwareVersion() {
}
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 @@ WifiLegacyHal::requestWlanDriverMemoryDump() {
}
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 @@ 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(

View File

@@ -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<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;