Search in sources :

Example 1 with WifiNetworkSuggestion

use of android.net.wifi.WifiNetworkSuggestion in project android_packages_apps_Settings by omnirom.

the class AddAppNetworksFragment method filterSavedNetworks.

/**
 * For the APP specified networks, filter saved ones and mark those saved as existed. And
 * prepare a new UiConfigurationItem list, which contains those new or need to be updated
 * networks, for creating UI to user.
 */
@VisibleForTesting
void filterSavedNetworks(List<WifiConfiguration> savedWifiConfigurations) {
    if (mUiToRequestedList == null) {
        mUiToRequestedList = new ArrayList<>();
    } else {
        mUiToRequestedList.clear();
    }
    int networkPositionInBundle = 0;
    for (WifiNetworkSuggestion suggestion : mAllSpecifiedNetworksList) {
        String displayedName = null;
        boolean foundInSavedList = false;
        /*
             * If specified is passpoint network, need to check with the existing passpoint
             * networks.
             */
        final PasspointConfiguration passpointConfig = suggestion.getPasspointConfig();
        if (passpointConfig != null) {
            foundInSavedList = isSavedPasspointConfiguration(passpointConfig);
            displayedName = passpointConfig.getHomeSp().getFriendlyName();
        } else {
            final WifiConfiguration specifiedConfig = suggestion.getWifiConfiguration();
            displayedName = removeDoubleQuotes(specifiedConfig.SSID);
            foundInSavedList = isSavedWifiConfiguration(specifiedConfig, savedWifiConfigurations);
        }
        if (foundInSavedList) {
            // If this requested network already in the saved networks, mark this item in the
            // result code list as existed.
            mResultCodeArrayList.set(networkPositionInBundle, RESULT_NETWORK_ALREADY_EXISTS);
        } else {
            // Prepare to add to UI list to show to user
            UiConfigurationItem uiConfigurationItem = new UiConfigurationItem(displayedName, suggestion, networkPositionInBundle, INITIAL_RSSI_SIGNAL_LEVEL);
            mUiToRequestedList.add(uiConfigurationItem);
        }
        networkPositionInBundle++;
    }
}
Also used : WifiNetworkSuggestion(android.net.wifi.WifiNetworkSuggestion) PasspointConfiguration(android.net.wifi.hotspot2.PasspointConfiguration) WifiConfiguration(android.net.wifi.WifiConfiguration) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Aggregations

WifiConfiguration (android.net.wifi.WifiConfiguration)1 WifiNetworkSuggestion (android.net.wifi.WifiNetworkSuggestion)1 PasspointConfiguration (android.net.wifi.hotspot2.PasspointConfiguration)1 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)1