diff --git a/wifi/1.0/default/failure_reason_util.cpp b/wifi/1.0/default/failure_reason_util.cpp index 7fd226978a..f703ebe2c2 100644 --- a/wifi/1.0/default/failure_reason_util.cpp +++ b/wifi/1.0/default/failure_reason_util.cpp @@ -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 diff --git a/wifi/1.0/default/failure_reason_util.h b/wifi/1.0/default/failure_reason_util.h index d731700347..7d51bbf2fe 100644 --- a/wifi/1.0/default/failure_reason_util.h +++ b/wifi/1.0/default/failure_reason_util.h @@ -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 diff --git a/wifi/1.0/default/service.cpp b/wifi/1.0/default/service.cpp index a96584b701..07e6c81e0d 100644 --- a/wifi/1.0/default/service.cpp +++ b/wifi/1.0/default/service.cpp @@ -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 service = - new android::hardware::wifi::Wifi(looper); - CHECK_EQ(service->registerAsService("wifi"), - android::NO_ERROR) << "Failed to register wifi HAL"; + android::sp 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; diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp index 0e10bfbcff..aa0fc5b65f 100644 --- a/wifi/1.0/default/wifi.cpp +++ b/wifi/1.0/default/wifi.cpp @@ -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) : state_(looper) { CHECK_EQ(init_wifi_vendor_hal_func_table(&state_.func_table_), WIFI_SUCCESS) @@ -43,7 +44,7 @@ Wifi::Wifi(sp& looper) : state_(looper) { } Return Wifi::registerEventCallback( - const sp& callback) { + const sp& callback) { // TODO(b/31632518): remove the callback when the client is destroyed callbacks_.insert(callback); return Void(); @@ -72,8 +73,8 @@ Return 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 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 Wifi::stop() { @@ -142,7 +141,8 @@ Return 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 Wifi::getChip(getChip_cb cb) { cb(chip_); return Void(); } +} // namespace implementation +} // namespace V1_0 } // namespace wifi } // namespace hardware } // namespace android diff --git a/wifi/1.0/default/wifi.h b/wifi/1.0/default/wifi.h index 92712fd961..01227418a1 100644 --- a/wifi/1.0/default/wifi.h +++ b/wifi/1.0/default/wifi.h @@ -21,25 +21,26 @@ #include #include -#include #include +#include #include #include #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); Return registerEventCallback( - const sp& callback) override; + const sp& callback) override; Return isStarted() override; Return start() override; @@ -63,7 +64,7 @@ class Wifi : public V1_0::IWifi { */ void DoHalEventLoop(); - std::set> callbacks_; + std::set> callbacks_; sp 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 diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp index e794f538a0..42118b75d2 100644 --- a/wifi/1.0/default/wifi_chip.cpp +++ b/wifi/1.0/default/wifi_chip.cpp @@ -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 WifiChip::registerEventCallback( - const sp& callback) { - if (!hal_state_) return Void(); + const sp& 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 WifiChip::getAvailableModes(getAvailableModes_cb cb) { } Return WifiChip::configureChip(uint32_t /*mode_id*/) { - if (!hal_state_) return Void(); + if (!hal_state_) + return Void(); // TODO add implementation return Void(); } Return WifiChip::getMode() { - if (!hal_state_) return 0; + if (!hal_state_) + return 0; // TODO add implementation return 0; } Return WifiChip::requestChipDebugInfo() { - if (!hal_state_) return Void(); + if (!hal_state_) + return Void(); - V1_0::IWifiChipEventCallback::ChipDebugInfo result; + IWifiChipEventCallback::ChipDebugInfo result; result.driverDescription = ""; result.firmwareDescription = ""; char buffer[256]; @@ -110,7 +116,8 @@ Return WifiChip::requestFirmwareDebugDump() { return Void(); } - +} // namespace implementation +} // namespace V1_0 } // namespace wifi } // namespace hardware } // namespace android diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h index 583c15185e..d776644581 100644 --- a/wifi/1.0/default/wifi_chip.h +++ b/wifi/1.0/default/wifi_chip.h @@ -19,8 +19,8 @@ #include -#include #include +#include #include #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 registerEventCallback( - const sp& callback) override; + const sp& callback) override; Return 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> callbacks_; + std::set> callbacks_; DISALLOW_COPY_AND_ASSIGN(WifiChip); }; +} // namespace implementation +} // namespace V1_0 } // namespace wifi } // namespace hardware } // namespace android diff --git a/wifi/1.0/default/wifi_hal_state.cpp b/wifi/1.0/default/wifi_hal_state.cpp index 11387d83d2..148368996a 100644 --- a/wifi/1.0/default/wifi_hal_state.cpp +++ b/wifi/1.0/default/wifi_hal_state.cpp @@ -24,8 +24,7 @@ namespace { class FunctionMessageHandler : public android::MessageHandler { public: explicit FunctionMessageHandler(const std::function& 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) : run_state_(RunState::STOPPED), looper_(looper) {} void WifiHalState::PostTask(const std::function& callback) { - sp message_handler = - new FunctionMessageHandler(callback); + sp message_handler = new FunctionMessageHandler(callback); looper_->sendMessage(message_handler, NULL); } +} // namespace implementation +} // namespace V1_0 } // namespace wifi } // namespace hardware } // namespace android diff --git a/wifi/1.0/default/wifi_hal_state.h b/wifi/1.0/default/wifi_hal_state.h index 6b9fc53acd..40e39ec424 100644 --- a/wifi/1.0/default/wifi_hal_state.h +++ b/wifi/1.0/default/wifi_hal_state.h @@ -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