wifi: Change namespace
Move the implementation to "android::hardware::wifi:V1_0::implementation"
namespace.
This is following the style guidelines in NFC HIDL
implementation(go/aog/279421).
While there,
Run checkstyle to correct formatting issues.
Bug:31936700
Test: mmma -j32 hardware/interfaces/wifi/1.0/default
Change-Id: I5600a60a0041b3318ed9289823ec335a8ed8a83d
diff --git a/wifi/1.0/default/failure_reason_util.cpp b/wifi/1.0/default/failure_reason_util.cpp
index 7fd2269..f703ebe 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 @@
}
}
-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 @@
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 @@
}
}
+} // 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 d731700..7d51bbf 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 a96584b..07e6c81 100644
--- a/wifi/1.0/default/service.cpp
+++ b/wifi/1.0/default/service.cpp
@@ -36,15 +36,15 @@
}
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 @@
<< "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;
diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp
index 0e10bfb..aa0fc5b 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 @@
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 @@
}
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 @@
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_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 @@
return kInterfaceNotFoundHandle;
}
-
void NoopHalCleanupHandler(wifi_handle) {}
Return<void> Wifi::stop() {
@@ -142,7 +141,8 @@
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 @@
}
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 @@
}
}
-
Return<void> 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 92712fd..0122741 100644
--- a/wifi/1.0/default/wifi.h
+++ b/wifi/1.0/default/wifi.h
@@ -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 @@
*/
void DoHalEventLoop();
- std::set<sp<V1_0::IWifiEventCallback>> callbacks_;
+ std::set<sp<IWifiEventCallback>> callbacks_;
sp<WifiChip> chip_;
WifiHalState state_;
@@ -76,6 +77,8 @@
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 e794f53..42118b7 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 @@
}
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::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();
}
-
+} // 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 583c151..d776644 100644
--- a/wifi/1.0/default/wifi_chip.h
+++ b/wifi/1.0/default/wifi_chip.h
@@ -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 @@
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
diff --git a/wifi/1.0/default/wifi_hal_state.cpp b/wifi/1.0/default/wifi_hal_state.cpp
index 11387d8..1483689 100644
--- a/wifi/1.0/default/wifi_hal_state.cpp
+++ b/wifi/1.0/default/wifi_hal_state.cpp
@@ -24,8 +24,7 @@
class FunctionMessageHandler : public android::MessageHandler {
public:
explicit FunctionMessageHandler(const std::function<void()>& callback)
- : callback_(callback) {
- }
+ : callback_(callback) {}
~FunctionMessageHandler() override = default;
@@ -43,16 +42,19 @@
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
diff --git a/wifi/1.0/default/wifi_hal_state.h b/wifi/1.0/default/wifi_hal_state.h
index 6b9fc53..40e39ec 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 @@
/** 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 @@
DISALLOW_COPY_AND_ASSIGN(WifiHalState);
};
+} // namespace implementation
+} // namespace V1_0
} // namespace wifi
} // namespace hardware
} // namespace android