return res;
}
+#ifdef ANDROID_P2P
+int p2p_search_pending(struct p2p_data *p2p)
+{
+ if(p2p == NULL)
+ return 0;
+
+ if(p2p->state == P2P_SEARCH_WHEN_READY)
+ return 1;
+
+ return 0;
+}
+#endif
int p2p_other_scan_completed(struct p2p_data *p2p)
{
return &dev->info;
}
+#ifdef ANDROID_P2P
+int p2p_search_in_progress(struct p2p_data *p2p)
+{
+ if (p2p == NULL)
+ return 0;
+
+ return p2p->state == P2P_SEARCH;
+}
+#endif
int p2p_in_progress(struct p2p_data *p2p)
{
*/
int p2p_in_progress(struct p2p_data *p2p);
+#ifdef ANDROID_P2P
+/**
+ * p2p_search_in_progress - Check whether a P2P SEARCH is in progress
+ * @p2p: P2P module context from p2p_init()
+ * Returns: 0 if P2P module is idle or 1 if an operation is in progress
+ */
+int p2p_search_in_progress(struct p2p_data *p2p);
+
+/**
+ * p2p_search_pending - Check whether there is a deferred P2P SEARCH
+ * @p2p: P2P module context from p2p_init()
+ * Returns: 0 if there is no deferred P2P search or 1 if there is one
+ */
+int p2p_search_pending(struct p2p_data *p2p);
+#endif
+
/**
* p2p_other_scan_completed - Notify completion of non-P2P scan
* @p2p: P2P module context from p2p_init()
return;
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
+#ifdef ANDROID
+ wpa_s->conf->ap_scan = DEFAULT_AP_SCAN;
+#endif
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
os_memset(wpa_s->bssid, 0, ETH_ALEN);
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
/* Return < 0 if no scan results could be fetched. */
+#ifdef ANDROID_P2P
+static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
+ union wpa_event_data *data, int suppress_event)
+#else
static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
union wpa_event_data *data)
+#endif
{
struct wpa_bss *selected;
struct wpa_ssid *ssid = NULL;
wpa_supplicant_notify_scanning(wpa_s, 0);
#ifdef CONFIG_P2P
+#ifdef ANDROID_P2P
+ if (p2p_search_pending(wpa_s->global->p2p) && !wpa_s->global->p2p_disabled &&
+#else
if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
+#endif
wpa_s->global->p2p != NULL) {
wpa_s->p2p_cb_on_scan_complete = 0;
if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
wpa_scan_results_free(scan_res);
return 0;
}
-
- wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available");
- wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
- wpas_notify_scan_results(wpa_s);
+#ifdef ANDROID_P2P
+ if(!suppress_event)
+#endif
+ {
+ wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available");
+ wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
+ wpas_notify_scan_results(wpa_s);
+ }
wpas_notify_scan_done(wpa_s, 1);
{
const char *rn, *rn2;
struct wpa_supplicant *ifs;
-
+#ifdef ANDROID_P2P
+ if (_wpa_supplicant_event_scan_results(wpa_s, data, 0) < 0) {
+#else
if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) {
+#endif
/*
* If no scan results could be fetched, then no need to
* notify those interfaces that did not actually request
if (rn2 && os_strcmp(rn, rn2) == 0) {
wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
"sibling", ifs->ifname);
+#ifdef ANDROID_P2P
+ if ( (ifs->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE) || (ifs->p2p_group_interface != NOT_P2P_GROUP_INTERFACE)) {
+ /* Do not update the scan results from STA interface to p2p interfaces */
+ wpa_printf(MSG_DEBUG, "Not Updating scan results on interface %s from "
+ "sibling %s", ifs->ifname, wpa_s->ifname);
+ continue;
+ }
+ else {
+ /* P2P_FIND will result in too many SCAN_RESULT_EVENTS within
+ * no time. Avoid announcing it to application as it may not
+ * be that useful (since results will be that of only 1,6,11).
+ * over to any other interface as it
+ */
+ if(p2p_search_in_progress(wpa_s->global->p2p))
+ _wpa_supplicant_event_scan_results(ifs, data, 1);
+ else
+ _wpa_supplicant_event_scan_results(ifs, data, 0);
+ }
+#else
_wpa_supplicant_event_scan_results(ifs, data);
+#endif
}
}
}
fast_reconnect = wpa_s->current_bss;
fast_reconnect_ssid = wpa_s->current_ssid;
} else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
+#ifdef ANDROID
+ wpa_supplicant_req_scan(wpa_s, 0, 500000);
+#else
wpa_supplicant_req_scan(wpa_s, 0, 100000);
+#endif
else
wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
"immediate scan");
#define P2P_MAX_CLIENT_IDLE 10
#endif /* P2P_MAX_CLIENT_IDLE */
-
+#ifdef ANDROID_P2P
+static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s);
+#endif
static void wpas_p2p_long_listen_timeout(void *eloop_ctx, void *timeout_ctx);
static struct wpa_supplicant *
wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
static void wpas_p2p_group_idle_timeout(void *eloop_ctx, void *timeout_ctx);
static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s);
+#ifdef ANDROID_P2P
+static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s)
+{
+ struct wpa_supplicant *iface = NULL;
+
+ for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
+ if(iface->scanning || iface->wpa_state == WPA_SCANNING) {
+ wpa_printf(MSG_DEBUG, "P2P: Scan in progress on %s,"
+ "defer P2P SEARCH", iface->ifname);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+#endif
static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res)
if (ret) {
wpa_s->scan_res_handler = NULL;
+#ifdef ANDROID_P2P
+ if (wpa_s->scanning || was_in_p2p_scan || wpas_global_scan_in_progress(wpa_s)) {
+#else
if (wpa_s->scanning || was_in_p2p_scan) {
+#endif
wpa_s->p2p_cb_on_scan_complete = 1;
ret = 1;
}
int interval)
{
int ret;
-
+#ifndef ANDROID_P2P
wpa_supplicant_notify_scanning(wpa_s, 1);
+#endif
ret = wpa_drv_sched_scan(wpa_s, params, interval * 1000);
if (ret)
wpa_supplicant_notify_scanning(wpa_s, 0);
- else
+ else {
wpa_s->sched_scanning = 1;
+#ifdef ANDROID_P2P
+ wpa_supplicant_notify_scanning(wpa_s, 1);
+#endif
+ }
return ret;
}
wpa_s->prev_scan_wildcard = 0;
wpa_supplicant_assoc_try(wpa_s, ssid);
return;
+#ifndef ANDROID
} else if (wpa_s->conf->ap_scan == 2) {
/*
* User-initiated scan request in ap_scan == 2; scan with
* wildcard SSID.
*/
ssid = NULL;
+#endif
} else {
struct wpa_ssid *start = ssid, *tssid;
int freqs_set = 0;
*/
void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
{
+#ifndef ANDROID
/* If there's at least one network that should be specifically scanned
* then don't cancel the scan and reschedule. Some drivers do
* background scanning which generates frequent scan results, and that
return;
}
}
-
+#endif
wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec",
sec, usec);
eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
sizeof(struct wpa_driver_scan_filter));
prev_state = wpa_s->wpa_state;
+#ifndef ANDROID_P2P
if (wpa_s->wpa_state == WPA_DISCONNECTED ||
wpa_s->wpa_state == WPA_INACTIVE)
wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
+#endif
/* Find the starting point from which to continue scanning */
ssid = wpa_s->conf->ssid;
{
wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request");
eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
+#ifdef ANDROID
+ wpa_supplicant_notify_scanning(wpa_s, 0);
+#endif
}
int scanning)
{
if (wpa_s->scanning != scanning) {
+#ifdef ANDROID_P2P
+ if(!wpa_s->sched_scanning)
+ wpa_s->scanning = scanning;
+#else
wpa_s->scanning = scanning;
+#endif
wpas_notify_scanning(wpa_s);
}
}