OSDN Git Service

wifi: Link libwpa_client only if wpa_supplicant was chosen
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 22 Nov 2013 23:54:27 +0000 (15:54 -0800)
committerYing Wang <wangying@google.com>
Thu, 5 Dec 2013 18:49:21 +0000 (10:49 -0800)
Change-Id: Ic487c3767a17299880e83080b79a91dbbaef1234
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Android.mk
wifi/Android.mk
wifi/wifi.c

index 1050811..0a82a1f 100644 (file)
@@ -9,7 +9,7 @@ LEGACY_AUDIO_MAKEFILES := $(call all-named-subdir-makefiles,audio)
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SHARED_LIBRARIES := libcutils liblog libwpa_client
+LOCAL_SHARED_LIBRARIES := libcutils liblog
 
 LOCAL_INCLUDES += $(LOCAL_PATH)
 
index cde99d7..99a4b0e 100644 (file)
@@ -27,4 +27,8 @@ endif
 
 LOCAL_SRC_FILES += wifi/wifi.c
 
+ifdef WPA_SUPPLICANT_VERSION
+LOCAL_CFLAGS += -DLIBWPA_CLIENT_EXISTS
+LOCAL_SHARED_LIBRARIES += libwpa_client
+endif
 LOCAL_SHARED_LIBRARIES += libnetutils
index ff9357b..7e72ac7 100644 (file)
@@ -24,7 +24,9 @@
 #include <poll.h>
 
 #include "hardware_legacy/wifi.h"
+#ifdef LIBWPA_CLIENT_EXISTS
 #include "libwpa_client/wpa_ctrl.h"
+#endif
 
 #define LOG_TAG "WifiHW"
 #include "cutils/log.h"
 #include <sys/_system_properties.h>
 #endif
 
-static struct wpa_ctrl *ctrl_conn;
-static struct wpa_ctrl *monitor_conn;
-
-/* socket pair used to exit from a blocking read */
-static int exit_sockets[2];
-
 extern int do_dhcp();
 extern int ifc_init();
 extern void ifc_close();
@@ -52,6 +48,28 @@ extern int init_module(void *, unsigned long, const char *);
 extern int delete_module(const char *, unsigned int);
 void wifi_close_sockets();
 
+#ifndef LIBWPA_CLIENT_EXISTS
+#define WPA_EVENT_TERMINATING "CTRL-EVENT-TERMINATING "
+struct wpa_ctrl {};
+void wpa_ctrl_cleanup(void) {}
+struct wpa_ctrl *wpa_ctrl_open(const char *ctrl_path) { return NULL; }
+void wpa_ctrl_close(struct wpa_ctrl *ctrl) {}
+int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
+       char *reply, size_t *reply_len, void (*msg_cb)(char *msg, size_t len))
+       { return 0; }
+int wpa_ctrl_attach(struct wpa_ctrl *ctrl) { return 0; }
+int wpa_ctrl_detach(struct wpa_ctrl *ctrl) { return 0; }
+int wpa_ctrl_recv(struct wpa_ctrl *ctrl, char *reply, size_t *reply_len)
+       { return 0; }
+int wpa_ctrl_get_fd(struct wpa_ctrl *ctrl) { return 0; }
+#endif
+
+static struct wpa_ctrl *ctrl_conn;
+static struct wpa_ctrl *monitor_conn;
+
+/* socket pair used to exit from a blocking read */
+static int exit_sockets[2];
+
 static char primary_iface[PROPERTY_VALUE_MAX];
 // TODO: use new ANDROID_SOCKET mechanism, once support for multiple
 // sockets is in