隐藏网络
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进行比较