mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 22:04:26 +00:00
wifi: Make methods deliver status synchronously (2/3) am: 5c05546fc9
am: dbfb6017fb
Change-Id: I9e0a3e100fd3a7bb3fe4f32e86ee3b538fa7eba4
This commit is contained in:
@@ -18,23 +18,19 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace {
|
||||
using android::sp;
|
||||
using android::hardware::hidl_vec;
|
||||
using android::hardware::hidl_string;
|
||||
|
||||
hidl_vec<hidl_string> createHidlVecOfIfaceNames(const std::string& ifname) {
|
||||
std::vector<hidl_string> createHidlVecOfIfaceNames(const std::string& ifname) {
|
||||
std::vector<hidl_string> ifnames;
|
||||
if (!ifname.empty()) {
|
||||
hidl_string hidl_ifname;
|
||||
hidl_ifname = ifname.c_str();
|
||||
ifnames.emplace_back(hidl_ifname);
|
||||
ifnames.emplace_back(ifname);
|
||||
}
|
||||
hidl_vec<hidl_string> hidl_ifnames;
|
||||
hidl_ifnames.setToExternal(ifnames.data(), ifnames.size());
|
||||
return hidl_ifnames;
|
||||
return ifnames;
|
||||
}
|
||||
|
||||
template <typename Iface>
|
||||
@@ -59,156 +55,181 @@ WifiChip::WifiChip(ChipId chip_id,
|
||||
void WifiChip::invalidate() {
|
||||
invalidateAndRemoveAllIfaces();
|
||||
legacy_hal_.reset();
|
||||
callbacks_.clear();
|
||||
event_callbacks_.clear();
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<ChipId> WifiChip::getId() {
|
||||
return chip_id_;
|
||||
Return<void> WifiChip::getId(getId_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
UINT32_MAX);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), chip_id_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::registerEventCallback(
|
||||
const sp<IWifiChipEventCallback>& callback) {
|
||||
if (!is_valid_)
|
||||
const sp<IWifiChipEventCallback>& event_callback,
|
||||
registerEventCallback_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID));
|
||||
return Void();
|
||||
}
|
||||
// TODO(b/31632518): remove the callback when the client is destroyed
|
||||
callbacks_.emplace_back(callback);
|
||||
event_callbacks_.emplace_back(event_callback);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getAvailableModes(getAvailableModes_cb cb) {
|
||||
Return<void> WifiChip::getAvailableModes(getAvailableModes_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(hidl_vec<ChipMode>());
|
||||
return Void();
|
||||
} else {
|
||||
// TODO add implementation
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<ChipMode>());
|
||||
return Void();
|
||||
}
|
||||
// TODO add implementation
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS),
|
||||
hidl_vec<ChipMode>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::configureChip(uint32_t /*mode_id*/) {
|
||||
if (!is_valid_)
|
||||
Return<void> WifiChip::configureChip(uint32_t /*mode_id*/,
|
||||
configureChip_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID));
|
||||
return Void();
|
||||
}
|
||||
|
||||
invalidateAndRemoveAllIfaces();
|
||||
// TODO add implementation
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<uint32_t> WifiChip::getMode() {
|
||||
if (!is_valid_)
|
||||
return 0;
|
||||
Return<void> WifiChip::getMode(getMode_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
UINT32_MAX);
|
||||
return Void();
|
||||
}
|
||||
// TODO add implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestChipDebugInfo() {
|
||||
if (!is_valid_)
|
||||
return Void();
|
||||
|
||||
IWifiChipEventCallback::ChipDebugInfo result;
|
||||
|
||||
std::pair<wifi_error, std::string> ret =
|
||||
legacy_hal_.lock()->getDriverVersion();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get driver version: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
FailureReason reason = CreateFailureReasonLegacyError(
|
||||
ret.first, " failed to get driver version");
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onChipDebugInfoFailure(reason);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
result.driverDescription = ret.second.c_str();
|
||||
|
||||
ret = legacy_hal_.lock()->getFirmwareVersion();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get firmware version: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
FailureReason reason = CreateFailureReasonLegacyError(
|
||||
ret.first, " failed to get firmware version");
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onChipDebugInfoFailure(reason);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
result.firmwareDescription = ret.second.c_str();
|
||||
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onChipDebugInfoAvailable(result);
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), 0);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestDriverDebugDump() {
|
||||
if (!is_valid_)
|
||||
return Void();
|
||||
|
||||
std::pair<wifi_error, std::vector<char>> ret =
|
||||
legacy_hal_.lock()->requestDriverMemoryDump();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get driver debug dump: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
FailureReason reason = CreateFailureReasonLegacyError(ret.first, "");
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onDriverDebugDumpFailure(reason);
|
||||
}
|
||||
Return<void> WifiChip::requestChipDebugInfo(
|
||||
requestChipDebugInfo_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
IWifiChip::ChipDebugInfo());
|
||||
return Void();
|
||||
}
|
||||
|
||||
IWifiChip::ChipDebugInfo result;
|
||||
|
||||
wifi_error legacy_status;
|
||||
std::string driver_desc;
|
||||
std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion();
|
||||
if (legacy_status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get driver version: "
|
||||
<< legacyErrorToString(legacy_status);
|
||||
WifiStatus status = createWifiStatusFromLegacyError(
|
||||
legacy_status, "failed to get driver version");
|
||||
hidl_status_cb(status, result);
|
||||
return Void();
|
||||
}
|
||||
result.driverDescription = driver_desc.c_str();
|
||||
|
||||
std::string firmware_desc;
|
||||
std::tie(legacy_status, firmware_desc) =
|
||||
legacy_hal_.lock()->getFirmwareVersion();
|
||||
if (legacy_status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get firmware version: "
|
||||
<< legacyErrorToString(legacy_status);
|
||||
WifiStatus status = createWifiStatusFromLegacyError(
|
||||
legacy_status, "failed to get firmware version");
|
||||
hidl_status_cb(status, result);
|
||||
return Void();
|
||||
}
|
||||
result.firmwareDescription = firmware_desc.c_str();
|
||||
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), result);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestDriverDebugDump(
|
||||
requestDriverDebugDump_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<uint8_t>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
wifi_error legacy_status;
|
||||
std::vector<char> driver_dump;
|
||||
std::tie(legacy_status, driver_dump) =
|
||||
legacy_hal_.lock()->requestDriverMemoryDump();
|
||||
if (legacy_status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get driver debug dump: "
|
||||
<< legacyErrorToString(legacy_status);
|
||||
hidl_status_cb(createWifiStatusFromLegacyError(legacy_status),
|
||||
hidl_vec<uint8_t>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
auto& driver_dump = ret.second;
|
||||
hidl_vec<uint8_t> hidl_data;
|
||||
hidl_data.setToExternal(reinterpret_cast<uint8_t*>(driver_dump.data()),
|
||||
driver_dump.size());
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onDriverDebugDumpAvailable(hidl_data);
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), hidl_data);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestFirmwareDebugDump() {
|
||||
if (!is_valid_)
|
||||
return Void();
|
||||
|
||||
std::pair<wifi_error, std::vector<char>> ret =
|
||||
legacy_hal_.lock()->requestFirmwareMemoryDump();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get firmware debug dump: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
FailureReason reason = CreateFailureReasonLegacyError(ret.first, "");
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onFirmwareDebugDumpFailure(reason);
|
||||
}
|
||||
Return<void> WifiChip::requestFirmwareDebugDump(
|
||||
requestFirmwareDebugDump_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<uint8_t>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
wifi_error legacy_status;
|
||||
std::vector<char> firmware_dump;
|
||||
std::tie(legacy_status, firmware_dump) =
|
||||
legacy_hal_.lock()->requestFirmwareMemoryDump();
|
||||
if (legacy_status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get firmware debug dump: "
|
||||
<< legacyErrorToString(legacy_status);
|
||||
hidl_status_cb(createWifiStatusFromLegacyError(legacy_status),
|
||||
hidl_vec<uint8_t>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
auto& firmware_dump = ret.second;
|
||||
hidl_vec<uint8_t> hidl_data;
|
||||
hidl_data.setToExternal(reinterpret_cast<uint8_t*>(firmware_dump.data()),
|
||||
firmware_dump.size());
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onFirmwareDebugDumpAvailable(hidl_data);
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), hidl_data);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createApIface(createApIface_cb cb) {
|
||||
Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// TODO(b/31997422): Disallow this based on the chip combination.
|
||||
std::string ifname = legacy_hal_.lock()->getApIfaceName();
|
||||
ap_iface_ = new WifiApIface(ifname, legacy_hal_);
|
||||
cb(ap_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb cb) {
|
||||
Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(hidl_vec<hidl_string>());
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<hidl_string>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -216,41 +237,47 @@ Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb cb) {
|
||||
if (ap_iface_.get()) {
|
||||
ifname = legacy_hal_.lock()->getApIfaceName().c_str();
|
||||
}
|
||||
cb(createHidlVecOfIfaceNames(ifname));
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS),
|
||||
createHidlVecOfIfaceNames(ifname));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getApIface(const hidl_string& ifname, getApIface_cb cb) {
|
||||
Return<void> WifiChip::getApIface(const hidl_string& ifname,
|
||||
getApIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (ap_iface_.get() &&
|
||||
(ifname.c_str() == legacy_hal_.lock()->getApIfaceName())) {
|
||||
cb(ap_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_);
|
||||
} else {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS),
|
||||
nullptr);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createNanIface(createNanIface_cb cb) {
|
||||
Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// TODO(b/31997422): Disallow this based on the chip combination.
|
||||
std::string ifname = legacy_hal_.lock()->getNanIfaceName();
|
||||
nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
|
||||
cb(nan_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb cb) {
|
||||
Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(hidl_vec<hidl_string>());
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<hidl_string>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -258,42 +285,47 @@ Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb cb) {
|
||||
if (nan_iface_.get()) {
|
||||
ifname = legacy_hal_.lock()->getNanIfaceName().c_str();
|
||||
}
|
||||
cb(createHidlVecOfIfaceNames(ifname));
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS),
|
||||
createHidlVecOfIfaceNames(ifname));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getNanIface(const hidl_string& ifname,
|
||||
getNanIface_cb cb) {
|
||||
getNanIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (nan_iface_.get() &&
|
||||
(ifname.c_str() == legacy_hal_.lock()->getNanIfaceName())) {
|
||||
cb(nan_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_);
|
||||
} else {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS),
|
||||
nullptr);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createP2pIface(createP2pIface_cb cb) {
|
||||
Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// TODO(b/31997422): Disallow this based on the chip combination.
|
||||
std::string ifname = legacy_hal_.lock()->getP2pIfaceName();
|
||||
p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_);
|
||||
cb(p2p_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb cb) {
|
||||
Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(hidl_vec<hidl_string>());
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<hidl_string>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -301,42 +333,47 @@ Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb cb) {
|
||||
if (p2p_iface_.get()) {
|
||||
ifname = legacy_hal_.lock()->getP2pIfaceName().c_str();
|
||||
}
|
||||
cb(createHidlVecOfIfaceNames(ifname));
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS),
|
||||
createHidlVecOfIfaceNames(ifname));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getP2pIface(const hidl_string& ifname,
|
||||
getP2pIface_cb cb) {
|
||||
getP2pIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (p2p_iface_.get() &&
|
||||
(ifname.c_str() == legacy_hal_.lock()->getP2pIfaceName())) {
|
||||
cb(p2p_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_);
|
||||
} else {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS),
|
||||
nullptr);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createStaIface(createStaIface_cb cb) {
|
||||
Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// TODO(b/31997422): Disallow this based on the chip combination.
|
||||
std::string ifname = legacy_hal_.lock()->getStaIfaceName();
|
||||
sta_iface_ = new WifiStaIface(ifname, legacy_hal_);
|
||||
cb(sta_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb cb) {
|
||||
Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(hidl_vec<hidl_string>());
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
hidl_vec<hidl_string>());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -344,36 +381,40 @@ Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb cb) {
|
||||
if (sta_iface_.get()) {
|
||||
ifname = legacy_hal_.lock()->getStaIfaceName().c_str();
|
||||
}
|
||||
cb(createHidlVecOfIfaceNames(ifname));
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS),
|
||||
createHidlVecOfIfaceNames(ifname));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::getStaIface(const hidl_string& ifname,
|
||||
getStaIface_cb cb) {
|
||||
getStaIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (sta_iface_.get() &&
|
||||
(ifname.c_str() == legacy_hal_.lock()->getStaIfaceName())) {
|
||||
cb(sta_iface_);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_);
|
||||
} else {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS),
|
||||
nullptr);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createRttController(const sp<IWifiIface>& bound_iface,
|
||||
createRttController_cb cb) {
|
||||
Return<void> WifiChip::createRttController(
|
||||
const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_CHIP_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);
|
||||
rtt_controllers_.emplace_back(rtt);
|
||||
cb(rtt);
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), rtt);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,39 +59,46 @@ class WifiChip : public IWifiChip {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<ChipId> getId() override;
|
||||
Return<void> getId(getId_cb hidl_status_cb) override;
|
||||
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;
|
||||
Return<void> createApIface(createApIface_cb cb) override;
|
||||
Return<void> getApIfaceNames(getApIfaceNames_cb cb) override;
|
||||
Return<void> getApIface(const hidl_string& ifname, getApIface_cb cb) override;
|
||||
Return<void> createNanIface(createNanIface_cb cb) override;
|
||||
Return<void> getNanIfaceNames(getNanIfaceNames_cb cb) override;
|
||||
const sp<IWifiChipEventCallback>& event_callback,
|
||||
registerEventCallback_cb hidl_status_cb) override;
|
||||
Return<void> getAvailableModes(getAvailableModes_cb hidl_status_cb) override;
|
||||
Return<void> configureChip(uint32_t mode_id,
|
||||
configureChip_cb hidl_status_cb) override;
|
||||
Return<void> getMode(getMode_cb hidl_status_cb) override;
|
||||
Return<void> requestChipDebugInfo(
|
||||
requestChipDebugInfo_cb hidl_status_cb) override;
|
||||
Return<void> requestDriverDebugDump(
|
||||
requestDriverDebugDump_cb hidl_status_cb) override;
|
||||
Return<void> requestFirmwareDebugDump(
|
||||
requestFirmwareDebugDump_cb hidl_status_cb) override;
|
||||
Return<void> createApIface(createApIface_cb hidl_status_cb) override;
|
||||
Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override;
|
||||
Return<void> getApIface(const hidl_string& ifname,
|
||||
getApIface_cb hidl_status_cb) override;
|
||||
Return<void> createNanIface(createNanIface_cb hidl_status_cb) override;
|
||||
Return<void> getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) override;
|
||||
Return<void> getNanIface(const hidl_string& ifname,
|
||||
getNanIface_cb cb) override;
|
||||
Return<void> createP2pIface(createP2pIface_cb cb) override;
|
||||
Return<void> getP2pIfaceNames(getP2pIfaceNames_cb cb) override;
|
||||
getNanIface_cb hidl_status_cb) override;
|
||||
Return<void> createP2pIface(createP2pIface_cb hidl_status_cb) override;
|
||||
Return<void> getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) override;
|
||||
Return<void> getP2pIface(const hidl_string& ifname,
|
||||
getP2pIface_cb cb) override;
|
||||
Return<void> createStaIface(createStaIface_cb cb) override;
|
||||
Return<void> getStaIfaceNames(getStaIfaceNames_cb cb) override;
|
||||
getP2pIface_cb hidl_status_cb) override;
|
||||
Return<void> createStaIface(createStaIface_cb hidl_status_cb) override;
|
||||
Return<void> getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) override;
|
||||
Return<void> getStaIface(const hidl_string& ifname,
|
||||
getStaIface_cb cb) override;
|
||||
Return<void> createRttController(const sp<IWifiIface>& bound_iface,
|
||||
createRttController_cb cb) override;
|
||||
getStaIface_cb hidl_status_cb) override;
|
||||
Return<void> createRttController(
|
||||
const sp<IWifiIface>& bound_iface,
|
||||
createRttController_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
void invalidateAndRemoveAllIfaces();
|
||||
|
||||
ChipId chip_id_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
std::vector<sp<IWifiChipEventCallback>> callbacks_;
|
||||
std::vector<sp<IWifiChipEventCallback>> event_callbacks_;
|
||||
sp<WifiApIface> ap_iface_;
|
||||
sp<WifiNanIface> nan_iface_;
|
||||
sp<WifiP2pIface> p2p_iface_;
|
||||
|
||||
Reference in New Issue
Block a user