wpa_supplicant(hidl): Send the active bssid on state change

wpa_supplicant uses different bssid field to indicate the active BSSID
before association & after. So, send the respective ones in the HIDL
callback.

Bug: 36451639
Test: Compiles & manual tests
Change-Id: I063bd0dff5c27efdd22cad4b8908ef27f4efce04
diff --git a/wpa_supplicant/hidl/hidl_manager.cpp b/wpa_supplicant/hidl/hidl_manager.cpp
index 2ba99bd..a22a0d1 100644
--- a/wpa_supplicant/hidl/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/hidl_manager.cpp
@@ -650,13 +650,22 @@
 		    wpa_s->current_ssid->ssid,
 		    wpa_s->current_ssid->ssid + wpa_s->current_ssid->ssid_len);
 	}
+	uint8_t *bssid;
+	// wpa_supplicant sets the |pending_bssid| field when it starts a
+	// connection. Only after association state does it update the |bssid|
+	// field. So, in the HIDL callback send the appropriate bssid.
+	if (wpa_s->wpa_state <= WPA_ASSOCIATED) {
+		bssid = wpa_s->pending_bssid;
+	} else {
+		bssid = wpa_s->bssid;
+	}
 	callWithEachStaIfaceCallback(
 	    wpa_s->ifname, std::bind(
 			       &ISupplicantStaIfaceCallback::onStateChanged,
 			       std::placeholders::_1,
 			       static_cast<ISupplicantStaIfaceCallback::State>(
 				   wpa_s->wpa_state),
-			       wpa_s->bssid, hidl_network_id, hidl_ssid));
+			       bssid, hidl_network_id, hidl_ssid));
 	return 0;
 }