这个平台的wifip2p也就是wifi Direct(wifi直连)其实是走的hostap功能。
一、问题描述
1.设置-》网络-》无线网络-》,打开wifi开关。
2.在开启无线直连,修改密码以后。
3.不用进入“无线互联”应用,就会出现描述现象;另外,步骤2中如果不修改密码、则不出现"设置-》网络-》无线网络,wifi开关无效"。
4.这种情况出现以后“设置-》网络-》无线网络,wifi开关无效”。
其实为wifip2p设置密码以后Settings应用死掉;后边第一次打开时还可以操作“wifi开关”、但timeout ,再之后“wifi开关无效”。
二、问题分析
echo 0 0 0 0 > /proc/sys/kernel/printk logcat -s WifiEnabler Wifimultisupport WifiPowerSetting WifiStateMachine wpa_supplicant ConnectivityService NetworkSettingsActivity WifiController WifiHW CommandListener WifiP2pService wifi wpa_supplicant WifiMonitor SupplicantStateTracker WifiP2pSettings WifiMonitor WifiNative-HAL
关键log
D/WifiP2pSettings( 4253): btn2.setOnClickListener D/WifiP2pService( 2010): ---Mod Group info, pw: "qqqqqqqq" I/wpa_supplicant(26602): [CTRL_IFACE_G]SET_NETWORK 0 psk "qqqqqqqq" D/WifiP2pService( 2010): ---set pw error D/WifiP2pService( 2010): ---saveConfig E/wifi ( 2010): Open file /data/misc/wifi/p2p_supplicant.conf : ...... D/WifiHW ( 2010): enter func wifi_start_supplicant p2p_supported = 1 E/WifiHW ( 2010): /data/misc/wifi/p2p_supplicant.conf is all right E/WifiHW ( 2010): /data/misc/wifi/wpa_supplicant.conf is all right I/wpa_supplicant(31183): wpa_supplicant v2.0-devel-4.4.2_rtw_r10999.20140528_debugmsg I/wpa_supplicant(31183): define REALTEK_WIFI_VENDOR I/wpa_supplicant(31183): supp-global-ctrl-iface-init(/data/system/wpa_supplicant/wlan0) (will try fixup): bind(PF_UNIX): Address already in u se I/wpa_supplicant(31183): Successfully initialized wpa_supplicant E/wpa_supplicant(31183): Failed to open config file '/data/misc/wifi/p2p_supplicant.conf', error: Permission denied E/wpa_supplicant(31183): Failed to read or parse configuration '/data/misc/wifi/p2p_supplicant.conf'. E/WifiStateMachine( 2010): Failed to start supplicant! shell@coconut:/data/misc/wifi # ll -rw-rw---- system wifi 21 2015-03-30 13:46 entropy.bin srwxrwx--- wifi wifi 2015-03-30 13:34 p2p0 -rw------- system system 473 2015-03-30 13:38 p2p_supplicant.conf drwxrwx--- wifi wifi 2015-03-30 13:39 sockets -rw------- system system 33 2007-01-01 20:01 softap.conf drwxrwx--- wifi wifi 2007-01-01 20:00 wpa_supplicant -rw-rw---- system wifi 315 2015-03-30 13:16 wpa_supplicant.conf
三、问题解决
修改/data/misc/wifi/p2p_supplicant.conf创建时权限
hardware/libhardware_legacy/wifi/wifi.c
int ensure_config_file_exists(const char *config_file) { int ret = 0; if (is_config_p2p(config_file)) { ret = ensure_config_file(config_file, P2P_CONFIG_TEMPLATE); } else { ret = ensure_config_file(config_file, SUPP_CONFIG_TEMPLATE); } //add by tank always make sure config_file has access right. begin /* chmod is needed because open() didn't set permisions properly */ if (chmod(config_file, 0660) < 0) { ALOGE("Error changing permissions of %s to 0660: %s", config_file, strerror(errno)); unlink(config_file); //return -1; } if (chown(config_file, AID_SYSTEM, AID_WIFI) < 0) { ALOGE("Error changing group ownership of %s to %d: %s", config_file, AID_WIFI, strerror(errno)); unlink(config_file); //return -1; } return ret; //end tank always make sure config_file has access right. end }
补充:
wifip2p的默认SSID等参数设置
system/etc/wifi/p2p_supplicant.conf
三、问题扩展wifip2p与Miracast(Wifi Display)