mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 22:04:26 +00:00
wifi: Make methods deliver status synchronously (3/3)
am: 734fea0d98
Change-Id: I749781becee892317f741ca561ee825546870163
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -35,15 +35,24 @@ void WifiApIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiApIface::getName(getName_cb cb) {
|
||||
hidl_string hidl_ifname;
|
||||
hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
|
||||
cb(hidl_ifname);
|
||||
Return<void> WifiApIface::getName(getName_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
hidl_string());
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ifname_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<IfaceType> WifiApIface::getType() {
|
||||
return IfaceType::AP;
|
||||
Return<void> WifiApIface::getType(getType_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
IfaceType::AP);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::AP);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -39,8 +39,8 @@ class WifiApIface : public IWifiApIface {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb cb) override;
|
||||
Return<IfaceType> getType() override;
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
std::string ifname_;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_legacy_hal.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <cutils/properties.h>
|
||||
@@ -188,7 +188,7 @@ wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
|
||||
global_handle_, &num_iface_handles, &iface_handles);
|
||||
if (status != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to enumerate interface handles: "
|
||||
<< LegacyErrorToString(status);
|
||||
<< legacyErrorToString(status);
|
||||
return status;
|
||||
}
|
||||
for (int i = 0; i < num_iface_handles; ++i) {
|
||||
@@ -198,7 +198,7 @@ wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
|
||||
iface_handles[i], current_ifname.data(), current_ifname.size());
|
||||
if (status != WIFI_SUCCESS) {
|
||||
LOG(WARNING) << "Failed to get interface handle name: "
|
||||
<< LegacyErrorToString(status);
|
||||
<< legacyErrorToString(status);
|
||||
continue;
|
||||
}
|
||||
if (ifname_to_find == current_ifname.data()) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <hardware_legacy/wifi_hal.h>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -35,15 +35,24 @@ void WifiNanIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiNanIface::getName(getName_cb cb) {
|
||||
hidl_string hidl_ifname;
|
||||
hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
|
||||
cb(hidl_ifname);
|
||||
Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
hidl_string());
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ifname_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<IfaceType> WifiNanIface::getType() {
|
||||
return IfaceType::NAN;
|
||||
Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
IfaceType::NAN);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -39,8 +39,8 @@ class WifiNanIface : public IWifiNanIface {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb cb) override;
|
||||
Return<IfaceType> getType() override;
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
std::string ifname_;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -35,15 +35,24 @@ void WifiP2pIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiP2pIface::getName(getName_cb cb) {
|
||||
hidl_string hidl_ifname;
|
||||
hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
|
||||
cb(hidl_ifname);
|
||||
Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
hidl_string());
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ifname_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<IfaceType> WifiP2pIface::getType() {
|
||||
return IfaceType::P2P;
|
||||
Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
IfaceType::P2P);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -39,8 +39,8 @@ class WifiP2pIface : public IWifiP2pIface {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb cb) override;
|
||||
Return<IfaceType> getType() override;
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
std::string ifname_;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -36,8 +36,14 @@ void WifiRttController::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiRttController::getBoundIface(getBoundIface_cb cb) {
|
||||
cb(bound_iface_);
|
||||
Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(
|
||||
createWifiStatus(WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID),
|
||||
nullptr);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class WifiRttController : public IWifiRttController {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getBoundIface(getBoundIface_cb cb) override;
|
||||
Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
sp<IWifiIface> bound_iface_;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -35,15 +35,24 @@ void WifiStaIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiStaIface::getName(getName_cb cb) {
|
||||
hidl_string hidl_ifname;
|
||||
hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
|
||||
cb(hidl_ifname);
|
||||
Return<void> WifiStaIface::getName(getName_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
hidl_string());
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ifname_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<IfaceType> WifiStaIface::getType() {
|
||||
return IfaceType::STA;
|
||||
Return<void> WifiStaIface::getType(getType_cb hidl_status_cb) {
|
||||
if (!is_valid_) {
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID),
|
||||
IfaceType::STA);
|
||||
return Void();
|
||||
}
|
||||
hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -39,8 +39,8 @@ class WifiStaIface : public IWifiStaIface {
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb cb) override;
|
||||
Return<IfaceType> getType() override;
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
std::string ifname_;
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
std::string legacyErrorToString(wifi_error error);
|
||||
|
||||
WifiStatus createWifiStatus(WifiStatusCode code,
|
||||
const std::string& description);
|
||||
WifiStatus createWifiStatus(WifiStatusCode code);
|
||||
|
||||
Reference in New Issue
Block a user