use of android.net.wifi.WifiConfiguration in project android_frameworks_base by ParanoidAndroid.
the class WifiConnectionTest method printNetworkConfigurations.
private void printNetworkConfigurations() {
log("==== print network configurations parsed from XML file ====");
log("number of access points: " + networks.size());
for (WifiConfiguration config : networks) {
log(config.toString());
}
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by ParanoidAndroid.
the class ConnectivityManagerTestActivity method disconnectAP.
/*
* Disconnect from the current AP and remove configured networks.
*/
public boolean disconnectAP() {
// remove saved networks
if (!mWifiManager.isWifiEnabled()) {
log("Enabled wifi before remove configured networks");
mWifiManager.setWifiEnabled(true);
sleep(SHORT_TIMEOUT);
}
List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
log("size of wifiConfigList: " + wifiConfigList.size());
for (WifiConfiguration wifiConfig : wifiConfigList) {
log("remove wifi configuration: " + wifiConfig.networkId);
int netId = wifiConfig.networkId;
mWifiManager.forget(netId, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
log("Failed to forget " + reason);
}
});
}
return true;
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by ResurrectionRemix.
the class WifiApStress method testWifiHotSpot.
@LargeTest
public void testWifiHotSpot() {
if (mWifiOnlyFlag) {
logv(getName() + " is excluded for wi-fi only test");
return;
}
WifiConfiguration config = new WifiConfiguration();
config.SSID = NETWORK_ID;
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
config.preSharedKey = PASSWD;
// if wifiap enabled, disable it
assertTrue("failed to disable wifi hotspot", mWifiManager.setWifiApEnabled(config, false));
assertTrue("wifi hotspot not enabled", waitForWifiApState(WifiManager.WIFI_AP_STATE_DISABLED, 2 * LONG_TIMEOUT));
// if Wifi is enabled, disable it
if (mWifiManager.isWifiEnabled()) {
assertTrue("failed to disable wifi", disableWifi());
// wait for the wifi state to be DISABLED
assertTrue("wifi state not disabled", waitForWifiState(WifiManager.WIFI_STATE_DISABLED, LONG_TIMEOUT));
}
int i;
for (i = 0; i < mTotalIterations; i++) {
logv("iteration: " + i);
mLastIteration = i;
// enable Wifi tethering
assertTrue("failed to enable wifi hotspot", mWifiManager.setWifiApEnabled(config, true));
// wait for wifi ap state to be ENABLED
assertTrue("wifi hotspot not enabled", waitForWifiApState(WifiManager.WIFI_AP_STATE_ENABLED, 2 * LONG_TIMEOUT));
// wait for wifi tethering result
assertTrue("tether state not changed", waitForTetherStateChange(LONG_TIMEOUT));
// allow the wifi tethering to be enabled for 10 seconds
try {
Thread.sleep(2 * SHORT_TIMEOUT);
} catch (Exception e) {
// ignore
}
assertTrue("no uplink data connection after Wi-Fi tethering", pingTest());
// disable wifi hotspot
assertTrue("failed to disable wifi hotspot", mWifiManager.setWifiApEnabled(config, false));
assertTrue("wifi hotspot not enabled", waitForWifiApState(WifiManager.WIFI_AP_STATE_DISABLED, 2 * LONG_TIMEOUT));
assertFalse("wifi hotspot still enabled", mWifiManager.isWifiApEnabled());
}
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by ResurrectionRemix.
the class WifiSoftAPTest method testApSsidWithAlphabet.
// Test case 1: Test the soft AP SSID with letters
@LargeTest
public void testApSsidWithAlphabet() {
WifiConfiguration config = new WifiConfiguration();
config.SSID = "abcdefghijklmnopqrstuvwxyz";
config.allowedKeyManagement.set(KeyMgmt.NONE);
mWifiConfig = config;
assertTrue(mWifiManager.setWifiApEnabled(mWifiConfig, true));
try {
Thread.sleep(DURATION);
} catch (InterruptedException e) {
Log.v(TAG, "exception " + e.getStackTrace());
assertFalse(true);
}
assertNotNull(mWifiManager.getWifiApConfiguration());
assertEquals("wifi AP state is not enabled", WifiManager.WIFI_AP_STATE_ENABLED, mWifiManager.getWifiApState());
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by ResurrectionRemix.
the class WifiClientTest method testAddRemoveNetwork.
// Test case 1: add/remove a open network
@LargeTest
public void testAddRemoveNetwork() {
WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"TestSSID1\"";
config.allowedKeyManagement.set(KeyMgmt.NONE);
//add
int netId = mWifiManager.addNetwork(config);
assertTrue(netId != -1);
//check config list
List<WifiConfiguration> configList = mWifiManager.getConfiguredNetworks();
boolean found = false;
for (WifiConfiguration c : configList) {
if (c.networkId == netId && c.SSID.equals(config.SSID)) {
found = true;
}
}
assertTrue(found);
//remove
boolean ret = mWifiManager.removeNetwork(netId);
assertTrue(ret);
//check config list
configList = mWifiManager.getConfiguredNetworks();
found = false;
for (WifiConfiguration c : configList) {
if (c.networkId == netId) {
found = true;
}
}
assertFalse(found);
}
Aggregations