wifi: Add support for removing iface
This is needed to support dynamically switching between ifaces
within the same mode.
While there, correct couple of nits:
1. Pass std::string to the |get*IfaceInternal| methods. This makes the
name comparison easier.
2. Update the docstring of |get*Iface| in IWifiChip.hal to indicate that
we'll return ERROR_INVALID_ARGS if the iface name is wrong.
Bug: 33040049
Test: Compiles
Change-Id: I53584013283a10bf109f1c2ffb6136c44f11ed29
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index af19491..d70f548 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -163,6 +163,15 @@
ifname);
}
+Return<void> WifiChip::removeApIface(const hidl_string& ifname,
+ removeApIface_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeApIfaceInternal,
+ hidl_status_cb,
+ ifname);
+}
+
Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
@@ -186,6 +195,15 @@
ifname);
}
+Return<void> WifiChip::removeNanIface(const hidl_string& ifname,
+ removeNanIface_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeNanIfaceInternal,
+ hidl_status_cb,
+ ifname);
+}
+
Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
@@ -209,6 +227,15 @@
ifname);
}
+Return<void> WifiChip::removeP2pIface(const hidl_string& ifname,
+ removeP2pIface_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeP2pIfaceInternal,
+ hidl_status_cb,
+ ifname);
+}
+
Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
@@ -232,6 +259,15 @@
ifname);
}
+Return<void> WifiChip::removeStaIface(const hidl_string& ifname,
+ removeStaIface_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeStaIfaceInternal,
+ hidl_status_cb,
+ ifname);
+}
+
Return<void> WifiChip::createRttController(
const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) {
return validateAndCall(this,
@@ -483,14 +519,21 @@
}
std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal(
- const hidl_string& ifname) {
- if (!ap_iface_.get() ||
- (ifname.c_str() != legacy_hal_.lock()->getApIfaceName())) {
+ const std::string& ifname) {
+ if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
}
+WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) {
+ if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ invalidateAndClear(ap_iface_);
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+}
+
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
// Only 1 of NAN or P2P iface can be active at a time.
if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
@@ -512,14 +555,21 @@
}
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal(
- const hidl_string& ifname) {
- if (!nan_iface_.get() ||
- (ifname.c_str() != legacy_hal_.lock()->getNanIfaceName())) {
+ const std::string& ifname) {
+ if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
}
+WifiStatus WifiChip::removeNanIfaceInternal(const std::string& ifname) {
+ if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ invalidateAndClear(nan_iface_);
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+}
+
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() {
// Only 1 of NAN or P2P iface can be active at a time.
if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() ||
@@ -541,14 +591,21 @@
}
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal(
- const hidl_string& ifname) {
- if (!p2p_iface_.get() ||
- (ifname.c_str() != legacy_hal_.lock()->getP2pIfaceName())) {
+ const std::string& ifname) {
+ if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
}
+WifiStatus WifiChip::removeP2pIfaceInternal(const std::string& ifname) {
+ if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ invalidateAndClear(p2p_iface_);
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+}
+
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() {
if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
@@ -568,14 +625,21 @@
}
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal(
- const hidl_string& ifname) {
- if (!sta_iface_.get() ||
- (ifname.c_str() != legacy_hal_.lock()->getStaIfaceName())) {
+ const std::string& ifname) {
+ if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
}
+WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) {
+ if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ invalidateAndClear(sta_iface_);
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+}
+
std::pair<WifiStatus, sp<IWifiRttController>>
WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) {
sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);