From 44a8bf9806d125c5a66e9dde1f8f1087ff476d98 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Mon, 9 Apr 2018 13:32:40 -0700 Subject: [PATCH] [AWARE] Support a mix of 1.0 and 1.2 Callback registration Allow clients to register both 1.0 and 1.2 callback objects. Only execute the new callbacks for 1.2 callback objects. Purpose: allow 1.0 VTS tests to run as-is. Bug: 71581915 Test: atest VtsHalWifiNanV1_0TargetTest Test: act.py -c /wifi_aware.json -tc ThroughputTest:test_iperf_single_ndp_aware_only_ib Change-Id: I1e049498a0eaa176a6074c552b1a3c6f23d18fd0 --- wifi/1.2/default/wifi_nan_iface.cpp | 29 ++++++++++++++++++++++------- wifi/1.2/default/wifi_nan_iface.h | 11 ++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/wifi/1.2/default/wifi_nan_iface.cpp b/wifi/1.2/default/wifi_nan_iface.cpp index 535e3d3d0c..566d36e72b 100644 --- a/wifi/1.2/default/wifi_nan_iface.cpp +++ b/wifi/1.2/default/wifi_nan_iface.cpp @@ -427,7 +427,8 @@ WifiNanIface::WifiNanIface( return; } - for (const auto& callback : shared_ptr_this->getEventCallbacks()) { + for (const auto& callback : + shared_ptr_this->getEventCallbacks_1_2()) { if (!callback->eventDataPathConfirm_1_2(hidl_struct).isOk()) { LOG(ERROR) << "Failed to invoke the callback"; } @@ -483,7 +484,7 @@ WifiNanIface::WifiNanIface( return; } - for (const auto& callback : shared_ptr_this->getEventCallbacks()) { + for (const auto& callback : shared_ptr_this->getEventCallbacks_1_2()) { if (!callback->eventDataPathScheduleUpdate(hidl_struct).isOk()) { LOG(ERROR) << "Failed to invoke the callback"; } @@ -507,6 +508,7 @@ void WifiNanIface::invalidate() { legacy_hal_.reset(); event_cb_handler_.invalidate(); + event_cb_handler_1_2_.invalidate(); is_valid_ = false; } @@ -514,10 +516,16 @@ bool WifiNanIface::isValid() { return is_valid_; } std::string WifiNanIface::getName() { return ifname_; } -std::set> WifiNanIface::getEventCallbacks() { +std::set> +WifiNanIface::getEventCallbacks() { return event_cb_handler_.getCallbacks(); } +std::set> +WifiNanIface::getEventCallbacks_1_2() { + return event_cb_handler_1_2_.getCallbacks(); +} + Return WifiNanIface::getName(getName_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiNanIface::getNameInternal, hidl_status_cb); @@ -681,8 +689,11 @@ std::pair WifiNanIface::getTypeInternal() { } WifiStatus WifiNanIface::registerEventCallbackInternal( - const sp& /*callback*/) { - return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); + const sp& callback) { + if (!event_cb_handler_.addCallback(callback)) { + return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); + } + return createWifiStatus(WifiStatusCode::SUCCESS); } WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) { @@ -808,8 +819,12 @@ WifiStatus WifiNanIface::terminateDataPathRequestInternal( } WifiStatus WifiNanIface::registerEventCallback_1_2Internal( - const sp& callback) { - if (!event_cb_handler_.addCallback(callback)) { + const sp& callback) { + sp callback_1_0 = callback; + if (!event_cb_handler_.addCallback(callback_1_0)) { + return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); + } + if (!event_cb_handler_1_2_.addCallback(callback)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } return createWifiStatus(WifiStatusCode::SUCCESS); diff --git a/wifi/1.2/default/wifi_nan_iface.h b/wifi/1.2/default/wifi_nan_iface.h index a2dcf3a52e..dba527b5f5 100644 --- a/wifi/1.2/default/wifi_nan_iface.h +++ b/wifi/1.2/default/wifi_nan_iface.h @@ -132,7 +132,7 @@ class WifiNanIface : public V1_2::IWifiNanIface { uint32_t ndpInstanceId); WifiStatus registerEventCallback_1_2Internal( - const sp& callback); + const sp& callback); WifiStatus enableRequest_1_2Internal( uint16_t cmd_id, const NanEnableRequest& msg1, const NanConfigRequestSupplemental& msg2); @@ -140,13 +140,18 @@ class WifiNanIface : public V1_2::IWifiNanIface { uint16_t cmd_id, const NanConfigRequest& msg, const NanConfigRequestSupplemental& msg2); - std::set> getEventCallbacks(); + // all 1_0 and descendant callbacks + std::set> getEventCallbacks(); + // all 1_2 and descendant callbacks + std::set> getEventCallbacks_1_2(); std::string ifname_; std::weak_ptr legacy_hal_; bool is_valid_; - hidl_callback_util::HidlCallbackHandler + hidl_callback_util::HidlCallbackHandler event_cb_handler_; + hidl_callback_util::HidlCallbackHandler + event_cb_handler_1_2_; DISALLOW_COPY_AND_ASSIGN(WifiNanIface); };