Andriod WIFI 隐藏SSID

隐藏网络
if (mScanningForHiddenNetworksEnabled) {
// retrieve the list of hidden network SSIDs to scan for, if enabled.
List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworkList =
mWifiConfigManager.retrieveHiddenNetworkList();
settings.hiddenNetworks = hiddenNetworkList.toArray(
new WifiScanner.ScanSettings.HiddenNetwork[hiddenNetworkList.size()]);
}

wifi启动的时候会调用enableScanningForHiddenNetworks将扫描隐藏网络的开关打开
/**
* Retrieves a list of all the saved hidden networks for scans.
*
* Hidden network list sent to the firmware has limited size. If there are a lot of saved
* networks, this list will be truncated and we might end up not sending the networks
* with the highest chance of connecting to the firmware.
* So, re-sort the network list based on the frequency of connection to those networks
* and whether it was last seen in the scan results.
*
* @return list of networks in the order of priority.
*/
public List<WifiScanner.ScanSettings.HiddenNetwork> retrieveHiddenNetworkList() {
List<WifiScanner.ScanSettings.HiddenNetwork> hiddenList = new ArrayList<>();
List networks = new ArrayList<>(getInternalConfiguredNetworks());
// Remove any permanently disabled networks or non hidden networks.
Iterator iter = networks.iterator();
while (iter.hasNext()) {
WifiConfiguration config = iter.next();
if (!config.hiddenSSID) {
iter.remove();
}
}
Collections.sort(networks, sScanListComparator);
// The most frequently connected network has the highest priority now.
for (WifiConfiguration config : networks) {
hiddenList.add(
new WifiScanner.ScanSettings.HiddenNetwork(config.SSID));
}
return hiddenList;
}

/**
 * General sorting algorithm of all networks for scanning purposes:
 * Place the configurations in descending order of their |numAssociation| values. If networks
 * have the same |numAssociation|, place the configurations with
 * |lastSeenInQualifiedNetworkSelection| set first.
 */
private static final WifiConfigurationUtil.WifiConfigurationComparator sScanListComparator =
        new WifiConfigurationUtil.WifiConfigurationComparator() {
            @Override
            public int compareNetworksWithSameStatus(WifiConfiguration a, WifiConfiguration b) {
                if (a.numAssociation != b.numAssociation) {
                    return Long.compare(b.numAssociation, a.numAssociation);
                } else {
                    boolean isConfigALastSeen =
                            a.getNetworkSelectionStatus()
                                    .getSeenInLastQualifiedNetworkSelection();
                    boolean isConfigBLastSeen =
                            b.getNetworkSelectionStatus()
                                    .getSeenInLastQualifiedNetworkSelection();
                    return Boolean.compare(isConfigBLastSeen, isConfigALastSeen);
                }
            }
        };

从这边看到隐藏网络扫描是有限制的,会优先以关联的次数进行比较,若相同,则以lastSeenInQualifiedNetworkSelection进行比较

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kaira88

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值