admin管理员组

文章数量:1540702

目前Android的WiFi自动连接的优先级规则如下:

1、priority值的范围设定为[0,1000000),如果超出此范围则会reset;

2、最近连接过的AP拥有最高priority,在自动连接中会首先尝试连接它;

3、未连接过但是扫描到的AP,按其信号值强弱排序,越强的显示靠前,但是,还得综合

AP的安全因素,基本情况是:WPA/WPA2 > WEP > signal level high > signal level low > noise low > noise

high

4、如果是预置的AP,可能会人为设定其最高的priority;

看一下源码,代码路径: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 goes too high.

if (mLastPriority == -1 || mLastPriority > 1000000) {

Xlog.d(TAG, "Need to reset the priority, mLastPriority:" + mLastPriority);

for(WifiConfiguration config : mConfiguredNetworks.values()

本文标签: 优先级规则密码wifiandroid