Loading wifi/1.0/default/wifi.cpp +24 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,11 @@ #include "failure_reason_util.h" #include "wifi_chip.h" namespace { // Chip ID to use for the only supported chip. static constexpr android::hardware::wifi::V1_0::ChipId kChipId = 0; } // namespace namespace android { namespace hardware { namespace wifi { Loading @@ -33,7 +38,7 @@ Wifi::Wifi() Return<void> Wifi::registerEventCallback( const sp<IWifiEventCallback>& callback) { // TODO(b/31632518): remove the callback when the client is destroyed callbacks_.insert(callback); callbacks_.emplace_back(callback); return Void(); } Loading Loading @@ -67,7 +72,7 @@ Return<void> Wifi::start() { } // Create the chip instance once the HAL is started. chip_ = new WifiChip(legacy_hal_); chip_ = new WifiChip(kChipId, legacy_hal_); run_state_ = RunState::STARTED; for (const auto& callback : callbacks_) { callback->onStart(); Loading Loading @@ -108,8 +113,23 @@ Return<void> Wifi::stop() { return Void(); } Return<void> Wifi::getChip(getChip_cb cb) { Return<void> Wifi::getChipIds(getChipIds_cb cb) { std::vector<ChipId> chip_ids; if (chip_.get()) { chip_ids.emplace_back(kChipId); } hidl_vec<ChipId> hidl_data; hidl_data.setToExternal(chip_ids.data(), chip_ids.size()); cb(hidl_data); return Void(); } Return<void> Wifi::getChip(ChipId chip_id, getChip_cb cb) { if (chip_.get() && chip_id == kChipId) { cb(chip_); } else { cb(nullptr); } return Void(); } Loading wifi/1.0/default/wifi.h +3 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define WIFI_H_ #include <functional> #include <set> #include <android-base/macros.h> #include <android/hardware/wifi/1.0/IWifi.h> Loading Loading @@ -46,7 +45,8 @@ class Wifi : public IWifi { Return<bool> isStarted() override; Return<void> start() override; Return<void> stop() override; Return<void> getChip(getChip_cb cb) override; Return<void> getChipIds(getChipIds_cb cb) override; Return<void> getChip(ChipId chip_id, getChip_cb cb) override; private: enum class RunState { STOPPED, STARTED, STOPPING }; Loading @@ -55,7 +55,7 @@ class Wifi : public IWifi { // and shared with all the child HIDL interface objects. std::shared_ptr<WifiLegacyHal> legacy_hal_; RunState run_state_; std::set<sp<IWifiEventCallback>> callbacks_; std::vector<sp<IWifiEventCallback>> callbacks_; sp<WifiChip> chip_; DISALLOW_COPY_AND_ASSIGN(Wifi); Loading wifi/1.0/default/wifi_chip.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -26,14 +26,19 @@ namespace wifi { namespace V1_0 { namespace implementation { WifiChip::WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal) : legacy_hal_(legacy_hal) {} WifiChip::WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal) : chip_id_(chip_id), legacy_hal_(legacy_hal) {} void WifiChip::invalidate() { legacy_hal_.reset(); callbacks_.clear(); } Return<ChipId> WifiChip::getId() { return chip_id_; } Return<void> WifiChip::registerEventCallback( const sp<IWifiChipEventCallback>& callback) { if (!legacy_hal_.lock()) Loading wifi/1.0/default/wifi_chip.h +3 −1 Original line number Diff line number Diff line Loading @@ -37,11 +37,12 @@ namespace implementation { */ class WifiChip : public IWifiChip { public: WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal); WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal); // Invalidate this instance once the HAL is stopped. void invalidate(); // HIDL methods exposed. Return<ChipId> getId() override; Return<void> registerEventCallback( const sp<IWifiChipEventCallback>& callback) override; Return<void> getAvailableModes(getAvailableModes_cb cb) override; Loading @@ -52,6 +53,7 @@ class WifiChip : public IWifiChip { Return<void> requestFirmwareDebugDump() override; private: ChipId chip_id_; std::weak_ptr<WifiLegacyHal> legacy_hal_; std::set<sp<IWifiChipEventCallback>> callbacks_; Loading Loading
wifi/1.0/default/wifi.cpp +24 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,11 @@ #include "failure_reason_util.h" #include "wifi_chip.h" namespace { // Chip ID to use for the only supported chip. static constexpr android::hardware::wifi::V1_0::ChipId kChipId = 0; } // namespace namespace android { namespace hardware { namespace wifi { Loading @@ -33,7 +38,7 @@ Wifi::Wifi() Return<void> Wifi::registerEventCallback( const sp<IWifiEventCallback>& callback) { // TODO(b/31632518): remove the callback when the client is destroyed callbacks_.insert(callback); callbacks_.emplace_back(callback); return Void(); } Loading Loading @@ -67,7 +72,7 @@ Return<void> Wifi::start() { } // Create the chip instance once the HAL is started. chip_ = new WifiChip(legacy_hal_); chip_ = new WifiChip(kChipId, legacy_hal_); run_state_ = RunState::STARTED; for (const auto& callback : callbacks_) { callback->onStart(); Loading Loading @@ -108,8 +113,23 @@ Return<void> Wifi::stop() { return Void(); } Return<void> Wifi::getChip(getChip_cb cb) { Return<void> Wifi::getChipIds(getChipIds_cb cb) { std::vector<ChipId> chip_ids; if (chip_.get()) { chip_ids.emplace_back(kChipId); } hidl_vec<ChipId> hidl_data; hidl_data.setToExternal(chip_ids.data(), chip_ids.size()); cb(hidl_data); return Void(); } Return<void> Wifi::getChip(ChipId chip_id, getChip_cb cb) { if (chip_.get() && chip_id == kChipId) { cb(chip_); } else { cb(nullptr); } return Void(); } Loading
wifi/1.0/default/wifi.h +3 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define WIFI_H_ #include <functional> #include <set> #include <android-base/macros.h> #include <android/hardware/wifi/1.0/IWifi.h> Loading Loading @@ -46,7 +45,8 @@ class Wifi : public IWifi { Return<bool> isStarted() override; Return<void> start() override; Return<void> stop() override; Return<void> getChip(getChip_cb cb) override; Return<void> getChipIds(getChipIds_cb cb) override; Return<void> getChip(ChipId chip_id, getChip_cb cb) override; private: enum class RunState { STOPPED, STARTED, STOPPING }; Loading @@ -55,7 +55,7 @@ class Wifi : public IWifi { // and shared with all the child HIDL interface objects. std::shared_ptr<WifiLegacyHal> legacy_hal_; RunState run_state_; std::set<sp<IWifiEventCallback>> callbacks_; std::vector<sp<IWifiEventCallback>> callbacks_; sp<WifiChip> chip_; DISALLOW_COPY_AND_ASSIGN(Wifi); Loading
wifi/1.0/default/wifi_chip.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -26,14 +26,19 @@ namespace wifi { namespace V1_0 { namespace implementation { WifiChip::WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal) : legacy_hal_(legacy_hal) {} WifiChip::WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal) : chip_id_(chip_id), legacy_hal_(legacy_hal) {} void WifiChip::invalidate() { legacy_hal_.reset(); callbacks_.clear(); } Return<ChipId> WifiChip::getId() { return chip_id_; } Return<void> WifiChip::registerEventCallback( const sp<IWifiChipEventCallback>& callback) { if (!legacy_hal_.lock()) Loading
wifi/1.0/default/wifi_chip.h +3 −1 Original line number Diff line number Diff line Loading @@ -37,11 +37,12 @@ namespace implementation { */ class WifiChip : public IWifiChip { public: WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal); WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal); // Invalidate this instance once the HAL is stopped. void invalidate(); // HIDL methods exposed. Return<ChipId> getId() override; Return<void> registerEventCallback( const sp<IWifiChipEventCallback>& callback) override; Return<void> getAvailableModes(getAvailableModes_cb cb) override; Loading @@ -52,6 +53,7 @@ class WifiChip : public IWifiChip { Return<void> requestFirmwareDebugDump() override; private: ChipId chip_id_; std::weak_ptr<WifiLegacyHal> legacy_hal_; std::set<sp<IWifiChipEventCallback>> callbacks_; Loading