Search in sources :

Example 6 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo 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 7 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo 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 8 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

the class ConnectivityService method getProxyForNetwork.

@Override
public ProxyInfo getProxyForNetwork(Network network) {
    if (network == null)
        return getDefaultProxy();
    final ProxyInfo globalProxy = getGlobalProxy();
    if (globalProxy != null)
        return globalProxy;
    if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId))
        return null;
    // Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
    // caller may not have.
    final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai == null)
        return null;
    synchronized (nai) {
        final ProxyInfo proxyInfo = nai.linkProperties.getHttpProxy();
        if (proxyInfo == null)
            return null;
        return new ProxyInfo(proxyInfo);
    }
}
Also used : ProxyInfo(android.net.ProxyInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 9 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

the class ConnectivityService method isLiveNetworkAgent.

private boolean isLiveNetworkAgent(NetworkAgentInfo nai, int what) {
    if (nai.network == null)
        return false;
    final NetworkAgentInfo officialNai = getNetworkAgentInfoForNetwork(nai.network);
    if (officialNai != null && officialNai.equals(nai))
        return true;
    if (officialNai != null || VDBG) {
        final String msg = sMagicDecoderRing.get(what, Integer.toString(what));
        loge(msg + " - isLiveNetworkAgent found mismatched netId: " + officialNai + " - " + nai);
    }
    return false;
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 10 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

the class ConnectivityService method handleAsyncChannelHalfConnect.

private void handleAsyncChannelHalfConnect(Message msg) {
    AsyncChannel ac = (AsyncChannel) msg.obj;
    if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkFactory connected");
            // A network factory has connected.  Send it all current NetworkRequests.
            for (NetworkRequestInfo nri : mNetworkRequests.values()) {
                if (nri.request.isListen())
                    continue;
                NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
                ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.getCurrentScore() : 0), 0, nri.request);
            }
        } else {
            loge("Error connecting NetworkFactory");
            mNetworkFactoryInfos.remove(msg.obj);
        }
    } else if (mNetworkAgentInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkAgent connected");
            // A network agent has requested a connection.  Establish the connection.
            mNetworkAgentInfos.get(msg.replyTo).asyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
        } else {
            loge("Error connecting NetworkAgent");
            NetworkAgentInfo nai = mNetworkAgentInfos.remove(msg.replyTo);
            if (nai != null) {
                final boolean wasDefault = isDefaultNetwork(nai);
                synchronized (mNetworkForNetId) {
                    mNetworkForNetId.remove(nai.network.netId);
                    mNetIdInUse.delete(nai.network.netId);
                }
                // Just in case.
                mLegacyTypeTracker.remove(nai, wasDefault);
            }
        }
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) AsyncChannel(com.android.internal.util.AsyncChannel)

Aggregations

NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)162 LinkProperties (android.net.LinkProperties)40 Network (android.net.Network)25 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)21 NetworkCapabilities (android.net.NetworkCapabilities)20 NetworkInfo (android.net.NetworkInfo)15 NetworkRequest (android.net.NetworkRequest)15 NetworkState (android.net.NetworkState)15 RemoteException (android.os.RemoteException)14 UnknownHostException (java.net.UnknownHostException)14 AsyncChannel (com.android.internal.util.AsyncChannel)10 Vpn (com.android.server.connectivity.Vpn)10 ArrayList (java.util.ArrayList)10 FileNotFoundException (java.io.FileNotFoundException)9 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)9 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)9 Nullable (android.annotation.Nullable)5 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5