From afdb65906d65b1febb2e6ccab1094798a0ba0da0 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Wed, 7 Apr 2021 20:32:39 +0800 Subject: [PATCH] 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 --- .../com/android/bandwidthtest/util/ConnectionUtil.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java index dd60dd4c40f9a..1a636604ed577 100644 --- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java +++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java @@ -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) {