Merge "wpa_supplicant: Increase log level for 4-way handshake" into pi-dev
diff --git a/wpa_supplicant/hidl/1.1/hidl_manager.cpp b/wpa_supplicant/hidl/1.1/hidl_manager.cpp
index ef239c1..ca614d2 100644
--- a/wpa_supplicant/hidl/1.1/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/1.1/hidl_manager.cpp
@@ -287,6 +287,34 @@
 	}
 }
 
+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 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::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 @@
 			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 @@
 
 /**
  * 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 b596a38..4f100aa 100644
--- a/wpa_supplicant/hidl/1.1/hidl_manager.h
+++ b/wpa_supplicant/hidl/1.1/hidl_manager.h
@@ -39,6 +39,8 @@
 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 @@
 	    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 54c4007..6436745 100644
--- a/wpa_supplicant/hidl/1.1/sta_iface.cpp
+++ b/wpa_supplicant/hidl/1.1/sta_iface.cpp
@@ -159,6 +159,10 @@
 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::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_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 @@
 }
 
 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();