Search in sources :

Example 6 with NetworkCapabilities

use of android.net.NetworkCapabilities in project platform_frameworks_base by android.

the class ConnectivityService method createInternetRequestForTransport.

private NetworkRequest createInternetRequestForTransport(int transportType, NetworkRequest.Type type) {
    NetworkCapabilities netCap = new NetworkCapabilities();
    netCap.addCapability(NET_CAPABILITY_INTERNET);
    netCap.addCapability(NET_CAPABILITY_NOT_RESTRICTED);
    if (transportType > -1) {
        netCap.addTransportType(transportType);
    }
    return new NetworkRequest(netCap, TYPE_NONE, nextNetworkRequestId(), type);
}
Also used : NetworkRequest(android.net.NetworkRequest) NetworkCapabilities(android.net.NetworkCapabilities)

Example 7 with NetworkCapabilities

use of android.net.NetworkCapabilities in project platform_frameworks_base by android.

the class ConnectivityManagerTest method verifyNetworkCapabilities.

static NetworkCapabilities verifyNetworkCapabilities(int legacyType, int transportType, int... capabilities) {
    final NetworkCapabilities nc = ConnectivityManager.networkCapabilitiesForType(legacyType);
    assertNotNull(nc);
    assertTrue(nc.hasTransport(transportType));
    for (int capability : capabilities) {
        assertTrue(nc.hasCapability(capability));
    }
    return nc;
}
Also used : NetworkCapabilities(android.net.NetworkCapabilities)

Example 8 with NetworkCapabilities

use of android.net.NetworkCapabilities in project platform_frameworks_base by android.

the class ConnectivityManagerTest method testNetworkCapabilitiesForTypeWifiP2p.

@Test
public void testNetworkCapabilitiesForTypeWifiP2p() {
    final NetworkCapabilities nc = verifyNetworkCapabilities(ConnectivityManager.TYPE_WIFI_P2P, TRANSPORT_WIFI, NET_CAPABILITY_NOT_RESTRICTED, NET_CAPABILITY_NOT_VPN, NET_CAPABILITY_TRUSTED, NET_CAPABILITY_WIFI_P2P);
    assertFalse(nc.hasCapability(NET_CAPABILITY_INTERNET));
}
Also used : NetworkCapabilities(android.net.NetworkCapabilities) SmallTest(android.support.test.filters.SmallTest) Test(org.junit.Test)

Example 9 with NetworkCapabilities

use of android.net.NetworkCapabilities in project platform_frameworks_base by android.

the class ConnectivityManagerTest method testNetworkCapabilitiesForTypeMobileMms.

@Test
public void testNetworkCapabilitiesForTypeMobileMms() {
    final NetworkCapabilities nc = verifyNetworkCapabilities(ConnectivityManager.TYPE_MOBILE_MMS, TRANSPORT_CELLULAR, NET_CAPABILITY_MMS, NET_CAPABILITY_NOT_VPN, NET_CAPABILITY_TRUSTED);
    assertFalse(nc.hasCapability(NET_CAPABILITY_INTERNET));
}
Also used : NetworkCapabilities(android.net.NetworkCapabilities) SmallTest(android.support.test.filters.SmallTest) Test(org.junit.Test)

Example 10 with NetworkCapabilities

use of android.net.NetworkCapabilities in project platform_frameworks_base by android.

the class LingerMonitorTest method nai.

NetworkAgentInfo nai(int netId, int transport, int networkType, String networkTypeName) {
    NetworkInfo info = new NetworkInfo(networkType, 0, networkTypeName, "");
    NetworkCapabilities caps = new NetworkCapabilities();
    caps.addCapability(0);
    caps.addTransportType(transport);
    NetworkAgentInfo nai = new NetworkAgentInfo(null, null, new Network(netId), info, null, caps, 50, mCtx, null, mMisc, null, mConnService);
    nai.everValidated = true;
    return nai;
}
Also used : NetworkInfo(android.net.NetworkInfo) Network(android.net.Network) NetworkCapabilities(android.net.NetworkCapabilities)

Aggregations

NetworkCapabilities (android.net.NetworkCapabilities)114 NetworkRequest (android.net.NetworkRequest)53 Network (android.net.Network)27 RemoteException (android.os.RemoteException)25 LinkProperties (android.net.LinkProperties)23 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)20 NetworkInfo (android.net.NetworkInfo)18 ConnectivityManager (android.net.ConnectivityManager)15 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)15 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 NetworkCallback (android.net.ConnectivityManager.NetworkCallback)10 NetworkState (android.net.NetworkState)8 HandlerThread (android.os.HandlerThread)8 NetworkMisc (android.net.NetworkMisc)5 IWifiManager (android.net.wifi.IWifiManager)5 WifiManager (android.net.wifi.WifiManager)5 Bundle (android.os.Bundle)5 Message (android.os.Message)5 ServiceState (android.telephony.ServiceState)5 SignalStrength (android.telephony.SignalStrength)5