From fd99009c529d5ee7734997f2dfecb486a4b5df22 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Fri, 21 Feb 2020 19:52:43 +0900 Subject: [PATCH] Revert part of 79eb7ba87bedd88fffa62a13ea9399c2affa1573 This reverts the parts of the above commit that have to do with NetworkScore. The parts that convert the factory to the new NetworkAgent API are conserved. Bug: 113554781 Test: FrameworksNetTests Change-Id: If2c368e084e29f9f358f43dcd547d42e8c7c4846 --- .../server/ethernet/EthernetNetworkFactory.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 7f12a136bc..1c835062ba 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -32,7 +32,6 @@ import android.net.NetworkAgentConfig; import android.net.NetworkCapabilities; import android.net.NetworkFactory; import android.net.NetworkRequest; -import android.net.NetworkScore; import android.net.NetworkSpecifier; import android.net.StringNetworkSpecifier; import android.net.ip.IIpClient; @@ -66,9 +65,6 @@ public class EthernetNetworkFactory extends NetworkFactory { private final static int NETWORK_SCORE = 70; private static final String NETWORK_TYPE = "Ethernet"; - private final static NetworkScore NULL_SCORE = new NetworkScore.Builder() - .setRange(NetworkScore.RANGE_CLOSE) - .build(); private final ConcurrentHashMap mTrackingInterfaces = new ConcurrentHashMap<>(); @@ -420,23 +416,23 @@ public class EthernetNetworkFactory extends NetworkFactory { * This function is called with the purpose of assigning and updating the network score of * the member NetworkAgent. */ - private NetworkScore getNetworkScore() { + private int getNetworkScore() { // never set the network score below 0. if (!mLinkUp) { - return NULL_SCORE; + return 0; } int[] transportTypes = mCapabilities.getTransportTypes(); if (transportTypes.length < 1) { Log.w(TAG, "Network interface '" + mLinkProperties.getInterfaceName() + "' has no " + "transport type associated with it. Score set to zero"); - return NULL_SCORE; + return 0; } TransportInfo transportInfo = sTransports.get(transportTypes[0], /* if dne */ null); if (transportInfo != null) { - return new NetworkScore.Builder().setLegacyScore(transportInfo.mScore).build(); + return transportInfo.mScore; } - return NULL_SCORE; + return 0; } private void start() { @@ -467,7 +463,6 @@ public class EthernetNetworkFactory extends NetworkFactory { mLinkProperties = linkProperties; // Create our NetworkAgent. - // STOPSHIP : use the new constructor for NetworkAgent that takes a NetworkScore final NetworkAgentConfig config = new NetworkAgentConfig.Builder() .setLegacyType(mLegacyType) .setLegacyTypeName(NETWORK_TYPE)