Search in sources :

Example 36 with NetworkInfo

use of android.net.NetworkInfo in project picasso by square.

the class DispatcherTest method performNetworkStateChangeWithConnectedInfoDifferentInstanceIgnores.

@Test
public void performNetworkStateChangeWithConnectedInfoDifferentInstanceIgnores() {
    Dispatcher dispatcher = createDispatcher(serviceMock);
    NetworkInfo info = mockNetworkInfo(true);
    dispatcher.performNetworkStateChange(info);
    verifyZeroInteractions(service);
}
Also used : NetworkInfo(android.net.NetworkInfo) TestUtils.mockNetworkInfo(com.squareup.picasso.TestUtils.mockNetworkInfo) Test(org.junit.Test)

Example 37 with NetworkInfo

use of android.net.NetworkInfo in project picasso by square.

the class DispatcherTest method performNetworkStateChangeWithDisconnectedInfoIgnores.

@Test
public void performNetworkStateChangeWithDisconnectedInfoIgnores() {
    Dispatcher dispatcher = createDispatcher(serviceMock);
    NetworkInfo info = mockNetworkInfo();
    when(info.isConnectedOrConnecting()).thenReturn(false);
    dispatcher.performNetworkStateChange(info);
    verifyZeroInteractions(service);
}
Also used : NetworkInfo(android.net.NetworkInfo) TestUtils.mockNetworkInfo(com.squareup.picasso.TestUtils.mockNetworkInfo) Test(org.junit.Test)

Example 38 with NetworkInfo

use of android.net.NetworkInfo in project picasso by square.

the class DispatcherTest method performNetworkStateChangeWithConnectedInfoAndPicassoExecutorServiceAdjustsThreads.

@Test
public void performNetworkStateChangeWithConnectedInfoAndPicassoExecutorServiceAdjustsThreads() {
    PicassoExecutorService service = mock(PicassoExecutorService.class);
    NetworkInfo info = mockNetworkInfo(true);
    Dispatcher dispatcher = createDispatcher(service);
    dispatcher.performNetworkStateChange(info);
    verify(service).adjustThreadCount(info);
    verifyZeroInteractions(service);
}
Also used : NetworkInfo(android.net.NetworkInfo) TestUtils.mockNetworkInfo(com.squareup.picasso.TestUtils.mockNetworkInfo) Test(org.junit.Test)

Example 39 with NetworkInfo

use of android.net.NetworkInfo in project FBReaderJ by geometer.

the class AndroidNetworkContext method perform.

@Override
protected void perform(ZLNetworkRequest request, int socketTimeout, int connectionTimeout) throws ZLNetworkException {
    final NetworkInfo info = getActiveNetworkInfo();
    if (info == null || !info.isConnected()) {
        throw ZLNetworkException.forCode("networkNotAvailable");
    }
    super.perform(request, socketTimeout, connectionTimeout);
}
Also used : NetworkInfo(android.net.NetworkInfo)

Example 40 with NetworkInfo

use of android.net.NetworkInfo in project fqrouter by fqrouter.

the class LaunchService method getApnName.

private String getApnName() {
    try {
        ConnectivityManager conManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = conManager.getActiveNetworkInfo();
        if (null == ni) {
            return "";
        }
        return ni.getExtraInfo();
    } catch (Exception e) {
        LogUtils.e("failed to get apn name", e);
        return "";
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager)

Aggregations

NetworkInfo (android.net.NetworkInfo)511 ConnectivityManager (android.net.ConnectivityManager)274 Intent (android.content.Intent)47 LinkProperties (android.net.LinkProperties)38 NetworkState (android.net.NetworkState)26 Test (org.junit.Test)26 PendingIntent (android.app.PendingIntent)23 NetworkCapabilities (android.net.NetworkCapabilities)18 Network (android.net.Network)17 LargeTest (android.test.suitebuilder.annotation.LargeTest)17 RemoteException (android.os.RemoteException)16 Context (android.content.Context)15 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)15 WifiInfo (android.net.wifi.WifiInfo)13 Bundle (android.os.Bundle)13 TestUtils.mockNetworkInfo (com.squareup.picasso.TestUtils.mockNetworkInfo)12 IOException (java.io.IOException)11 WifiManager (android.net.wifi.WifiManager)9 IntentFilter (android.content.IntentFilter)8 BroadcastReceiver (android.content.BroadcastReceiver)7