Search in sources :

Example 96 with NetworkState

use of android.net.NetworkState in project android_frameworks_base by ResurrectionRemix.

the class NetworkStatsServiceTest method buildMobile4gState.

private static NetworkState buildMobile4gState(String iface) {
    final NetworkInfo info = new NetworkInfo(TYPE_WIMAX, 0, null, null);
    info.setDetailedState(DetailedState.CONNECTED, null, null);
    final LinkProperties prop = new LinkProperties();
    prop.setInterfaceName(iface);
    return new NetworkState(info, prop, null, null, null, null);
}
Also used : NetworkInfo(android.net.NetworkInfo) NetworkState(android.net.NetworkState) LinkProperties(android.net.LinkProperties)

Example 97 with NetworkState

use of android.net.NetworkState in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method getNetworkInfoForUid.

@Override
public NetworkInfo getNetworkInfoForUid(Network network, int uid, boolean ignoreBlocked) {
    enforceAccessPermission();
    final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai != null) {
        final NetworkState state = nai.getNetworkState();
        filterNetworkStateForUid(state, uid, ignoreBlocked);
        return state.networkInfo;
    } else {
        return null;
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) NetworkState(android.net.NetworkState)

Example 98 with NetworkState

use of android.net.NetworkState in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method getActiveNetworkQuotaInfo.

@Override
public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    final long token = Binder.clearCallingIdentity();
    try {
        final NetworkState state = getUnfilteredActiveNetworkState(uid);
        if (state.networkInfo != null) {
            try {
                return mPolicyManager.getNetworkQuotaInfo(state);
            } catch (RemoteException e) {
            }
        }
        return null;
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : NetworkState(android.net.NetworkState) RemoteException(android.os.RemoteException)

Example 99 with NetworkState

use of android.net.NetworkState in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method getActiveLinkProperties.

/**
     * Return LinkProperties for the active (i.e., connected) default
     * network interface.  It is assumed that at most one default network
     * is active at a time. If more than one is active, it is indeterminate
     * which will be returned.
     * @return the ip properties for the active network, or {@code null} if
     * none is active
     */
@Override
public LinkProperties getActiveLinkProperties() {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    NetworkState state = getUnfilteredActiveNetworkState(uid);
    return state.linkProperties;
}
Also used : NetworkState(android.net.NetworkState)

Example 100 with NetworkState

use of android.net.NetworkState in project android_frameworks_base by crdroidandroid.

the class NetworkPolicyManagerServiceTest method buildWifi.

private static NetworkState buildWifi() {
    final NetworkInfo info = new NetworkInfo(TYPE_WIFI, 0, null, null);
    info.setDetailedState(DetailedState.CONNECTED, null, null);
    final LinkProperties prop = new LinkProperties();
    prop.setInterfaceName(TEST_IFACE);
    return new NetworkState(info, prop, null, null, null, TEST_SSID);
}
Also used : NetworkInfo(android.net.NetworkInfo) NetworkState(android.net.NetworkState) LinkProperties(android.net.LinkProperties)

Aggregations

NetworkState (android.net.NetworkState)101 LinkProperties (android.net.LinkProperties)36 NetworkInfo (android.net.NetworkInfo)26 NetworkPolicy (android.net.NetworkPolicy)21 RemoteException (android.os.RemoteException)18 NetworkStats (android.net.NetworkStats)15 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)15 NetworkIdentity (android.net.NetworkIdentity)11 Intent (android.content.Intent)10 ArraySet (android.util.ArraySet)10 Suppress (android.test.suitebuilder.annotation.Suppress)9 NetworkCapabilities (android.net.NetworkCapabilities)8 Network (android.net.Network)5 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5 Pair (android.util.Pair)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)2 NetworkStateTracker (android.net.NetworkStateTracker)1 HashMap (java.util.HashMap)1