Accumulative patch from commit 52728dcd25b5074fb7c0493a8155f096089ad6d0

P2P: Stop P2P_PD_DURING_FIND wait on PD Response RX
P2P: Postpone P2P scan only if station mode scan is pending
Use special scan result processing steps only on requesting interface
P2P: Re-start P2P operation if station mode scanning is stopped
P2P: Use common function for re-starting P2P scan after station scan

Change-Id: I62bb738a912483647606de1a5bd5357346ebd8f9
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 54afd01..825e90b 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -536,12 +536,14 @@
 
 	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - interface disabled");
+		wpas_p2p_continue_after_scan(wpa_s);
 		return;
 	}
 
 	if (wpa_s->disconnected && wpa_s->scan_req == NORMAL_SCAN_REQ) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "Disconnected - do not scan");
 		wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
+		wpas_p2p_continue_after_scan(wpa_s);
 		return;
 	}
 #ifdef ANDROID
@@ -555,9 +557,7 @@
 	    wpa_s->scan_req == NORMAL_SCAN_REQ) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan");
 		wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
-#ifdef CONFIG_P2P
-		wpa_s->sta_scan_pending = 0;
-#endif /* CONFIG_P2P */
+		wpas_p2p_continue_after_scan(wpa_s);
 		return;
 	}
 
@@ -1159,6 +1159,7 @@
 {
 	wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request");
 	eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
+	wpas_p2p_continue_after_scan(wpa_s);
 #ifdef ANDROID
 	wpa_supplicant_notify_scanning(wpa_s, 0);
 #endif
@@ -1636,3 +1637,9 @@
 	wpas_notify_scan_results(wpa_s);
 	wpas_notify_scan_done(wpa_s, 1);
 }
+
+
+int wpas_scan_scheduled(struct wpa_supplicant *wpa_s)
+{
+	return eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL);
+}