diff options
author | Ahmed ElArabawy <arabawy@google.com> | 2018-04-12 19:53:16 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-12 19:53:16 +0000 |
commit | fac65c6b8f7420e80ef98f191ea8360c365314e9 (patch) | |
tree | 84a7661b40a9bf64a1f148696d1853cc8f364806 | |
parent | ab9f5af6bed01bc2014ef4a1c2a2a9b5c6e81fac (diff) | |
parent | 349add1e55b52368814439f055b9d09b27ee2f33 (diff) | |
download | wpa_supplicant_8-fac65c6b8f7420e80ef98f191ea8360c365314e9.tar.gz |
Merge "Fix failures for V1.0 vts suites on V1.1 service" into pi-dev
-rw-r--r-- | wpa_supplicant/hidl/1.1/hidl_manager.cpp | 55 | ||||
-rw-r--r-- | wpa_supplicant/hidl/1.1/hidl_manager.h | 6 | ||||
-rw-r--r-- | wpa_supplicant/hidl/1.1/sta_iface.cpp | 17 |
3 files changed, 66 insertions, 12 deletions
diff --git a/wpa_supplicant/hidl/1.1/hidl_manager.cpp b/wpa_supplicant/hidl/1.1/hidl_manager.cpp index ef239c15..ca614d20 100644 --- a/wpa_supplicant/hidl/1.1/hidl_manager.cpp +++ b/wpa_supplicant/hidl/1.1/hidl_manager.cpp @@ -287,6 +287,34 @@ void callWithEachIfaceCallback( } } +template <class CallbackTypeV1_0, class CallbackTypeV1_1> +void callWithEachIfaceCallback_1_1( + const std::string &ifname, + const std::function< + android::hardware::Return<void>(android::sp<CallbackTypeV1_1>)> &method, + const std::map<const std::string, std::vector<android::sp<CallbackTypeV1_0>>> + &callbacks_map) +{ + if (ifname.empty()) + return; + + auto iface_callback_map_iter = callbacks_map.find(ifname); + if (iface_callback_map_iter == callbacks_map.end()) + return; + const auto &iface_callback_list = iface_callback_map_iter->second; + for (const auto &callback : iface_callback_list) { + android::sp<CallbackTypeV1_1> callback_1_1 = + CallbackTypeV1_1::castFrom(callback); + if (callback_1_1 == nullptr) + continue; + + if (!method(callback_1_1).isOk()) { + wpa_printf( + MSG_ERROR, "Failed to invoke HIDL iface callback"); + } + } +} + template <class CallbackType> void callWithEachNetworkCallback( const std::string &ifname, int network_id, @@ -372,6 +400,10 @@ namespace supplicant { namespace V1_1 { namespace implementation { +using namespace android::hardware::wifi::supplicant::V1_0; +using namespace android::hardware::wifi::supplicant::V1_1; +using V1_0::ISupplicantStaIfaceCallback; + HidlManager *HidlManager::instance_ = NULL; HidlManager *HidlManager::getInstance() @@ -1382,7 +1414,7 @@ void HidlManager::notifyExtRadioWorkTimeout( void HidlManager::notifyEapError(struct wpa_supplicant *wpa_s, int error_code) { - typedef ISupplicantStaIfaceCallback::EapErrorCode EapErrorCode; + typedef V1_1::ISupplicantStaIfaceCallback::EapErrorCode EapErrorCode; if (!wpa_s) return; @@ -1398,10 +1430,10 @@ void HidlManager::notifyEapError(struct wpa_supplicant *wpa_s, int error_code) return; } - callWithEachStaIfaceCallback( + callWithEachStaIfaceCallback_1_1( wpa_s->ifname, std::bind( - &ISupplicantStaIfaceCallback::onEapFailure_1_1, + &V1_1::ISupplicantStaIfaceCallback::onEapFailure_1_1, std::placeholders::_1, static_cast<EapErrorCode>(error_code))); } @@ -1736,6 +1768,23 @@ void HidlManager::callWithEachP2pIfaceCallback( /** * Helper fucntion to invoke the provided callback method on all the + * registered V1.1 iface callback hidl objects for the specified + * |ifname|. + * + * @param ifname Name of the corresponding interface. + * @param method Pointer to the required hidl method from + * |V1_1::ISupplicantIfaceCallback|. + */ +void HidlManager::callWithEachStaIfaceCallback_1_1( + const std::string &ifname, + const std::function<Return<void> + (android::sp<V1_1::ISupplicantStaIfaceCallback>)> &method) +{ + callWithEachIfaceCallback_1_1(ifname, method, sta_iface_callbacks_map_); +} + +/** + * Helper fucntion to invoke the provided callback method on all the * registered iface callback hidl objects for the specified * |ifname|. * diff --git a/wpa_supplicant/hidl/1.1/hidl_manager.h b/wpa_supplicant/hidl/1.1/hidl_manager.h index b596a380..4f100aae 100644 --- a/wpa_supplicant/hidl/1.1/hidl_manager.h +++ b/wpa_supplicant/hidl/1.1/hidl_manager.h @@ -39,6 +39,8 @@ namespace supplicant { namespace V1_1 { namespace implementation { using namespace android::hardware::wifi::supplicant::V1_0; +using namespace android::hardware::wifi::supplicant::V1_1; +using V1_0::ISupplicantStaIfaceCallback; /** * HidlManager is responsible for managing the lifetime of all @@ -189,6 +191,10 @@ private: const std::string &ifname, const std::function<android::hardware::Return<void>( android::sp<ISupplicantStaIfaceCallback>)> &method); + void callWithEachStaIfaceCallback_1_1( + const std::string &ifname, + const std::function<android::hardware::Return<void>( + android::sp<V1_1::ISupplicantStaIfaceCallback>)> &method); void callWithEachP2pNetworkCallback( const std::string &ifname, int network_id, const std::function<android::hardware::Return<void>( diff --git a/wpa_supplicant/hidl/1.1/sta_iface.cpp b/wpa_supplicant/hidl/1.1/sta_iface.cpp index 54c40075..64367451 100644 --- a/wpa_supplicant/hidl/1.1/sta_iface.cpp +++ b/wpa_supplicant/hidl/1.1/sta_iface.cpp @@ -159,6 +159,10 @@ namespace V1_1 { namespace implementation { using hidl_return_util::validateAndCall; +using namespace android::hardware::wifi::supplicant::V1_0; +using namespace android::hardware::wifi::supplicant::V1_1; +using V1_0::ISupplicantStaIfaceCallback; + StaIface::StaIface(struct wpa_global *wpa_global, const char ifname[]) : wpa_global_(wpa_global), ifname_(ifname), is_valid_(true) { @@ -215,7 +219,7 @@ Return<void> StaIface::listNetworks(listNetworks_cb _hidl_cb) } Return<void> StaIface::registerCallback( - const sp<android::hardware::wifi::supplicant::V1_0::ISupplicantStaIfaceCallback> + const sp<ISupplicantStaIfaceCallback> & callback, registerCallback_cb _hidl_cb) { return validateAndCall( @@ -224,12 +228,13 @@ Return<void> StaIface::registerCallback( } Return<void> StaIface::registerCallback_1_1( - const sp<ISupplicantStaIfaceCallback> &callback, + const sp<V1_1::ISupplicantStaIfaceCallback> &callback, registerCallback_cb _hidl_cb) { + sp<V1_0::ISupplicantStaIfaceCallback> callback_1_0 = callback; return validateAndCall( this, SupplicantStatusCode::FAILURE_IFACE_INVALID, - &StaIface::registerCallbackInternal_1_1, _hidl_cb, callback); + &StaIface::registerCallbackInternal, _hidl_cb, callback_1_0); } Return<void> StaIface::reassociate(reassociate_cb _hidl_cb) @@ -579,12 +584,6 @@ StaIface::listNetworksInternal() } SupplicantStatus StaIface::registerCallbackInternal( - const sp<android::hardware::wifi::supplicant::V1_0::ISupplicantStaIfaceCallback> &callback) -{ - return {SupplicantStatusCode::FAILURE_UNKNOWN, ""}; -} - -SupplicantStatus StaIface::registerCallbackInternal_1_1( const sp<ISupplicantStaIfaceCallback> &callback) { HidlManager *hidl_manager = HidlManager::getInstance(); |