Search in sources :

Example 16 with WifiManager

use of android.net.wifi.WifiManager in project robolectric by robolectric.

the class ShadowWifiInfoTest method shouldReturnFrequency.

@Test
@Config(minSdk = LOLLIPOP)
public void shouldReturnFrequency() {
    WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getFrequency()).isEqualTo(-1);
    shadowOf(wifiInfo).setFrequency(10);
    wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getFrequency()).isEqualTo(10);
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 17 with WifiManager

use of android.net.wifi.WifiManager in project robolectric by robolectric.

the class ShadowWifiInfoTest method shouldReturnBSSID.

@Test
public void shouldReturnBSSID() {
    WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getBSSID()).isEqualTo(null);
    shadowOf(wifiInfo).setBSSID("BSSID");
    wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getBSSID()).isEqualTo("BSSID");
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo) Test(org.junit.Test)

Example 18 with WifiManager

use of android.net.wifi.WifiManager in project robolectric by robolectric.

the class ShadowWifiInfoTest method shouldReturnMacAddress.

@Test
public void shouldReturnMacAddress() {
    WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getMacAddress()).isEqualTo(// WifiInfo.DEFAULT_MAC_ADDRESS
    "02:00:00:00:00:00");
    shadowOf(wifiInfo).setMacAddress("mac address");
    wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getMacAddress()).isEqualTo("mac address");
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo) Test(org.junit.Test)

Example 19 with WifiManager

use of android.net.wifi.WifiManager in project robolectric by robolectric.

the class ShadowWifiInfoTest method shouldReturnSSID.

@Test
public void shouldReturnSSID() {
    WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    // WifiSsid.NONE
    assertThat(wifiInfo.getSSID()).isEqualTo("<unknown ssid>");
    shadowOf(wifiInfo).setSSID("SSID");
    wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();
    assertThat(wifiInfo.getSSID()).isEqualTo("SSID");
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo) Test(org.junit.Test)

Example 20 with WifiManager

use of android.net.wifi.WifiManager in project fqrouter by fqrouter.

the class AcquireWifiLockService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    try {
        WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        if (null == wifiLock) {
            wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "fqrouter wifi hotspot");
        }
        wifiLock.acquire();
        LogUtils.i("acquired wifi lock");
    } catch (Exception e) {
        LogUtils.e("failed to acquire wifi lock", e);
    }
}
Also used : WifiManager(android.net.wifi.WifiManager)

Aggregations

WifiManager (android.net.wifi.WifiManager)169 WifiInfo (android.net.wifi.WifiInfo)53 WifiConfiguration (android.net.wifi.WifiConfiguration)42 IOException (java.io.IOException)24 IntentFilter (android.content.IntentFilter)13 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 Context (android.content.Context)9 ConnectivityManager (android.net.ConnectivityManager)8 NetworkInfo (android.net.NetworkInfo)8 Test (org.junit.Test)8 Intent (android.content.Intent)7 File (java.io.File)6 SAXException (org.xml.sax.SAXException)6 SharedPreferences (android.content.SharedPreferences)5 PowerManager (android.os.PowerManager)5 TelephonyManager (android.telephony.TelephonyManager)5 X509Certificate (java.security.cert.X509Certificate)5 BufferedReader (java.io.BufferedReader)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileReader (java.io.FileReader)4