diff options
| author | Roshan Pius <rpius@google.com> | 2016-12-09 12:05:12 -0800 |
|---|---|---|
| committer | Roshan Pius <rpius@google.com> | 2016-12-13 14:34:33 -0800 |
| commit | 8b55e6f475f77183b6420e9bc74316763d1bb987 (patch) | |
| tree | 303fc2e2b6d6bf6efa1912252394360d51758d9f /wifi | |
| parent | 11f930321ba8c3501ed4e24a5519f13d34f69b31 (diff) | |
| download | android_hardware_interfaces-8b55e6f475f77183b6420e9bc74316763d1bb987.tar.gz android_hardware_interfaces-8b55e6f475f77183b6420e9bc74316763d1bb987.tar.bz2 android_hardware_interfaces-8b55e6f475f77183b6420e9bc74316763d1bb987.zip | |
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
Diffstat (limited to 'wifi')
| -rw-r--r-- | wifi/1.0/IWifiChip.hal | 68 | ||||
| -rw-r--r-- | wifi/1.0/default/wifi_chip.cpp | 88 | ||||
| -rw-r--r-- | wifi/1.0/default/wifi_chip.h | 20 |
3 files changed, 156 insertions, 20 deletions
diff --git a/wifi/1.0/IWifiChip.hal b/wifi/1.0/IWifiChip.hal index 3c085c345..051a08859 100644 --- a/wifi/1.0/IWifiChip.hal +++ b/wifi/1.0/IWifiChip.hal @@ -323,13 +323,28 @@ interface IWifiChip { * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, - * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| * @return iface HIDL interface object representing the iface if * it exists, null otherwise. */ getApIface(string ifname) generates (WifiStatus status, IWifiApIface iface); /** + * Removes the AP Iface with the provided ifname. + * Any further calls on the corresponding |IWifiApIface| HIDL interface + * object must fail. + * + * @param ifname Name of the iface. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| + */ + removeApIface(string ifname) generates (WifiStatus status); + + /** * Create a NAN iface on the chip. * * Depending on the mode the chip is configured in, the interface creation @@ -368,13 +383,28 @@ interface IWifiChip { * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, - * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| * @return iface HIDL interface object representing the iface if * it exists, null otherwise. */ getNanIface(string ifname) generates (WifiStatus status, IWifiNanIface iface); /** + * Removes the NAN Iface with the provided ifname. + * Any further calls on the corresponding |IWifiNanIface| HIDL interface + * object must fail. + * + * @param ifname Name of the iface. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| + */ + removeNanIface(string ifname) generates (WifiStatus status); + + /** * Create a P2P iface on the chip. * * Depending on the mode the chip is configured in, the interface creation @@ -413,13 +443,28 @@ interface IWifiChip { * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, - * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| * @return iface HIDL interface object representing the iface if * it exists, null otherwise. */ getP2pIface(string ifname) generates (WifiStatus status, IWifiP2pIface iface); /** + * Removes the P2P Iface with the provided ifname. + * Any further calls on the corresponding |IWifiP2pIface| HIDL interface + * object must fail. + * + * @param ifname Name of the iface. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| + */ + removeP2pIface(string ifname) generates (WifiStatus status); + + /** * Create an STA iface on the chip. * * Depending on the mode the chip is configured in, the interface creation @@ -458,13 +503,28 @@ interface IWifiChip { * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, - * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| * @return iface HIDL interface object representing the iface if * it exists, null otherwise. */ getStaIface(string ifname) generates (WifiStatus status, IWifiStaIface iface); /** + * Removes the STA Iface with the provided ifname. + * Any further calls on the corresponding |IWifiStaIface| HIDL interface + * object must fail. + * + * @param ifname Name of the iface. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|, + * |WifiStatusCode.ERROR_INVALID_ARGS| + */ + removeStaIface(string ifname) generates (WifiStatus status); + + /** * Create a RTTController instance. * * RTT controller can be either: diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp index af194912a..d70f54878 100644 --- a/wifi/1.0/default/wifi_chip.cpp +++ b/wifi/1.0/default/wifi_chip.cpp @@ -163,6 +163,15 @@ Return<void> WifiChip::getApIface(const hidl_string& ifname, 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 @@ Return<void> WifiChip::getNanIface(const hidl_string& ifname, 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 @@ Return<void> WifiChip::getP2pIface(const hidl_string& ifname, 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 @@ Return<void> WifiChip::getStaIface(const hidl_string& ifname, 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 @@ WifiChip::getApIfaceNamesInternal() { } 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 @@ WifiChip::getNanIfaceNamesInternal() { } 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 @@ WifiChip::getP2pIfaceNamesInternal() { } 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 @@ WifiChip::getStaIfaceNamesInternal() { } 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_); diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h index 764445fab..5e7a0c37c 100644 --- a/wifi/1.0/default/wifi_chip.h +++ b/wifi/1.0/default/wifi_chip.h @@ -83,18 +83,26 @@ class WifiChip : public IWifiChip { Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override; Return<void> getApIface(const hidl_string& ifname, getApIface_cb hidl_status_cb) override; + Return<void> removeApIface(const hidl_string& ifname, + removeApIface_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 hidl_status_cb) override; + Return<void> removeNanIface(const hidl_string& ifname, + removeNanIface_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 hidl_status_cb) override; + Return<void> removeP2pIface(const hidl_string& ifname, + removeP2pIface_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 hidl_status_cb) override; + Return<void> removeStaIface(const hidl_string& ifname, + removeStaIface_cb hidl_status_cb) override; Return<void> createRttController( const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) override; @@ -131,19 +139,23 @@ class WifiChip : public IWifiChip { std::pair<WifiStatus, sp<IWifiApIface>> createApIfaceInternal(); std::pair<WifiStatus, std::vector<hidl_string>> getApIfaceNamesInternal(); std::pair<WifiStatus, sp<IWifiApIface>> getApIfaceInternal( - const hidl_string& ifname); + const std::string& ifname); + WifiStatus removeApIfaceInternal(const std::string& ifname); std::pair<WifiStatus, sp<IWifiNanIface>> createNanIfaceInternal(); std::pair<WifiStatus, std::vector<hidl_string>> getNanIfaceNamesInternal(); std::pair<WifiStatus, sp<IWifiNanIface>> getNanIfaceInternal( - const hidl_string& ifname); + const std::string& ifname); + WifiStatus removeNanIfaceInternal(const std::string& ifname); std::pair<WifiStatus, sp<IWifiP2pIface>> createP2pIfaceInternal(); std::pair<WifiStatus, std::vector<hidl_string>> getP2pIfaceNamesInternal(); std::pair<WifiStatus, sp<IWifiP2pIface>> getP2pIfaceInternal( - const hidl_string& ifname); + const std::string& ifname); + WifiStatus removeP2pIfaceInternal(const std::string& ifname); std::pair<WifiStatus, sp<IWifiStaIface>> createStaIfaceInternal(); std::pair<WifiStatus, std::vector<hidl_string>> getStaIfaceNamesInternal(); std::pair<WifiStatus, sp<IWifiStaIface>> getStaIfaceInternal( - const hidl_string& ifname); + const std::string& ifname); + WifiStatus removeStaIfaceInternal(const std::string& ifname); std::pair<WifiStatus, sp<IWifiRttController>> createRttControllerInternal( const sp<IWifiIface>& bound_iface); std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>> |
