wifi: Add support for removing iface

am: 8b55e6f475

Change-Id: I403f1173636f520790d041155f8a3b8a9a06197d
This commit is contained in:
Roshan Pius 2016-12-14 01:24:46 +00:00 committed by android-build-merger
commit bb2dad47bb
3 changed files with 156 additions and 20 deletions

View file

@ -323,12 +323,27 @@ 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.
*
@ -368,12 +383,27 @@ 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.
*
@ -413,12 +443,27 @@ 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.
*
@ -458,12 +503,27 @@ 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.
*

View file

@ -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_);

View file

@ -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>>