Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e5cfe4e authored by lucaslin's avatar lucaslin Committed by Lucas Lin
Browse files

Replace MAX_NETWORK_TYPE with TYPE_VPN

ConnectivityManager#MAX_NETWORK_TYPE is a hidden API which cannot
be accessed after ConnectivityManager becomes a part of mainline
module.
Use the max public network type - TYPE_VPN should be enough since
TYPE_* is deprecated and no longer extended.

Bug: 182859030
Test: 1. Remove "framework-connectivity.impl"
      2. cd frameworks/base/core/tests/bandwidthtests; mm
Change-Id: I27579a942a0424db647ad1f3383db78d5a0c69a9
Merged-In: I27579a942a0424db647ad1f3383db78d5a0c69a9
    (Cherry-picked from ag/14111130)
parent 9ef59ac9
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -44,8 +44,6 @@ import com.android.bandwidthtest.NetworkState;
import com.android.bandwidthtest.NetworkState.StateTransitionDirection;
import com.android.internal.util.AsyncChannel;

import junit.framework.Assert;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;
@@ -76,7 +74,11 @@ public class ConnectionUtil {
    private WifiManager mWifiManager;
    private Context mContext;
    // Verify connectivity state
    private static final int NUM_NETWORK_TYPES = ConnectivityManager.MAX_NETWORK_TYPE + 1;
    // ConnectivityManager.TYPE_* is deprecated and no longer extended, so use the max public
    // network type - TYPE_VPN should be enough.
    // TODO: Replace registering CONNECTIVITY_ACTION with registering NetworkCallback and check
    //  network by NetworkCapabilities.TRANSPORT_* and NetworkCapabilities.hasTransport() instead.
    private static final int NUM_NETWORK_TYPES = ConnectivityManager.TYPE_VPN + 1;
    private NetworkState[] mConnectivityState = new NetworkState[NUM_NETWORK_TYPES];

    public ConnectionUtil(Context context) {