mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 10:05:19 +00:00
wifi: Use hidl_return_util functions in Iface/Rtt
am: 907d4a234d
Change-Id: I224f3edf8aefe3e47e1604b457e5aa57b9c7a301
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wifi_ap_iface.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "hidl_return_util.h"
|
||||
#include "wifi_ap_iface.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
@@ -25,6 +25,7 @@ namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
WifiApIface::WifiApIface(const std::string& ifname,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal)
|
||||
@@ -35,24 +36,30 @@ void WifiApIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
bool WifiApIface::isValid() {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
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 validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiApIface::getNameInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
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();
|
||||
return validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiApIface::getTypeInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, IfaceType> WifiApIface::getTypeInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::AP};
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -37,12 +37,17 @@ class WifiApIface : public IWifiApIface {
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
bool isValid();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
// Corresponding worker functions for the HIDL methods.
|
||||
std::pair<WifiStatus, std::string> getNameInternal();
|
||||
std::pair<WifiStatus, IfaceType> getTypeInternal();
|
||||
|
||||
std::string ifname_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wifi_nan_iface.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "hidl_return_util.h"
|
||||
#include "wifi_nan_iface.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
@@ -25,6 +25,7 @@ namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
WifiNanIface::WifiNanIface(const std::string& ifname,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal)
|
||||
@@ -35,24 +36,30 @@ void WifiNanIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
bool WifiNanIface::isValid() {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
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 validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiNanIface::getNameInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
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();
|
||||
return validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiNanIface::getTypeInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN};
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -37,12 +37,17 @@ class WifiNanIface : public IWifiNanIface {
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
bool isValid();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
// Corresponding worker functions for the HIDL methods.
|
||||
std::pair<WifiStatus, std::string> getNameInternal();
|
||||
std::pair<WifiStatus, IfaceType> getTypeInternal();
|
||||
|
||||
std::string ifname_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wifi_p2p_iface.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "hidl_return_util.h"
|
||||
#include "wifi_p2p_iface.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
@@ -25,6 +25,7 @@ namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
WifiP2pIface::WifiP2pIface(const std::string& ifname,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal)
|
||||
@@ -35,24 +36,30 @@ void WifiP2pIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
bool WifiP2pIface::isValid() {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
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 validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiP2pIface::getNameInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
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();
|
||||
return validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiP2pIface::getTypeInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, std::string> WifiP2pIface::getNameInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, IfaceType> WifiP2pIface::getTypeInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -37,12 +37,17 @@ class WifiP2pIface : public IWifiP2pIface {
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
bool isValid();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
// Corresponding worker functions for the HIDL methods.
|
||||
std::pair<WifiStatus, std::string> getNameInternal();
|
||||
std::pair<WifiStatus, IfaceType> getTypeInternal();
|
||||
|
||||
std::string ifname_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wifi_rtt_controller.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "hidl_return_util.h"
|
||||
#include "wifi_rtt_controller.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
@@ -25,6 +25,7 @@ namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
WifiRttController::WifiRttController(
|
||||
const sp<IWifiIface>& bound_iface,
|
||||
@@ -36,15 +37,20 @@ void WifiRttController::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
bool WifiRttController::isValid() {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
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();
|
||||
return validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
|
||||
&WifiRttController::getBoundIfaceInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, sp<IWifiIface>>
|
||||
WifiRttController::getBoundIfaceInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -38,11 +38,15 @@ class WifiRttController : public IWifiRttController {
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
bool isValid();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
// Corresponding worker functions for the HIDL methods.
|
||||
std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
|
||||
|
||||
sp<IWifiIface> bound_iface_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wifi_sta_iface.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "hidl_return_util.h"
|
||||
#include "wifi_sta_iface.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
namespace android {
|
||||
@@ -25,6 +25,7 @@ namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
WifiStaIface::WifiStaIface(const std::string& ifname,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal)
|
||||
@@ -35,24 +36,30 @@ void WifiStaIface::invalidate() {
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
bool WifiStaIface::isValid() {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
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 validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiStaIface::getNameInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
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();
|
||||
return validateAndCall(this,
|
||||
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
|
||||
&WifiStaIface::getTypeInternal,
|
||||
hidl_status_cb);
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
|
||||
}
|
||||
|
||||
std::pair<WifiStatus, IfaceType> WifiStaIface::getTypeInternal() {
|
||||
return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA};
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -37,12 +37,17 @@ class WifiStaIface : public IWifiStaIface {
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
bool isValid();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getName(getName_cb hidl_status_cb) override;
|
||||
Return<void> getType(getType_cb hidl_status_cb) override;
|
||||
|
||||
private:
|
||||
// Corresponding worker functions for the HIDL methods.
|
||||
std::pair<WifiStatus, std::string> getNameInternal();
|
||||
std::pair<WifiStatus, IfaceType> getTypeInternal();
|
||||
|
||||
std::string ifname_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
Reference in New Issue
Block a user