Merge "P2P: get cached scan results on iface creation to avoid scan"
diff --git a/wpa_supplicant/aidl/p2p_iface.cpp b/wpa_supplicant/aidl/p2p_iface.cpp
index d812a08..1fd015b 100644
--- a/wpa_supplicant/aidl/p2p_iface.cpp
+++ b/wpa_supplicant/aidl/p2p_iface.cpp
@@ -338,9 +338,7 @@
void joinScanWrapper(void *eloop_ctx, void *timeout_ctx)
{
- struct wpa_supplicant *wpa_s = (struct wpa_supplicant *) eloop_ctx;
-
- if (pending_join_scan_callback != NULL) {
+ if (pending_join_scan_callback) {
pending_join_scan_callback();
}
}
@@ -1371,7 +1369,6 @@
if (!wpa_group_s) {
return createStatus(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN);
}
- wpa_group_s->global->p2p_go_found_external_scan = 0;
if (wpas_p2p_group_remove(wpa_group_s, group_ifname.c_str())) {
return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
}
@@ -1970,10 +1967,8 @@
struct wpa_bss *bss = findBssBySsid(
wpa_s, peer_address.data(), ssid.data(), ssid.size());
if (bss) {
- wpa_s->global->p2p_go_found_external_scan = 1;
if (0 != joinGroup(wpa_s, bss->bssid, ssid, passphrase)) {
wpa_printf(MSG_ERROR, "P2P: Failed to join a group.");
- wpa_s->global->p2p_go_found_external_scan = 0;
}
// no need to notify group join failure here,
// it will be handled by wpas_p2p_group_add_persistent
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 1fbf07d..ce20970 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -6953,6 +6953,8 @@
int freq, int force_scan)
{
struct wpa_ssid *ssid;
+ int other_iface_found = 0;
+ struct wpa_supplicant *ifs;
wpa_s = wpas_p2p_get_group_iface(wpa_s, addr_allocated, 0);
if (wpa_s == NULL)
@@ -6997,6 +6999,26 @@
wpa_s->p2p_go_group_formation_completed = 0;
wpa_s->global->p2p_group_formation = wpa_s;
+ /*
+ * Get latest scan results from driver in case cached scan results from
+ * interfaces on the same wiphy allow us to skip the next scan by fast
+ * associating. Also update the scan time to the most recent scan result
+ * fetch time on the same radio so it reflects the actual time the last
+ * scan result event occurred.
+ */
+ wpa_supplicant_update_scan_results(wpa_s);
+ dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
+ radio_list) {
+ if (ifs == wpa_s)
+ continue;
+ if (!other_iface_found || os_reltime_before(&wpa_s->last_scan,
+ &ifs->last_scan)) {
+ other_iface_found = 1;
+ wpa_s->last_scan.sec = ifs->last_scan.sec;
+ wpa_s->last_scan.usec = ifs->last_scan.usec;
+ }
+ }
+
eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->p2pdev,
NULL);
eloop_register_timeout(P2P_MAX_INITIAL_CONN_WAIT, 0,
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 0e0937e..f9e927a 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -1036,19 +1036,6 @@
}
#ifdef CONFIG_P2P
-#ifdef ANDROID
- if (wpa_s->global->p2p_go_found_external_scan &&
- (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) &&
- (wpa_s->global->p2p_group_formation == wpa_s)) {
- wpa_dbg(wpa_s, MSG_DEBUG,
- "Try to fast associate since GO is found in external scan");
- wpa_s->global->p2p_go_found_external_scan = 0;
- if (wpa_supplicant_fast_associate(wpa_s) >= 0) {
- return;
- }
- }
-#endif
-
if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) &&
wpa_s->go_params && !wpa_s->conf->passive_scan) {
wpa_printf(MSG_DEBUG, "P2P: Use specific SSID for scan during P2P group formation (p2p_in_provisioning=%d show_group_started=%d)",
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index a76da0b..047e88d 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -311,7 +311,6 @@
unsigned int p2p_24ghz_social_channels:1;
unsigned int pending_p2ps_group:1;
unsigned int pending_group_iface_for_p2ps:1;
- unsigned int p2p_go_found_external_scan:1;
unsigned int pending_p2ps_group_freq;
#ifdef CONFIG_WIFI_DISPLAY