Search in sources :

Example 36 with WifiConfiguration

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());
    }
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 37 with WifiConfiguration

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration)

Example 38 with WifiConfiguration

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());
    }
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 39 with WifiConfiguration

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());
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 40 with WifiConfiguration

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);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) LargeTest(android.test.suitebuilder.annotation.LargeTest)

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