mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
wifi: Change namespace am: 79a9975d07
am: 162f178af9
Change-Id: I7b6357236b1c2f06e9b4bdbc3459b0dde176d441
This commit is contained in:
@@ -16,14 +16,14 @@
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
|
||||
using ::android::hardware::wifi::V1_0::CommandFailureReason;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
std::string LegacyErrorToString(wifi_error error) {
|
||||
switch(error) {
|
||||
switch (error) {
|
||||
case WIFI_SUCCESS:
|
||||
return "SUCCESS";
|
||||
case WIFI_ERROR_UNINITIALIZED:
|
||||
@@ -48,17 +48,17 @@ std::string LegacyErrorToString(wifi_error error) {
|
||||
}
|
||||
}
|
||||
|
||||
V1_0::FailureReason CreateFailureReason(
|
||||
CommandFailureReason reason, const std::string& description) {
|
||||
V1_0::FailureReason result;
|
||||
FailureReason CreateFailureReason(CommandFailureReason reason,
|
||||
const std::string& description) {
|
||||
FailureReason result;
|
||||
result.reason = reason;
|
||||
result.description = description.data();
|
||||
return result;
|
||||
}
|
||||
|
||||
V1_0::FailureReason CreateFailureReasonLegacyError(
|
||||
wifi_error error, const std::string& desc) {
|
||||
switch(error) {
|
||||
FailureReason CreateFailureReasonLegacyError(wifi_error error,
|
||||
const std::string& desc) {
|
||||
switch (error) {
|
||||
case WIFI_ERROR_UNINITIALIZED:
|
||||
case WIFI_ERROR_NOT_AVAILABLE:
|
||||
return CreateFailureReason(CommandFailureReason::NOT_AVAILABLE, desc);
|
||||
@@ -71,16 +71,16 @@ V1_0::FailureReason CreateFailureReasonLegacyError(
|
||||
return CreateFailureReason(CommandFailureReason::INVALID_ARGS, desc);
|
||||
|
||||
case WIFI_ERROR_TIMED_OUT:
|
||||
return CreateFailureReason(
|
||||
CommandFailureReason::UNKNOWN, desc + ", timed out");
|
||||
return CreateFailureReason(CommandFailureReason::UNKNOWN,
|
||||
desc + ", timed out");
|
||||
|
||||
case WIFI_ERROR_TOO_MANY_REQUESTS:
|
||||
return CreateFailureReason(
|
||||
CommandFailureReason::UNKNOWN, desc + ", too many requests");
|
||||
return CreateFailureReason(CommandFailureReason::UNKNOWN,
|
||||
desc + ", too many requests");
|
||||
|
||||
case WIFI_ERROR_OUT_OF_MEMORY:
|
||||
return CreateFailureReason(
|
||||
CommandFailureReason::UNKNOWN, desc + ", out of memory");
|
||||
return CreateFailureReason(CommandFailureReason::UNKNOWN,
|
||||
desc + ", out of memory");
|
||||
|
||||
case WIFI_ERROR_NONE:
|
||||
case WIFI_ERROR_UNKNOWN:
|
||||
@@ -89,6 +89,8 @@ V1_0::FailureReason CreateFailureReasonLegacyError(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -23,14 +23,18 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
std::string LegacyErrorToString(wifi_error error);
|
||||
|
||||
V1_0::FailureReason CreateFailureReason(
|
||||
V1_0::CommandFailureReason reason, const std::string& description);
|
||||
V1_0::FailureReason CreateFailureReasonLegacyError(
|
||||
wifi_error error, const std::string& description);
|
||||
FailureReason CreateFailureReason(CommandFailureReason reason,
|
||||
const std::string& description);
|
||||
FailureReason CreateFailureReasonLegacyError(wifi_error error,
|
||||
const std::string& description);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -36,15 +36,15 @@ int OnBinderReadReady(int /*fd*/, int /*events*/, void* /*data*/) {
|
||||
}
|
||||
|
||||
int main(int /*argc*/, char** argv) {
|
||||
android::base::InitLogging(
|
||||
argv, android::base::LogdLogger(android::base::SYSTEM));
|
||||
android::base::InitLogging(argv,
|
||||
android::base::LogdLogger(android::base::SYSTEM));
|
||||
LOG(INFO) << "wifi_hal_legacy is starting up...";
|
||||
|
||||
// Setup binder
|
||||
int binder_fd = -1;
|
||||
ProcessState::self()->setThreadPoolMaxThreadCount(0);
|
||||
CHECK_EQ(IPCThreadState::self()->setupPolling(&binder_fd),
|
||||
android::NO_ERROR) << "Failed to initialize binder polling";
|
||||
CHECK_EQ(IPCThreadState::self()->setupPolling(&binder_fd), android::NO_ERROR)
|
||||
<< "Failed to initialize binder polling";
|
||||
CHECK_GE(binder_fd, 0) << "Invalid binder FD: " << binder_fd;
|
||||
|
||||
// Setup looper
|
||||
@@ -54,13 +54,14 @@ int main(int /*argc*/, char** argv) {
|
||||
<< "Failed to watch binder FD";
|
||||
|
||||
// Setup hwbinder service
|
||||
android::sp<android::hardware::wifi::Wifi> service =
|
||||
new android::hardware::wifi::Wifi(looper);
|
||||
CHECK_EQ(service->registerAsService("wifi"),
|
||||
android::NO_ERROR) << "Failed to register wifi HAL";
|
||||
android::sp<android::hardware::wifi::V1_0::IWifi> service =
|
||||
new android::hardware::wifi::V1_0::implementation::Wifi(looper);
|
||||
CHECK_EQ(service->registerAsService("wifi"), android::NO_ERROR)
|
||||
<< "Failed to register wifi HAL";
|
||||
|
||||
// Loop
|
||||
while (looper->pollAll(-1) != Looper::POLL_ERROR);
|
||||
while (looper->pollAll(-1) != Looper::POLL_ERROR)
|
||||
;
|
||||
|
||||
LOG(INFO) << "wifi_hal_legacy is terminating...";
|
||||
return 0;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_chip.h"
|
||||
|
||||
using ::android::hardware::wifi::V1_0::CommandFailureReason;
|
||||
using RunState = ::android::hardware::wifi::WifiHalState::RunState;
|
||||
|
||||
namespace {
|
||||
@@ -36,6 +35,8 @@ std::string GetWlanInterfaceName() {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Wifi::Wifi(sp<Looper>& looper) : state_(looper) {
|
||||
CHECK_EQ(init_wifi_vendor_hal_func_table(&state_.func_table_), WIFI_SUCCESS)
|
||||
@@ -43,7 +44,7 @@ Wifi::Wifi(sp<Looper>& looper) : state_(looper) {
|
||||
}
|
||||
|
||||
Return<void> Wifi::registerEventCallback(
|
||||
const sp<V1_0::IWifiEventCallback>& callback) {
|
||||
const sp<IWifiEventCallback>& callback) {
|
||||
// TODO(b/31632518): remove the callback when the client is destroyed
|
||||
callbacks_.insert(callback);
|
||||
return Void();
|
||||
@@ -72,8 +73,8 @@ Return<void> Wifi::start() {
|
||||
if (status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to initialize Wifi HAL";
|
||||
for (auto& callback : callbacks_) {
|
||||
callback->onStartFailure(CreateFailureReasonLegacyError(
|
||||
status, "Failed to initialize HAL"));
|
||||
callback->onStartFailure(
|
||||
CreateFailureReasonLegacyError(status, "Failed to initialize HAL"));
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
@@ -95,8 +96,7 @@ Return<void> Wifi::start() {
|
||||
return Void();
|
||||
}
|
||||
|
||||
wifi_interface_handle Wifi::FindInterfaceHandle(
|
||||
const std::string& ifname) {
|
||||
wifi_interface_handle Wifi::FindInterfaceHandle(const std::string& ifname) {
|
||||
int num_iface_handles = 0;
|
||||
wifi_interface_handle* iface_handles = nullptr;
|
||||
wifi_error ret = state_.func_table_.wifi_get_ifaces(
|
||||
@@ -124,7 +124,6 @@ wifi_interface_handle Wifi::FindInterfaceHandle(
|
||||
return kInterfaceNotFoundHandle;
|
||||
}
|
||||
|
||||
|
||||
void NoopHalCleanupHandler(wifi_handle) {}
|
||||
|
||||
Return<void> Wifi::stop() {
|
||||
@@ -142,7 +141,8 @@ Return<void> Wifi::stop() {
|
||||
awaiting_hal_event_loop_termination_ = true;
|
||||
state_.run_state_ = RunState::STOPPING;
|
||||
|
||||
if (chip_.get()) chip_->Invalidate();
|
||||
if (chip_.get())
|
||||
chip_->Invalidate();
|
||||
chip_.clear();
|
||||
|
||||
state_.func_table_.wifi_cleanup(state_.hal_handle_, NoopHalCleanupHandler);
|
||||
@@ -160,10 +160,10 @@ void Wifi::DoHalEventLoop() {
|
||||
}
|
||||
LOG(VERBOSE) << "HAL Event loop terminated";
|
||||
event_loop_thread_.detach();
|
||||
state_.PostTask([this](){
|
||||
awaiting_hal_event_loop_termination_ = false;
|
||||
FinishHalCleanup();
|
||||
});
|
||||
state_.PostTask([this]() {
|
||||
awaiting_hal_event_loop_termination_ = false;
|
||||
FinishHalCleanup();
|
||||
});
|
||||
}
|
||||
|
||||
void Wifi::FinishHalCleanup() {
|
||||
@@ -176,12 +176,13 @@ void Wifi::FinishHalCleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Return<void> Wifi::getChip(getChip_cb cb) {
|
||||
cb(chip_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -21,25 +21,26 @@
|
||||
#include <set>
|
||||
#include <thread>
|
||||
|
||||
#include <android/hardware/wifi/1.0/IWifi.h>
|
||||
#include <android-base/macros.h>
|
||||
#include <android/hardware/wifi/1.0/IWifi.h>
|
||||
#include <hardware_legacy/wifi_hal.h>
|
||||
#include <utils/Looper.h>
|
||||
|
||||
#include "wifi_hal_state.h"
|
||||
#include "wifi_chip.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class WifiChip;
|
||||
|
||||
class Wifi : public V1_0::IWifi {
|
||||
class Wifi : public IWifi {
|
||||
public:
|
||||
Wifi(sp<Looper>& looper);
|
||||
|
||||
Return<void> registerEventCallback(
|
||||
const sp<V1_0::IWifiEventCallback>& callback) override;
|
||||
const sp<IWifiEventCallback>& callback) override;
|
||||
|
||||
Return<bool> isStarted() override;
|
||||
Return<void> start() override;
|
||||
@@ -63,7 +64,7 @@ class Wifi : public V1_0::IWifi {
|
||||
*/
|
||||
void DoHalEventLoop();
|
||||
|
||||
std::set<sp<V1_0::IWifiEventCallback>> callbacks_;
|
||||
std::set<sp<IWifiEventCallback>> callbacks_;
|
||||
sp<WifiChip> chip_;
|
||||
|
||||
WifiHalState state_;
|
||||
@@ -76,6 +77,8 @@ class Wifi : public V1_0::IWifi {
|
||||
DISALLOW_COPY_AND_ASSIGN(Wifi);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
WifiChip::WifiChip(
|
||||
WifiHalState* hal_state, wifi_interface_handle interface_handle)
|
||||
WifiChip::WifiChip(WifiHalState* hal_state,
|
||||
wifi_interface_handle interface_handle)
|
||||
: hal_state_(hal_state), interface_handle_(interface_handle) {}
|
||||
|
||||
void WifiChip::Invalidate() {
|
||||
@@ -34,8 +36,9 @@ void WifiChip::Invalidate() {
|
||||
}
|
||||
|
||||
Return<void> WifiChip::registerEventCallback(
|
||||
const sp<V1_0::IWifiChipEventCallback>& callback) {
|
||||
if (!hal_state_) return Void();
|
||||
const sp<IWifiChipEventCallback>& callback) {
|
||||
if (!hal_state_)
|
||||
return Void();
|
||||
// TODO(b/31632518): remove the callback when the client is destroyed
|
||||
callbacks_.insert(callback);
|
||||
return Void();
|
||||
@@ -52,21 +55,24 @@ Return<void> WifiChip::getAvailableModes(getAvailableModes_cb cb) {
|
||||
}
|
||||
|
||||
Return<void> WifiChip::configureChip(uint32_t /*mode_id*/) {
|
||||
if (!hal_state_) return Void();
|
||||
if (!hal_state_)
|
||||
return Void();
|
||||
// TODO add implementation
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<uint32_t> WifiChip::getMode() {
|
||||
if (!hal_state_) return 0;
|
||||
if (!hal_state_)
|
||||
return 0;
|
||||
// TODO add implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestChipDebugInfo() {
|
||||
if (!hal_state_) return Void();
|
||||
if (!hal_state_)
|
||||
return Void();
|
||||
|
||||
V1_0::IWifiChipEventCallback::ChipDebugInfo result;
|
||||
IWifiChipEventCallback::ChipDebugInfo result;
|
||||
result.driverDescription = "<unknown>";
|
||||
result.firmwareDescription = "<unknown>";
|
||||
char buffer[256];
|
||||
@@ -110,7 +116,8 @@ Return<void> WifiChip::requestFirmwareDebugDump() {
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <android/hardware/wifi/1.0/IWifiChip.h>
|
||||
#include <android-base/macros.h>
|
||||
#include <android/hardware/wifi/1.0/IWifiChip.h>
|
||||
#include <hardware_legacy/wifi_hal.h>
|
||||
|
||||
#include "wifi_hal_state.h"
|
||||
@@ -28,16 +28,17 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class WifiChip : public V1_0::IWifiChip {
|
||||
class WifiChip : public IWifiChip {
|
||||
public:
|
||||
WifiChip(
|
||||
WifiHalState* hal_state, wifi_interface_handle interface_handle);
|
||||
WifiChip(WifiHalState* hal_state, wifi_interface_handle interface_handle);
|
||||
|
||||
void Invalidate();
|
||||
|
||||
Return<void> registerEventCallback(
|
||||
const sp<V1_0::IWifiChipEventCallback>& callback) override;
|
||||
const sp<IWifiChipEventCallback>& callback) override;
|
||||
|
||||
Return<void> getAvailableModes(getAvailableModes_cb cb) override;
|
||||
|
||||
@@ -54,11 +55,13 @@ class WifiChip : public V1_0::IWifiChip {
|
||||
private:
|
||||
WifiHalState* hal_state_;
|
||||
wifi_interface_handle interface_handle_;
|
||||
std::set<sp<V1_0::IWifiChipEventCallback>> callbacks_;
|
||||
std::set<sp<IWifiChipEventCallback>> callbacks_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WifiChip);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace {
|
||||
class FunctionMessageHandler : public android::MessageHandler {
|
||||
public:
|
||||
explicit FunctionMessageHandler(const std::function<void()>& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
|
||||
~FunctionMessageHandler() override = default;
|
||||
|
||||
@@ -43,16 +42,19 @@ class FunctionMessageHandler : public android::MessageHandler {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
WifiHalState::WifiHalState(sp<Looper>& looper)
|
||||
: run_state_(RunState::STOPPED), looper_(looper) {}
|
||||
|
||||
void WifiHalState::PostTask(const std::function<void()>& callback) {
|
||||
sp<MessageHandler> message_handler =
|
||||
new FunctionMessageHandler(callback);
|
||||
sp<MessageHandler> message_handler = new FunctionMessageHandler(callback);
|
||||
looper_->sendMessage(message_handler, NULL);
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
/**
|
||||
* Class that stores common state and functionality shared between HAL services.
|
||||
@@ -41,11 +43,7 @@ class WifiHalState {
|
||||
/** opaque handle from vendor for use while HAL is running */
|
||||
wifi_handle hal_handle_;
|
||||
|
||||
enum class RunState {
|
||||
STOPPED,
|
||||
STARTED,
|
||||
STOPPING
|
||||
};
|
||||
enum class RunState { STOPPED, STARTED, STOPPING };
|
||||
|
||||
RunState run_state_;
|
||||
|
||||
@@ -55,6 +53,8 @@ class WifiHalState {
|
||||
DISALLOW_COPY_AND_ASSIGN(WifiHalState);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
Reference in New Issue
Block a user