Switch to using NetworkScore instead of legacy integer
This change switches the VcnNetworkAgent from using the legacy score integer, and switches to using the new NetworkScore, using the legacy integer as a internal representation. Bug: 185204197 Test: FrameworksVcnTests Change-Id: Ib0690243f176a2f074358fcc8430f1fd7c3d0d3c
This commit is contained in:
@@ -32,6 +32,7 @@ import android.content.ContentResolver;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkRequest;
|
||||
import android.net.NetworkScore;
|
||||
import android.net.Uri;
|
||||
import android.net.vcn.VcnConfig;
|
||||
import android.net.vcn.VcnGatewayConnectionConfig;
|
||||
@@ -71,6 +72,8 @@ import java.util.Set;
|
||||
public class Vcn extends Handler {
|
||||
private static final String TAG = Vcn.class.getSimpleName();
|
||||
|
||||
private static final int VCN_LEGACY_SCORE_INT = 52;
|
||||
|
||||
private static final List<Integer> CAPS_REQUIRING_MOBILE_DATA =
|
||||
Arrays.asList(NET_CAPABILITY_INTERNET, NET_CAPABILITY_DUN);
|
||||
|
||||
@@ -527,11 +530,9 @@ public class Vcn extends Handler {
|
||||
}
|
||||
|
||||
/** Retrieves the network score for a VCN Network */
|
||||
// Package visibility for use in VcnGatewayConnection
|
||||
static int getNetworkScore() {
|
||||
// TODO: STOPSHIP (b/173549607): Make this use new NetworkSelection, or some magic "max in
|
||||
// subGrp" value
|
||||
return 52;
|
||||
// Package visibility for use in VcnGatewayConnection and VcnNetworkProvider
|
||||
static NetworkScore getNetworkScore() {
|
||||
return new NetworkScore.Builder().setLegacyInt(VCN_LEGACY_SCORE_INT).build();
|
||||
}
|
||||
|
||||
/** Callback used for passing status signals from a VcnGatewayConnection to its managing Vcn. */
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.net.NetworkAgent;
|
||||
import android.net.NetworkAgentConfig;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkProvider;
|
||||
import android.net.NetworkScore;
|
||||
import android.net.RouteInfo;
|
||||
import android.net.TelephonyNetworkSpecifier;
|
||||
import android.net.Uri;
|
||||
@@ -2203,7 +2204,7 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
@NonNull String tag,
|
||||
@NonNull NetworkCapabilities caps,
|
||||
@NonNull LinkProperties lp,
|
||||
@NonNull int score,
|
||||
@NonNull NetworkScore score,
|
||||
@NonNull NetworkAgentConfig nac,
|
||||
@NonNull NetworkProvider provider,
|
||||
@NonNull Consumer<VcnNetworkAgent> networkUnwantedCallback,
|
||||
@@ -2344,7 +2345,7 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
@NonNull String tag,
|
||||
@NonNull NetworkCapabilities caps,
|
||||
@NonNull LinkProperties lp,
|
||||
@NonNull int score,
|
||||
@NonNull NetworkScore score,
|
||||
@NonNull NetworkAgentConfig nac,
|
||||
@NonNull NetworkProvider provider,
|
||||
@NonNull Consumer<VcnNetworkAgent> networkUnwantedCallback,
|
||||
|
||||
@@ -89,7 +89,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
mNetworkAgent = mock(VcnNetworkAgent.class);
|
||||
doReturn(mNetworkAgent)
|
||||
.when(mDeps)
|
||||
.newNetworkAgent(any(), any(), any(), any(), anyInt(), any(), any(), any(), any());
|
||||
.newNetworkAgent(any(), any(), any(), any(), any(), any(), any(), any(), any());
|
||||
|
||||
mGatewayConnection.setUnderlyingNetwork(TEST_UNDERLYING_NETWORK_RECORD_1);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
anyInt(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
@@ -244,7 +244,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
any(String.class),
|
||||
ncCaptor.capture(),
|
||||
lpCaptor.capture(),
|
||||
anyInt(),
|
||||
any(),
|
||||
argThat(nac -> nac.getLegacyType() == ConnectivityManager.TYPE_MOBILE),
|
||||
any(),
|
||||
any(),
|
||||
@@ -297,7 +297,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
startingInternalAddrs.equals(lp.getLinkAddresses())
|
||||
&& Collections.singletonList(TEST_DNS_ADDR)
|
||||
.equals(lp.getDnsServers())),
|
||||
anyInt(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
@@ -356,7 +356,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
anyInt(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
unwantedCallbackCaptor.capture(),
|
||||
|
||||
Reference in New Issue
Block a user