Revert part of 79eb7ba87b
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
This commit is contained in:
@@ -32,7 +32,6 @@ import android.net.NetworkAgentConfig;
|
|||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkFactory;
|
import android.net.NetworkFactory;
|
||||||
import android.net.NetworkRequest;
|
import android.net.NetworkRequest;
|
||||||
import android.net.NetworkScore;
|
|
||||||
import android.net.NetworkSpecifier;
|
import android.net.NetworkSpecifier;
|
||||||
import android.net.StringNetworkSpecifier;
|
import android.net.StringNetworkSpecifier;
|
||||||
import android.net.ip.IIpClient;
|
import android.net.ip.IIpClient;
|
||||||
@@ -66,9 +65,6 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
|
|
||||||
private final static int NETWORK_SCORE = 70;
|
private final static int NETWORK_SCORE = 70;
|
||||||
private static final String NETWORK_TYPE = "Ethernet";
|
private static final String NETWORK_TYPE = "Ethernet";
|
||||||
private final static NetworkScore NULL_SCORE = new NetworkScore.Builder()
|
|
||||||
.setRange(NetworkScore.RANGE_CLOSE)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, NetworkInterfaceState> mTrackingInterfaces =
|
private final ConcurrentHashMap<String, NetworkInterfaceState> mTrackingInterfaces =
|
||||||
new ConcurrentHashMap<>();
|
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
|
* This function is called with the purpose of assigning and updating the network score of
|
||||||
* the member NetworkAgent.
|
* the member NetworkAgent.
|
||||||
*/
|
*/
|
||||||
private NetworkScore getNetworkScore() {
|
private int getNetworkScore() {
|
||||||
// never set the network score below 0.
|
// never set the network score below 0.
|
||||||
if (!mLinkUp) {
|
if (!mLinkUp) {
|
||||||
return NULL_SCORE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] transportTypes = mCapabilities.getTransportTypes();
|
int[] transportTypes = mCapabilities.getTransportTypes();
|
||||||
if (transportTypes.length < 1) {
|
if (transportTypes.length < 1) {
|
||||||
Log.w(TAG, "Network interface '" + mLinkProperties.getInterfaceName() + "' has no "
|
Log.w(TAG, "Network interface '" + mLinkProperties.getInterfaceName() + "' has no "
|
||||||
+ "transport type associated with it. Score set to zero");
|
+ "transport type associated with it. Score set to zero");
|
||||||
return NULL_SCORE;
|
return 0;
|
||||||
}
|
}
|
||||||
TransportInfo transportInfo = sTransports.get(transportTypes[0], /* if dne */ null);
|
TransportInfo transportInfo = sTransports.get(transportTypes[0], /* if dne */ null);
|
||||||
if (transportInfo != null) {
|
if (transportInfo != null) {
|
||||||
return new NetworkScore.Builder().setLegacyScore(transportInfo.mScore).build();
|
return transportInfo.mScore;
|
||||||
}
|
}
|
||||||
return NULL_SCORE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
@@ -467,7 +463,6 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
mLinkProperties = linkProperties;
|
mLinkProperties = linkProperties;
|
||||||
|
|
||||||
// Create our NetworkAgent.
|
// Create our NetworkAgent.
|
||||||
// STOPSHIP : use the new constructor for NetworkAgent that takes a NetworkScore
|
|
||||||
final NetworkAgentConfig config = new NetworkAgentConfig.Builder()
|
final NetworkAgentConfig config = new NetworkAgentConfig.Builder()
|
||||||
.setLegacyType(mLegacyType)
|
.setLegacyType(mLegacyType)
|
||||||
.setLegacyTypeName(NETWORK_TYPE)
|
.setLegacyTypeName(NETWORK_TYPE)
|
||||||
|
|||||||
Reference in New Issue
Block a user