开启wifi错误

 最近遇到一个wifi问题,同一个手机,由eng版本升级到user版本后,去打开wifi,wifi一直处于正在打开状态,打开不了。打印log显示以下错误:

E/WifiStateMachine(  452): Failed to start supplicant!
D/StateMachine(  452): handleMessage: X
D/StateMachine(  452): handleMessage: E msg.what=131073
D/StateMachine(  452): processMsg: DriverLoadedState
D/WifiStateMachine(  452): DriverLoadedState{ what=131073 when=-10s843ms arg1=2 }
D/StateMachine(  452): processMsg: DefaultState
D/WifiStateMachine(  452): DefaultState{ what=131073 when=-10s843ms arg1=2 }
D/StateMachine(  452): handleMessage: X
D/StateMachine(  452): handleMessage: E msg.what=131083
D/StateMachine(  452): processMsg: DriverLoadedState
D/WifiStateMachine(  452): DriverLoadedState{ what=131083 when=-10s843ms }
E/        (  452): fopen failed: /dev/cpuctl/ux/tasks, Permission denied
I/ActivityThread( 1572): Pub com.google.android.music.athome: com.google.android.music.athome.AtHomeContentProvider
I/ActivityThread( 1572): Pub com.google.android.music.MusicContent: com.google.android.music.store.MusicContentProvider
I/MusicStore( 1572): Database version: 44
W/CommandListener(  128): Failed to retrieve HW addr for wlan0 (No such device)
E/WifiStateMachine(  452): Unable to change interface settings: java.lang.IllegalStateException: command '10 interface setcfg wlan0 0.0.0.0 0 down' failed with '400 10 Failed to set address (No such device)'
D/wpa_supplicant( 1611): wpa_supplicant v2.0-devel-4.1.2
D/wpa_supplicant( 1611): Add randomness: count=1 entropy=0


看到W/CommandListener(  128): Failed to retrieve HW addr for wlan0 (No such device)
错误,以为是没写地址导致的,去about phone查看wifi地址,果然是不可用的,但是用QXDM读wifi地址(NV项为4678项),地址是有的,也就是说引起wifi开启不了的原因还是因为Failed to start supplicant!,导致读取地址也是失败的。

start pupplicant是由WifiStateMachine直接调用wifinative的startSupplicant方法来处理的,最后调到wifi,c的wifi_start_supplicant

int wifi_start_supplicant(int p2p_supported)
{
    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
    int count = 200; /* wait at most 20 seconds for completion */
#ifdef HAVE_LIBC_SYSTEM_PROPERTIES
    const prop_info *pi;
    unsigned serial = 0, i;
    char supp_rdy_status[PROPERTY_VALUE_MAX] = "";
    const prop_info *rdy_pi = NULL;
    int rdy_loop_count = 0;
#endif

    if (p2p_supported) {
        strcpy(supplicant_name, P2P_SUPPLICANT_NAME);
        strcpy(supplicant_prop_name, P2P_PROP_NAME);

        /* Ensure p2p config file is created */
        if (ensure_config_file_exists(P2P_CONFIG_FILE) < 0) {
            ALOGE("Failed to create a p2p config file");
            return -1;
        }

    } else {
        strcpy(supplicant_name, SUPPLICANT_NAME);
        strcpy(supplicant_prop_name, SUPP_PROP_NAME);
    }

    /* Check whether already running */
    if (property_get(supplicant_name, supp_status, NULL)
            && strcmp(supp_status, "running") == 0) {
        return 0;
    }

    /* Before starting the daemon, make sure its config file exists */
    if (ensure_config_file_exists(SUPP_CONFIG_FILE) < 0) {
        ALOGE("Wi-Fi will not be enabled");
        return -1;
    }

    if (ensure_entropy_file_exists() < 0) {
        ALOGE("Wi-Fi entropy file was not created");
    }

    /* Clear out any stale socket files that might be left over. */
    wifi_wpa_ctrl_cleanup();

    /* Reset sockets used for exiting from hung state */
    for (i=0; i running => stopped (i.e.,
     * it start up, but fails right away) from the case in which
     * it starts in the stopped state and never manages to start
     * running at all.
     */
    pi = __system_property_find(supplicant_prop_name);
    if (pi != NULL) {
        serial = pi->serial;
    }
#endif
    property_get("wifi.interface", primary_iface, WIFI_TEST_INTERFACE);

    property_set("ctl.start", supplicant_name);
    sched_yield();

    while (count-- > 0) {
#ifdef HAVE_LIBC_SYSTEM_PROPERTIES
        if (pi == NULL) {
            pi = __system_property_find(supplicant_prop_name);
        }
        if (pi != NULL) {
            __system_property_read(pi, NULL, supp_status);
            if (strcmp(supp_status, "running") == 0) {
                for (rdy_loop_count = 0; rdy_loop_count < 15000/RDY_WAIT_MS;
                                rdy_loop_count ++) {
                    if (rdy_pi == NULL) {
                        rdy_pi = __system_property_find(SUPP_RDY_PROP_NAME);
                    } else {
                           __system_property_read(rdy_pi, NULL, supp_rdy_status);
                           if (strcmp(supp_rdy_status, "1") == 0)
                           {
                               return 0;
                           }
                      }
                    usleep (RDY_WAIT_MS * 1000);
                }
                return -1;
            } else if (pi->serial != serial &&
                    strcmp(supp_status, "stopped") == 0) {
                  return -1;
              }
        }
#else
        if (property_get(supplicant_prop_name, supp_status, NULL)) {
            if (strcmp(supp_status, "running") == 0)
                return 0;
        }
#endif
        usleep(100000);
    }
    return -1;
}


查看开不了wifi的手机,各种配置文件均正常。再往下分析好像也没有什么问题。

查看下一个错误信息:W/CommandListener(  128): Failed to retrieve HW addr for wlan0 (No such device)
网上搜索了下这个错误,竟然还是很多人遇到这样的错误,有人建议

Check that you have the modules in /system/lib/module,说是这个文件下面多了两个驱动文件,删除就可以了,但是查看问题手机和正常手机的modules下面的文件是一样的。更多的版本是

1:在刷rom之前刷boot.img
2:wipe
3:刷rom

问题手机是升级了软件版本开不了的,按照上面这个所说,想到了先下载了一个能开启的版本,然后一步步升级软件版本,先写了boot.img,然后是system.img,userdata.img,这几个每次写完都看一下wifi是否能打开,结果这三个都是正常的。接下来写了persist.img,这个写进去后,wifi开不了了。找到了是有这个persist,img引起的。之前调wifi参数时,曾经修改过手机里persist/bdata.bin这个文件。然后看了下问题手机里persist这个目录下面没有bdata.bin这个文件,push进去一个bdata.bin,wifi就能正常开启,问题解决。

同一套代码,编译成eng版本,wifi是正常,编译成user版本,persist目录下就没有了bdata.bin这个文件。查看makefile等信息,都没有对版本编译做限制的条件编译,这个问题不知道是什么原因。

 

你可能感兴趣的:(Wi-Fi)