Search in sources :

Example 76 with NetworkAgentInfo

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

the class ConnectivityService method getUnfilteredActiveNetworkState.

private NetworkState getUnfilteredActiveNetworkState(int uid) {
    NetworkAgentInfo nai = getDefaultNetwork();
    final Network[] networks = getVpnUnderlyingNetworks(uid);
    if (networks != null) {
        //                    first one.
        if (networks.length > 0) {
            nai = getNetworkAgentInfoForNetwork(networks[0]);
        } else {
            nai = null;
        }
    }
    if (nai != null) {
        return nai.getNetworkState();
    } else {
        return NetworkState.EMPTY;
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network)

Example 77 with NetworkAgentInfo

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

the class ConnectivityService method getLinkProperties.

// TODO - this should be ALL networks
@Override
public LinkProperties getLinkProperties(Network network) {
    enforceAccessPermission();
    NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai != null) {
        synchronized (nai) {
            return new LinkProperties(nai.linkProperties);
        }
    }
    return null;
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) LinkProperties(android.net.LinkProperties)

Example 78 with NetworkAgentInfo

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

the class ConnectivityService method createVpnInfo.

/**
     * @return VPN information for accounting, or null if we can't retrieve all required
     *         information, e.g primary underlying iface.
     */
@Nullable
private VpnInfo createVpnInfo(Vpn vpn) {
    VpnInfo info = vpn.getVpnInfo();
    if (info == null) {
        return null;
    }
    Network[] underlyingNetworks = vpn.getUnderlyingNetworks();
    // the underlyingNetworks list.
    if (underlyingNetworks == null) {
        NetworkAgentInfo defaultNetwork = getDefaultNetwork();
        if (defaultNetwork != null && defaultNetwork.linkProperties != null) {
            info.primaryUnderlyingIface = getDefaultNetwork().linkProperties.getInterfaceName();
        }
    } else if (underlyingNetworks.length > 0) {
        LinkProperties linkProperties = getLinkProperties(underlyingNetworks[0]);
        if (linkProperties != null) {
            info.primaryUnderlyingIface = linkProperties.getInterfaceName();
        }
    }
    return info.primaryUnderlyingIface == null ? null : info;
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) VpnInfo(com.android.internal.net.VpnInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) LinkProperties(android.net.LinkProperties) Nullable(android.annotation.Nullable)

Example 79 with NetworkAgentInfo

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

the class ConnectivityService method handleRegisterNetworkRequest.

private void handleRegisterNetworkRequest(NetworkRequestInfo nri) {
    mNetworkRequests.put(nri.request, nri);
    mNetworkRequestInfoLogs.log("REGISTER " + nri);
    if (nri.request.isListen()) {
        for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
            if (nri.request.networkCapabilities.hasSignalStrength() && network.satisfiesImmutableCapabilitiesOf(nri.request)) {
                updateSignalStrengthThresholds(network, "REGISTER", nri.request);
            }
        }
    }
    rematchAllNetworksAndRequests(null, 0);
    if (nri.request.isRequest() && mNetworkForRequestId.get(nri.request.requestId) == null) {
        sendUpdatedScoreToFactories(nri.request, 0);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 80 with NetworkAgentInfo

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

the class ConnectivityService method getActiveNetworkForUidInternal.

private Network getActiveNetworkForUidInternal(final int uid, boolean ignoreBlocked) {
    final int user = UserHandle.getUserId(uid);
    int vpnNetId = NETID_UNSET;
    synchronized (mVpns) {
        final Vpn vpn = mVpns.get(user);
        if (vpn != null && vpn.appliesToUid(uid))
            vpnNetId = vpn.getNetId();
    }
    NetworkAgentInfo nai;
    if (vpnNetId != NETID_UNSET) {
        synchronized (mNetworkForNetId) {
            nai = mNetworkForNetId.get(vpnNetId);
        }
        if (nai != null)
            return nai.network;
    }
    nai = getDefaultNetwork();
    if (nai != null && isNetworkWithLinkPropertiesBlocked(nai.linkProperties, uid, ignoreBlocked)) {
        nai = null;
    }
    return nai != null ? nai.network : null;
}
Also used : Vpn(com.android.server.connectivity.Vpn) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Aggregations

NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)165 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)11 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