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