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;
}
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();
}
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;
}
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;
}
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;
}
Aggregations