wifi: Restructure wifi legacy HAL implementation
Restructured the existing code to create a new class called
|WifiLegacyHal|. This class will be used as a wrapper to invoke
all the legacy HAL functions and handle the "C" style callbacks.
Bug: 31936700
Test: mmma -j32 hardware/interfaces/wifi/1.0/default
Change-Id: I63e8543f49886f8446101320a97d1e96e30d1035
diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h
index d776644..95fabe4 100644
--- a/wifi/1.0/default/wifi_chip.h
+++ b/wifi/1.0/default/wifi_chip.h
@@ -21,9 +21,8 @@
#include <android-base/macros.h>
#include <android/hardware/wifi/1.0/IWifiChip.h>
-#include <hardware_legacy/wifi_hal.h>
-#include "wifi_hal_state.h"
+#include "wifi_legacy_hal.h"
namespace android {
namespace hardware {
@@ -31,30 +30,29 @@
namespace V1_0 {
namespace implementation {
+/**
+ * HIDL interface object used to control a Wifi HAL chip instance.
+ * Since there is only a single chip instance used today, there is no
+ * identifying handle information stored here.
+ */
class WifiChip : public IWifiChip {
public:
- WifiChip(WifiHalState* hal_state, wifi_interface_handle interface_handle);
+ WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Invalidate this instance once the HAL is stopped.
+ void invalidate();
- void Invalidate();
-
+ // HIDL methods exposed.
Return<void> registerEventCallback(
const sp<IWifiChipEventCallback>& callback) override;
-
Return<void> getAvailableModes(getAvailableModes_cb cb) override;
-
Return<void> configureChip(uint32_t mode_id) override;
-
Return<uint32_t> getMode() override;
-
Return<void> requestChipDebugInfo() override;
-
Return<void> requestDriverDebugDump() override;
-
Return<void> requestFirmwareDebugDump() override;
private:
- WifiHalState* hal_state_;
- wifi_interface_handle interface_handle_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
std::set<sp<IWifiChipEventCallback>> callbacks_;
DISALLOW_COPY_AND_ASSIGN(WifiChip);