onCreate 後就啟動了...WifiP2pManager.initialize( )
framework/base/services/java/com/android/server/display/DisplayManagerService.java: DEBUG=true;
framework/base/services/java/com/android/server/display/WifiDisplayAdapter.java: DEBUG=true;
framework/base/services/java/com/android/server/display/WifiDisplayController.java: DEBUG=true
真正connect 的流程就在 WifiDisplayController.java: updateConnection()
大概就是..先 disconnect from the old one.
然後再call WifiP2pManager.connect( )
連線完成 call WifiP2pManager.setMiracastMode( )
然後叫 RemoteDispkay.listen( ) 這個 P2p connection...
有點跑掉...
framework/base/java/android/net/wifi/WifiNative.java: DBG=true;
doCommand : wifi_command
libhardware_legacy
wpa_ctrl_request( ) : TAG WifiHW
在 wpa_supplicant_8
是在 wpa_supplicant_8/wpa_supplicant/Android.mk
src/common/wpa_ctrl.c
有兩個 implement, depend on CTRL_IFACE_SOCKET 或是 CONFIG_CTRL_IFACE_NAMED_PIPE
因為 IFACE_UNIX, 所以是 IFACE_SOCKET
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)) ..wpa_ctrl structure 包含一個 socket.是 溝通的界面。
在 libhardware_legacy/wifi/wifi.c (wpa_supplicant 使用者) 中 是先呼叫:
wifi_connect_on_socket_path(const char *path) { ctrl_conn = wpa_ctrl_open(path);取得 connect socket
caller 是..
/* Establishes the control and monitor socket connections on the interface */ int wifi_connect_to_supplicant() { static char path[PATH_MAX]; if (access(IFACE_DIR, F_OK) == 0) { snprintf(path, sizeof(path), "%s/%s", IFACE_DIR, primary_iface); } else { snprintf(path, sizeof(path), "@android:wpa_%s", primary_iface); } return wifi_connect_on_socket_path(path); }其中..
static const char IFACE_DIR[] = "/data/system/wpa_supplicant"; property_get("wifi.interface",primary_iface,..);wifi.interface 定義在 system.prop : wlan0
完成後,用 android 的 system control:
property_set("ctl.start", supplicant_name);啟動 wpa_supplicant service.
根據 P2P 有沒有啟動, ctrl.start 的 service 不一樣:
static const char SUPPLICANT_NAME[] = "wpa_supplicant"; static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant"; static const char P2P_SUPPLICANT_NAME[] = "p2p_supplicant"; static const char P2P_PROP_NAME[] = "init.svc.p2p_supplicant";
找一下 libwpa_client..
其中只有:
- src/common/wpa_ctrl.c
- src/utils/os_unix.c
在 Android.mk:
include $(CLEAR_VARS) LOCAL_MODULE = libwpa_client LOCAL_CFLAGS = $(L_CFLAGS) LOCAL_SRC_FILES = src/common/wpa_ctrl.c src/utils/os_$(CONFIG_OS).c LOCAL_C_INCLUDES = $(INCLUDES) LOCAL_SHARED_LIBRARIES := libcutils liblog LOCAL_COPY_HEADERS_TO := libwpa_client LOCAL_COPY_HEADERS := src/common/wpa_ctrl.h include $(BUILD_SHARED_LIBRARY)所以會把 wpa_ctrl.h copy 到 out folder 的 include/libwpa_client/ 下面。
所以有使用到的 project...
./frameworks/base/core/jni/Android.mk: libwpa_client \ ./hardware/libhardware_legacy/wifi/Android.mk:LOCAL_SHARED_LIBRARIES += libnetutils libwpa_client就 include "libwpa_client/wpa_ctrl.h"
framework/.../jni call 到 libhardware_legacy 的 wificommand.
沒有直接 call libwpa_client 的 api
所以所有call libwpa_client 的應該都是經過 libhardware_legacy
沒有留言:
張貼留言