Android Auto-connect WiFi priority rule and view password for connected WiFi

Source: Internet
Author: User

The priority rules for the current Android WiFi auto-connect are as follows:

1, the priority value of the range is set to [0,1000000], if beyond this range will reset;

2, the most recently connected AP has the highest priority, in the automatic connection will first try to connect it;
3, not connected but scan to the AP, according to its signal value of the strength of the order, the stronger the display of the front, but, still have to synthesize
Security factors for APS, the basic situation is: WPA/WPA2 > WEP > Signal Level High > signal level low > Noise low > Noise
High

4. If the AP is preset, it may set its highest priority.

Check the source code path: frameworks/base/wifi/java/android/net/wifi/


Wificonfigstore.java

 Boolean selectnetwork (int netId) {if (vdbg) locallog ("Selectnetwork", netId);        if (netId = = invalid_network_id) return false;        Reset the priority of each network at start or if it is goes too high. if (mlastpriority = =-1 | | mlastpriority > 1000000) {xlog.d (TAG, "need to reset", mlastpriority            : "+ mlastpriority); For (Wificonfiguration config:mConfiguredNetworks.values ()) {if (Config.networkid! = invalid_network_id)                    {config.priority = 0;                addorupdatenetworknative (config);        }} mlastpriority = 0;        }//Set to the highest and save the configuration.        wificonfiguration config = new wificonfiguration ();        Config.networkid = netId;        config.priority = ++mlastpriority;        addorupdatenetworknative (config);        Mwifinative.saveconfig (); /* Enable the given network while disabling all other Networks */Enablenetworkwithoutbroadcast (netId, true); /* Avoid Saving the config & sending a broadcast to prevent settings * from displaying a disabled list of Netwo    Rks */return true; }

Sometimes, we forget the password that has been connected to the WiFi, the application market also has the relevant application can help us to read. In fact, if you have root privileges, you can view it with the re file manager (Root Explorer). File path:

/data/misc/wifi/sockets/wpa_supplicant.conf

Each network package is a connected Wi-Fi hotspot, where the SSID is the name, PSK is the password, also you can see additional information, including encryption type KEY_MGMT and priority priorities, whether to automatically connect Autojoin, and so on, such as:



Reprint Please specify source: Zhou Mushi's csdn blog Http://blog.csdn.net/zhoumushui

My github: Zhou Mushi's GitHub Https://github.com/zhoumushui


Android Auto-connect WiFi priority rule and view password for connected WiFi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.