Search in sources :

Example 91 with NetworkState

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

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

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

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

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

the class NetworkPolicyManagerServiceTest method testMeteredNetworkWithoutLimit.

@Suppress
public void testMeteredNetworkWithoutLimit() throws Exception {
    NetworkState[] state = null;
    NetworkStats stats = null;
    Future<Void> future;
    Future<String> tagFuture;
    final long TIME_FEB_15 = 1171497600000L;
    final long TIME_MAR_10 = 1173484800000L;
    final int CYCLE_DAY = 15;
    setCurrentTimeMillis(TIME_MAR_10);
    // bring up wifi network with metered policy
    state = new NetworkState[] { buildWifi() };
    stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 0L, 0L, 0L, 0L);
    {
        expectCurrentTime();
        expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
        expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, currentTimeMillis())).andReturn(stats.getTotalBytes()).atLeastOnce();
        expectPolicyDataEnable(TYPE_WIFI, true);
        expectRemoveInterfaceQuota(TEST_IFACE);
        expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE);
        expectClearNotifications();
        expectAdvisePersistThreshold();
        future = expectMeteredIfacesChanged(TEST_IFACE);
        replay();
        setNetworkPolicies(new NetworkPolicy(sTemplateWifi, CYCLE_DAY, TIMEZONE_UTC, WARNING_DISABLED, LIMIT_DISABLED, true));
        future.get();
        verifyAndReset();
    }
}
Also used : NetworkPolicy(android.net.NetworkPolicy) NetworkStats(android.net.NetworkStats) NetworkState(android.net.NetworkState) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 94 with NetworkState

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

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

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

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