Loading wifi/aidl/default/aidl_callback_util.h +19 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ namespace { std::unordered_map<void* /* callback */, void* /* handler */> callback_handler_map_; std::mutex callback_handler_lock_; int32_t min_callback_version_ = INT_MAX; } namespace aidl { Loading @@ -50,6 +51,13 @@ class AidlCallbackHandler { return false; } // Callback interface version indicates which methods are available int callbackVersion = getCallbackInterfaceVersion(cb); if (callbackVersion < min_callback_version_) { LOG(INFO) << "Setting min callback version to " << callbackVersion; min_callback_version_ = callbackVersion; } std::unique_lock<std::mutex> lk(callback_handler_lock_); void* cbPtr = reinterpret_cast<void*>(cb->asBinder().get()); const auto& cbPosition = findCbInSet(cbPtr); Loading Loading @@ -111,6 +119,8 @@ class AidlCallbackHandler { // unique_lock unlocked here } int32_t getMinCallbackVersion() { return min_callback_version_; } private: std::set<std::shared_ptr<CallbackType>> cb_set_; AIBinder_DeathRecipient* death_handler_; Loading Loading @@ -145,6 +155,15 @@ class AidlCallbackHandler { } } static int32_t getCallbackInterfaceVersion(std::shared_ptr<CallbackType> callback) { int32_t callbackVersion; if (!callback->getInterfaceVersion(&callbackVersion).isOk()) { LOG(ERROR) << "Unable to check the callback version"; return INT_MAX; } return callbackVersion; } DISALLOW_COPY_AND_ASSIGN(AidlCallbackHandler); }; Loading wifi/aidl/default/wifi_nan_iface.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -672,6 +672,10 @@ std::string WifiNanIface::getName() { return ifname_; } int32_t WifiNanIface::getMinCallbackVersion() { return event_cb_handler_.getMinCallbackVersion(); } std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() { LOG(ERROR) << "Using original getEventCallbacks"; return event_cb_handler_.getCallbacks(); Loading wifi/aidl/default/wifi_nan_iface.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ class WifiNanIface : public BnWifiNanIface { ndk::ScopedAStatus suspendRequestInternal(char16_t in_cmdId, int8_t sessionId); ndk::ScopedAStatus resumeRequestInternal(char16_t in_cmdId, int8_t sessionId); int32_t getMinCallbackVersion(); // Overridden in the gTest suite. virtual std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> getEventCallbacks(); Loading Loading
wifi/aidl/default/aidl_callback_util.h +19 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ namespace { std::unordered_map<void* /* callback */, void* /* handler */> callback_handler_map_; std::mutex callback_handler_lock_; int32_t min_callback_version_ = INT_MAX; } namespace aidl { Loading @@ -50,6 +51,13 @@ class AidlCallbackHandler { return false; } // Callback interface version indicates which methods are available int callbackVersion = getCallbackInterfaceVersion(cb); if (callbackVersion < min_callback_version_) { LOG(INFO) << "Setting min callback version to " << callbackVersion; min_callback_version_ = callbackVersion; } std::unique_lock<std::mutex> lk(callback_handler_lock_); void* cbPtr = reinterpret_cast<void*>(cb->asBinder().get()); const auto& cbPosition = findCbInSet(cbPtr); Loading Loading @@ -111,6 +119,8 @@ class AidlCallbackHandler { // unique_lock unlocked here } int32_t getMinCallbackVersion() { return min_callback_version_; } private: std::set<std::shared_ptr<CallbackType>> cb_set_; AIBinder_DeathRecipient* death_handler_; Loading Loading @@ -145,6 +155,15 @@ class AidlCallbackHandler { } } static int32_t getCallbackInterfaceVersion(std::shared_ptr<CallbackType> callback) { int32_t callbackVersion; if (!callback->getInterfaceVersion(&callbackVersion).isOk()) { LOG(ERROR) << "Unable to check the callback version"; return INT_MAX; } return callbackVersion; } DISALLOW_COPY_AND_ASSIGN(AidlCallbackHandler); }; Loading
wifi/aidl/default/wifi_nan_iface.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -672,6 +672,10 @@ std::string WifiNanIface::getName() { return ifname_; } int32_t WifiNanIface::getMinCallbackVersion() { return event_cb_handler_.getMinCallbackVersion(); } std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() { LOG(ERROR) << "Using original getEventCallbacks"; return event_cb_handler_.getCallbacks(); Loading
wifi/aidl/default/wifi_nan_iface.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ class WifiNanIface : public BnWifiNanIface { ndk::ScopedAStatus suspendRequestInternal(char16_t in_cmdId, int8_t sessionId); ndk::ScopedAStatus resumeRequestInternal(char16_t in_cmdId, int8_t sessionId); int32_t getMinCallbackVersion(); // Overridden in the gTest suite. virtual std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> getEventCallbacks(); Loading