Search in sources :

Example 6 with NetworkState

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

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 7 with NetworkState

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

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 8 with NetworkState

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

the class ConnectivityService method getFilteredNetworkState.

private NetworkState getFilteredNetworkState(int networkType, int uid, boolean ignoreBlocked) {
    if (mLegacyTypeTracker.isTypeSupported(networkType)) {
        final NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
        final NetworkState state;
        if (nai != null) {
            state = nai.getNetworkState();
            state.networkInfo.setType(networkType);
        } else {
            final NetworkInfo info = new NetworkInfo(networkType, 0, getNetworkTypeName(networkType), "");
            info.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
            info.setIsAvailable(true);
            state = new NetworkState(info, new LinkProperties(), new NetworkCapabilities(), null, null, null);
        }
        filterNetworkStateForUid(state, uid, ignoreBlocked);
        return state;
    } else {
        return NetworkState.EMPTY;
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) NetworkState(android.net.NetworkState) LinkProperties(android.net.LinkProperties) NetworkCapabilities(android.net.NetworkCapabilities)

Example 9 with NetworkState

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

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)

Example 10 with NetworkState

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

the class ConnectivityService method getActiveNetworkInfo.

/**
     * Return NetworkInfo for the active (i.e., connected) network interface.
     * It is assumed that at most one network is active at a time. If more
     * than one is active, it is indeterminate which will be returned.
     * @return the info for the active network, or {@code null} if none is
     * active
     */
@Override
public NetworkInfo getActiveNetworkInfo() {
    enforceAccessPermission();
    final int uid = Binder.getCallingUid();
    final NetworkState state = getUnfilteredActiveNetworkState(uid);
    filterNetworkStateForUid(state, uid, false);
    maybeLogBlockedNetworkInfo(state.networkInfo, uid);
    return state.networkInfo;
}
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