Fix PTK rekeying to generate a new ANonce am: e52ae8e63a am: a1f3ac5a6e  -s ours am: 36dc61025b  -s ours am: 66cf8e0f1e  -s ours am: a1a392bfd4  -s ours am: 9e44f88253  -s ours am: 2fc627faae  -s ours am: 72f303c62b  -s ours am: e24998d0ec  -s ours am: 37dbf4894d  -s ours am: 758ed7d4e7  -s ours
am: 7e8bf5031c  -s ours

Change-Id: I6533f7c5fb186cc7c0b51480ba14c1341e7817d0
diff --git a/wpa_supplicant/hidl/1.0/hidl.cpp b/wpa_supplicant/hidl/1.0/hidl.cpp
index e5f5303..ca914b4 100644
--- a/wpa_supplicant/hidl/1.0/hidl.cpp
+++ b/wpa_supplicant/hidl/1.0/hidl.cpp
@@ -530,13 +530,18 @@
 void wpas_hidl_notify_p2p_invitation_result(
     struct wpa_supplicant *wpa_s, int status, const u8 *bssid)
 {
-	if (!wpa_s || !bssid)
+	if (!wpa_s)
 		return;
-
-	wpa_printf(
-	    MSG_DEBUG,
-	    "Notifying P2P invitation result to hidl control: " MACSTR,
-	    MAC2STR(bssid));
+	if (bssid) {
+		wpa_printf(
+			MSG_DEBUG,
+			"Notifying P2P invitation result to hidl control: " MACSTR,
+			MAC2STR(bssid));
+	} else {
+		wpa_printf(
+			MSG_DEBUG,
+			"Notifying P2P invitation result to hidl control: NULL bssid");
+	}
 
 	HidlManager *hidl_manager = HidlManager::getInstance();
 	if (!hidl_manager)
diff --git a/wpa_supplicant/hidl/1.0/hidl_manager.cpp b/wpa_supplicant/hidl/1.0/hidl_manager.cpp
index 72b53a4..622dcbf 100644
--- a/wpa_supplicant/hidl/1.0/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/1.0/hidl_manager.cpp
@@ -1256,7 +1256,7 @@
 void HidlManager::notifyP2pInvitationResult(
     struct wpa_supplicant *wpa_s, int status, const u8 *bssid)
 {
-	if (!wpa_s || !bssid)
+	if (!wpa_s)
 		return;
 
 	if (p2p_iface_object_map_.find(wpa_s->ifname) ==
@@ -1267,7 +1267,7 @@
 	    wpa_s->ifname,
 	    std::bind(
 		&ISupplicantP2pIfaceCallback::onInvitationResult,
-		std::placeholders::_1, bssid,
+		std::placeholders::_1, bssid ? bssid : kZeroBssid,
 		static_cast<ISupplicantP2pIfaceCallback::P2pStatusCode>(
 		    status)));
 }
diff --git a/wpa_supplicant/hidl/1.0/supplicant.cpp b/wpa_supplicant/hidl/1.0/supplicant.cpp
index 409547f..a381511 100644
--- a/wpa_supplicant/hidl/1.0/supplicant.cpp
+++ b/wpa_supplicant/hidl/1.0/supplicant.cpp
@@ -111,6 +111,9 @@
 			return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""},
 				iface};
 		}
+		// Set this flag true here, since there is no HIDL initialize method for the p2p
+		// config, and the supplicant interface is not ready when the p2p iface is created.
+		wpa_s->conf->persistent_reconnect = true;
 		return {{SupplicantStatusCode::SUCCESS, ""}, iface};
 	} else {
 		android::sp<ISupplicantStaIface> iface;