Android5.0系统wifip2p默认ssid和密码

logcat -s WifiEnabler Wifimultisupport WifiPowerSetting WifiStateMachine wpa_supplicant ConnectivityService NetworkSettingsActivity WifiController WifiHW CommandListener WifiP2pService wifi  wpa_supplicant WifiMonitor SupplicantStateTracker WifiP2pSettings WifiMonitor WifiNative-HAL

一、问题描述

无法通过配置文件修改默认的p2p的ssid和password。

二、问题原因

1.文件权限问题

Android系统wifi之p2p(wifi直连)配置文件权限导致应用不能使用wifi问题

2.设置密码命令执行错误问题

D/WifiP2pService( 2046): ---Mod Group info, pw: "eeeeeeee"
D/wifi    ( 2046): TK--------->>>>>>>JNI>>>>doBooleanCommand>>11111
D/WifiHW  ( 2046): TK--------->>>>command is SET_NETWORK 0 psk "eeeeeeee",reply is     ,reply_len is 4095 D/WifiHW  ( 2046): TK-------->>>wifi_send_command,ctrl_conn is   I/wpa_supplicant( 4841): [CTRL_IFACE_G]SET_NETWORK 0 psk "eeeeeeee"
D/wifi    ( 2046): TK--------->>>>>>>JNI>>>>doBooleanCommand>>33333>>>reply is UNKNOWN COMMAND
D/WifiP2pService( 2046): ---set pw error
原因;wps不识别“SET_NETWORK 0 psk "eeeeeeee"”命令。

修改如下:

frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java

    public WifiNative(String interfaceName) {
        mInterfaceName = interfaceName;
        mTAG = "WifiNative";// + interfaceName; tank
        //if (!interfaceName.equals("p2p0")) {
            mInterfacePrefix = "IFNAME=" + interfaceName + " ";
        //} else {
            // commands for p2p0 interface don't need prefix
            //mInterfacePrefix = "";
        //} //tank
    }
结果:
D/WifiHW  ( 2055): TK--------->>>>command is IFNAME=p2p0 SET_NETWORK 0 psk "dddddddd",reply is ,reply_len is 4095
D/WifiHW  ( 2055): TK-------->>>wifi_send_command,ctrl_conn is �
I/wpa_supplicant( 4846): [CTRL_IFACE]p2p0: SET_NETWORK 0 psk "dddddddd"
D/wifi    ( 2055): TK--------->>>>>>>JNI>>>>doBooleanCommand>>33333>>>reply is OK
......
D/WifiHW  ( 2055): TK--------->>>>command is IFNAME=p2p0 P2P_GROUP_ADD persistent=1,reply is OK,reply_len is 4095
D/WifiHW  ( 2055): TK-------->>>wifi_send_command,ctrl_conn is �
I/wpa_supplicant( 4846): [CTRL_IFACE]p2p0: P2P_GROUP_ADD persistent=1
D/wifi    ( 2055): TK--------->>>>>>>JNI>>>>doBooleanCommand>>33333>>>reply is OK
其实没有设置成功。

3.修改“IFNAME=p2p0 P2P_GROUP_ADD persistent=1”为“IFNAME=p2p0 P2P_GROUP_ADD persistent=0”

frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java

    public boolean p2pGroupAdd(boolean persistent) {
        //modify by tank  always add persistent 0 fixed 0 may cause cts verifiver p2p group owner fail 
        /*if (persistent) {
            return doBooleanCommand("P2P_GROUP_ADD persistent");
        }
        return doBooleanCommand("P2P_GROUP_ADD");*/
        return doBooleanCommand("P2P_GROUP_ADD" + " persistent=0");//mod by HQS
        //end tank
    }

    public boolean p2pGroupAdd(int netId) {
        //modify by tank  always add persistent 0 fixed 0 may cause cts verifiver p2p group owner fail
        //return doBooleanCommand("P2P_GROUP_ADD persistent=" + netId);
        return doBooleanCommand("P2P_GROUP_ADD" + " persistent=0");//mod by HQS
        //end tank
    }
结果:可以立即设置成功。
D/WifiHW  ( 2026): TK--------->>>>command is IFNAME=p2p0 P2P_GROUP_ADD persistent=0,reply is ��K�L�pIN�,reply_len is 4095
D/WifiHW  ( 2026): TK-------->>>wifi_send_command,ctrl_conn is �
I/wpa_supplicant( 4657): [CTRL_IFACE]p2p0: P2P_GROUP_ADD persistent=0
D/wifi    ( 2026): TK--------->>>>>>>JNI>>>>doBooleanCommand>>33333>>>reply is OK
E/wpa_supplicant( 4657): Using interface p2p0 with hwaddr 7e:b2:32:24:9d:da and ssid "TANK_p2p"
三、p2p默认配置文件

system/etc/wifi/p2p_supplicant.conf

ctrl_interface=/data/system/wpa_supplicant
update_config=1
device_type=10-0050F204-5
config_methods=virtual_push_button physical_display keypad
p2p_listen_reg_class=81
p2p_listen_channel=11
p2p_oper_reg_class=81
p2p_oper_channel=11
p2p_go_intent=0
persistent_reconnect=1


network={
        ssid="TANK_p2p"
        psk="123456789"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP
        auth_alg=OPEN
        mode=3
        disabled=2
}


你可能感兴趣的:(移动操作系统之Android)