use of android.net.wifi.WifiConfiguration in project robolectric by robolectric.
the class ShadowWifiManagerTest method updateNetwork_shouldReplaceNetworks.
@Test
public void updateNetwork_shouldReplaceNetworks() throws Exception {
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.networkId = -1;
wifiManager.addNetwork(wifiConfiguration);
WifiConfiguration anotherConfig = new WifiConfiguration();
int networkId = wifiManager.addNetwork(anotherConfig);
assertThat(networkId).isEqualTo(1);
WifiConfiguration configuration = new WifiConfiguration();
configuration.networkId = networkId;
configuration.priority = 44;
assertThat(wifiManager.updateNetwork(configuration)).isEqualTo(networkId);
List<WifiConfiguration> configuredNetworks = wifiManager.getConfiguredNetworks();
assertThat(configuredNetworks.size()).isEqualTo(2);
assertThat(configuration.priority).isEqualTo(44);
assertThat(configuredNetworks.get(1).priority).isEqualTo(44);
}
use of android.net.wifi.WifiConfiguration in project robolectric by robolectric.
the class ShadowWifiConfiguration method copy.
public WifiConfiguration copy() {
WifiConfiguration config = new WifiConfiguration();
config.networkId = realObject.networkId;
config.SSID = realObject.SSID;
config.BSSID = realObject.BSSID;
config.preSharedKey = realObject.preSharedKey;
config.wepTxKeyIndex = realObject.wepTxKeyIndex;
config.status = realObject.status;
config.priority = realObject.priority;
config.hiddenSSID = realObject.hiddenSSID;
config.allowedKeyManagement = (BitSet) realObject.allowedKeyManagement.clone();
config.allowedProtocols = (BitSet) realObject.allowedProtocols.clone();
config.allowedAuthAlgorithms = (BitSet) realObject.allowedAuthAlgorithms.clone();
config.allowedPairwiseCiphers = (BitSet) realObject.allowedPairwiseCiphers.clone();
config.allowedGroupCiphers = (BitSet) realObject.allowedGroupCiphers.clone();
config.wepKeys = new String[4];
System.arraycopy(realObject.wepKeys, 0, config.wepKeys, 0, config.wepKeys.length);
return config;
}
use of android.net.wifi.WifiConfiguration in project robolectric by robolectric.
the class ShadowWifiManager method makeCopy.
private WifiConfiguration makeCopy(WifiConfiguration config, int networkId) {
WifiConfiguration copy = Shadows.shadowOf(config).copy();
copy.networkId = networkId;
return copy;
}
use of android.net.wifi.WifiConfiguration in project android by cSploit.
the class NetworkManager method shiftPriorityAndSave.
public 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 zxingfragmentlib by mitoyarzun.
the class WifiConfigManager method changeNetworkWPA.
// Adding a WPA or WPA2 network
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
// Hex passwords that are 64 bits long are not to be quoted.
config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
// For WPA
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
// For WPA2
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
updateNetwork(wifiManager, config);
}
Aggregations