Search in sources :

Example 71 with NetworkState

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

the class ConnectivityService method getActiveNetworkInfoForUid.

@Override
public NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked) {
    enforceConnectivityInternalPermission();
    final NetworkState state = getUnfilteredActiveNetworkState(uid);
    filterNetworkStateForUid(state, uid, ignoreBlocked);
    return state.networkInfo;
}
Also used : NetworkState(android.net.NetworkState)

Example 72 with NetworkState

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

the class ConnectivityService method getAllNetworkState.

@Override
public NetworkState[] getAllNetworkState() {
    // Require internal since we're handing out IMSI details
    enforceConnectivityInternalPermission();
    final ArrayList<NetworkState> result = Lists.newArrayList();
    for (Network network : getAllNetworks()) {
        final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
        if (nai != null) {
            result.add(nai.getNetworkState());
        }
    }
    return result.toArray(new NetworkState[result.size()]);
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) NetworkState(android.net.NetworkState)

Example 73 with NetworkState

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

the class ConnectivityService method getActiveNetworkInfoUnfiltered.

// Public because it's used by mLockdownTracker.
public NetworkInfo getActiveNetworkInfoUnfiltered() {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    NetworkState state = getUnfilteredActiveNetworkState(uid);
    return state.networkInfo;
}
Also used : NetworkState(android.net.NetworkState)

Example 74 with NetworkState

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

the class ConnectivityService method getNetworkInfo.

@Override
public NetworkInfo getNetworkInfo(int networkType) {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    if (getVpnUnderlyingNetworks(uid) != null) {
        // A VPN is active, so we may need to return one of its underlying networks. This
        // information is not available in LegacyTypeTracker, so we have to get it from
        // getUnfilteredActiveNetworkState.
        final NetworkState state = getUnfilteredActiveNetworkState(uid);
        if (state.networkInfo != null && state.networkInfo.getType() == networkType) {
            filterNetworkStateForUid(state, uid, false);
            return state.networkInfo;
        }
    }
    final NetworkState state = getFilteredNetworkState(networkType, uid, false);
    return state.networkInfo;
}
Also used : NetworkState(android.net.NetworkState)

Example 75 with NetworkState

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

the class ConnectivityService method getNetworkForType.

@Override
public Network getNetworkForType(int networkType) {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    NetworkState state = getFilteredNetworkState(networkType, uid, false);
    if (!isNetworkWithLinkPropertiesBlocked(state.linkProperties, uid, false)) {
        return state.network;
    }
    return null;
}
Also used : NetworkState(android.net.NetworkState)

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