Search in sources :

Example 21 with WifiConfiguration

use of android.net.wifi.WifiConfiguration in project routerkeygenAndroid by routerkeygen.

the class Wifi method shiftPriorityAndSave.

private static int shiftPriorityAndSave(final WifiManager wifiMgr) {
    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    sortByPriority(configurations);
    final int size = configurations.size();
    for (int i = 0; i < size; i++) {
        final WifiConfiguration config = configurations.get(i);
        config.priority = i;
        wifiMgr.updateNetwork(config);
    }
    wifiMgr.saveConfiguration();
    return size;
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 22 with WifiConfiguration

use of android.net.wifi.WifiConfiguration in project routerkeygenAndroid by routerkeygen.

the class Wifi method checkForExcessOpenNetworkAndSave.

/**
     * Ensure no more than numOpenNetworksKept open networks in configuration list.
     *
     * @param wifiMgr
     * @param numOpenNetworksKept
     * @return Operation succeed or not.
     */
private static boolean checkForExcessOpenNetworkAndSave(final WifiManager wifiMgr, final int numOpenNetworksKept) {
    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    sortByPriority(configurations);
    boolean modified = false;
    int tempCount = 0;
    for (int i = configurations.size() - 1; i >= 0; i--) {
        final WifiConfiguration config = configurations.get(i);
        if (ConfigSec.isOpenNetwork(ConfigSec.getWifiConfigurationSecurity(config))) {
            tempCount++;
            if (tempCount >= numOpenNetworksKept) {
                modified = true;
                wifiMgr.removeNetwork(config.networkId);
            }
        }
    }
    return !modified || wifiMgr.saveConfiguration();
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 23 with WifiConfiguration

use of android.net.wifi.WifiConfiguration in project routerkeygenAndroid by routerkeygen.

the class Wifi method getWifiConfiguration.

private static WifiConfiguration getWifiConfiguration(final WifiManager wifiMgr, final ScanResult hotspot, String hotspotSecurity) {
    final String ssid = convertToQuotedString(hotspot.SSID);
    if (ssid.length() == 0) {
        return null;
    }
    final String bssid = hotspot.BSSID;
    if (bssid == null) {
        return null;
    }
    if (hotspotSecurity == null) {
        hotspotSecurity = ConfigSec.getScanResultSecurity(hotspot);
    }
    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    if (configurations == null) {
        return null;
    }
    for (final WifiConfiguration config : configurations) {
        if (config.SSID == null || !ssid.equals(config.SSID)) {
            continue;
        }
        if (config.BSSID == null || bssid.equals(config.BSSID)) {
            final String configSecurity = ConfigSec.getWifiConfigurationSecurity(config);
            if (hotspotSecurity.equals(configSecurity)) {
                return config;
            }
        }
    }
    return null;
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 24 with WifiConfiguration

use of android.net.wifi.WifiConfiguration in project platform_frameworks_base by android.

the class WifiConfigurationHelper method createGenericConfig.

/**
     * Create a generic {@link WifiConfiguration} used by the other create methods.
     */
private static WifiConfiguration createGenericConfig(String ssid) {
    WifiConfiguration config = new WifiConfiguration();
    config.SSID = quotedString(ssid);
    config.setIpAssignment(IpAssignment.DHCP);
    config.setProxySettings(ProxySettings.NONE);
    return config;
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 25 with WifiConfiguration

use of android.net.wifi.WifiConfiguration in project platform_frameworks_base by android.

the class WifiConfigurationHelper method createWepConfig.

/**
     * Create a {@link WifiConfiguration} for a WEP secured network
     *
     * @param ssid The SSID of the wifi network
     * @param password Either a 10, 26, or 58 character hex string or the plain text password
     * @return The {@link WifiConfiguration}
     */
public static WifiConfiguration createWepConfig(String ssid, String password) {
    WifiConfiguration config = createGenericConfig(ssid);
    if (isHex(password, 10) || isHex(password, 26) || isHex(password, 58)) {
        config.wepKeys[0] = password;
    } else {
        config.wepKeys[0] = quotedString(password);
    }
    config.allowedKeyManagement.set(KeyMgmt.NONE);
    config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
    config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
    return config;
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Aggregations

WifiConfiguration (android.net.wifi.WifiConfiguration)316 WifiManager (android.net.wifi.WifiManager)54 LargeTest (android.test.suitebuilder.annotation.LargeTest)53 IOException (java.io.IOException)44 ArrayList (java.util.ArrayList)38 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)32 ScanResult (android.net.wifi.ScanResult)27 Credential (com.android.hotspot2.pps.Credential)20 Scanner (com.android.settingslib.wifi.WifiTracker.Scanner)20 WifiInfo (android.net.wifi.WifiInfo)16 Bundle (android.os.Bundle)12 NetworkPolicy (android.net.NetworkPolicy)10 SpannableString (android.text.SpannableString)10 EAP (com.android.anqp.eap.EAP)10 X509Certificate (java.security.cert.X509Certificate)10 StaticIpConfiguration (android.net.StaticIpConfiguration)7 PackageManager (android.content.pm.PackageManager)6 NetworkInfo (android.net.NetworkInfo)6 PowerManager (android.os.PowerManager)6 RemoteException (android.os.RemoteException)6