OSDN Git Service

Reconcile with jb-dev - do not merge
[android-x86/external-wpa_supplicant_8.git] / wpa_supplicant / p2p_supplicant.c
index 5e7edc8..5f1329e 100644 (file)
  * How many seconds to try to reconnect to the GO when connection in P2P client
  * role has been lost.
  */
+#ifdef ANDROID_P2P
+#define P2P_MAX_CLIENT_IDLE 20
+#else
 #define P2P_MAX_CLIENT_IDLE 10
+#endif /* ANDROID_P2P */
 #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,
@@ -63,6 +69,22 @@ static void wpas_p2p_cross_connect_setup(struct wpa_supplicant *wpa_s);
 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)
@@ -157,7 +179,11 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
 
        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;
                }
@@ -3383,8 +3409,10 @@ static void wpas_p2p_idle_update(void *ctx, int idle)
        if (!wpa_s->ap_iface)
                return;
        wpa_printf(MSG_DEBUG, "P2P: GO - group %sidle", idle ? "" : "not ");
-       if (idle)
+       if (idle) {
+               wpa_printf(MSG_DEBUG,"Calling set group idle time out from idle_update");
                wpas_p2p_set_group_idle_timeout(wpa_s);
+       }
        else
                eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
 }
@@ -3908,8 +3936,8 @@ static void wpas_p2p_group_idle_timeout(void *eloop_ctx, void *timeout_ctx)
                return;
        }
 
-       wpa_printf(MSG_DEBUG, "P2P: Group idle timeout reached - terminate "
-                  "group");
+       wpa_printf(MSG_DEBUG, "P2P: Group idle timeout reached - terminate %d"
+                  "group",wpa_s->conf->p2p_group_idle);
        wpa_s->removal_reason = P2P_GROUP_REMOVAL_IDLE_TIMEOUT;
        wpas_p2p_group_delete(wpa_s);
 }
@@ -4183,7 +4211,10 @@ void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s)
        if (!wpa_s->ap_iface &&
            !eloop_is_timeout_registered(wpas_p2p_group_idle_timeout,
                                         wpa_s, NULL))
+       {
+               wpa_printf(MSG_DEBUG,"Calling set grouple idle_timeout from notif_disconnected");
                wpas_p2p_set_group_idle_timeout(wpa_s);
+       }
 }
 
 
@@ -4393,7 +4424,13 @@ void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
                                 wpa_s->parent, NULL) > 0) {
                wpa_printf(MSG_DEBUG, "P2P: Canceled group formation due to "
                           "P2P group network getting removed");
+#ifdef ANDROID_P2P
+               /* Give time for any Pending WPS Frame exchange */
+               eloop_register_timeout(5, 0, wpas_p2p_group_formation_timeout,
+                       wpa_s->parent, NULL);
+#else
                wpas_p2p_group_formation_timeout(wpa_s->parent, NULL);
+#endif
        }
 }