Update comments and documentation in net type prop change
Bug: b/112588045
Test: atest EthernetServiceTests --verbose
Test: kitchensink, dumpsys ethernet, with RPi devices and USB to
ethernet adapters.
Change-Id: Iaa260aabbbd7aa4b7864eba32ecff7e3f84123c3
This commit is contained in:
@@ -44,6 +44,7 @@ import android.os.ConditionVariable;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -71,6 +72,12 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
private final Handler mHandler;
|
||||
private final Context mContext;
|
||||
|
||||
public static class ConfigurationException extends AndroidRuntimeException {
|
||||
public ConfigurationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public EthernetNetworkFactory(Handler handler, Context context, NetworkCapabilities filter) {
|
||||
super(handler.getLooper(), context, NETWORK_TYPE, filter);
|
||||
|
||||
@@ -358,8 +365,8 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
legacyType = getLegacyType(transportTypes[0]);
|
||||
} else {
|
||||
// Should never happen as transport is always one of ETHERNET or a valid override
|
||||
Log.w(TAG, "There is no transport type associated with network interface '"
|
||||
+ mLinkProperties.getInterfaceName() + "' -- Legacy type set to TYPE_NONE");
|
||||
throw new ConfigurationException("Network Capabilities do not have an associated "
|
||||
+ "transport type.");
|
||||
}
|
||||
|
||||
mHwAddress = hwAddress;
|
||||
@@ -410,8 +417,8 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
|
||||
int[] transportTypes = mCapabilities.getTransportTypes();
|
||||
if (transportTypes.length < 1) {
|
||||
Log.w(TAG, "There is no transport type associated with network interface '"
|
||||
+ mLinkProperties.getInterfaceName() + "' -- Score set to zero");
|
||||
Log.w(TAG, "Network interface '" + mLinkProperties.getInterfaceName() + "' has no "
|
||||
+ "transport type associated with it. Score set to zero");
|
||||
return 0;
|
||||
}
|
||||
TransportInfo transportInfo = sTransports.get(transportTypes[0], /* if dne */ null);
|
||||
@@ -532,7 +539,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
mNetworkAgent.sendLinkProperties(mLinkProperties);
|
||||
|
||||
// As a note, getNetworkScore() is fairly expensive to calculate. This is fine for now
|
||||
// since the agent isn't update frequently. Consider caching the score in the future if
|
||||
// since the agent isn't updated frequently. Consider caching the score in the future if
|
||||
// agent updating is required more often
|
||||
mNetworkAgent.sendNetworkScore(getNetworkScore());
|
||||
}
|
||||
|
||||
@@ -337,10 +337,10 @@ final class EthernetTracker {
|
||||
* @param clearDefaultCapabilities Indicates whether or not to clear any default capabilities
|
||||
* @param commaSeparatedCapabilities A comma separated string list of integer encoded
|
||||
* NetworkCapability.NET_CAPABILITY_* values
|
||||
* @param overrideTransport A string representing a single override transport type, must be one
|
||||
* of the NetworkCapability.TRANSPORT_* values. TRANSPORT_VPN is
|
||||
* not supported. Errors with input will cause the override to
|
||||
* be ignored.
|
||||
* @param overrideTransport A string representing a single integer encoded override transport
|
||||
* type. Must be one of the NetworkCapability.TRANSPORT_*
|
||||
* values. TRANSPORT_VPN is not supported. Errors with input
|
||||
* will cause the override to be ignored.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static NetworkCapabilities createNetworkCapabilities(
|
||||
@@ -363,14 +363,14 @@ final class EthernetTracker {
|
||||
if (parsedTransport == NetworkCapabilities.TRANSPORT_VPN
|
||||
|| parsedTransport == NetworkCapabilities.TRANSPORT_WIFI_AWARE
|
||||
|| parsedTransport == NetworkCapabilities.TRANSPORT_LOWPAN) {
|
||||
Log.e(TAG, "Override transport '" + parsedTransport + "' is not supported -- "
|
||||
Log.e(TAG, "Override transport '" + parsedTransport + "' is not supported. "
|
||||
+ "Defaulting to TRANSPORT_ETHERNET");
|
||||
} else {
|
||||
transport = parsedTransport;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
Log.e(TAG, "Override transport type '" + overrideTransport + "' could not be parsed"
|
||||
+ "-- Defaulting to TRANSPORT_ETHERNET");
|
||||
Log.e(TAG, "Override transport type '" + overrideTransport + "' "
|
||||
+ "could not be parsed. Defaulting to TRANSPORT_ETHERNET");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,8 +379,8 @@ final class EthernetTracker {
|
||||
try {
|
||||
nc.addTransportType(transport);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Log.e(TAG, transport + " is not a valid NetworkCapability.TRANSPORT_* value"
|
||||
+ " -- Defaulting to TRANSPORT_ETHERNET");
|
||||
Log.e(TAG, transport + " is not a valid NetworkCapability.TRANSPORT_* value. "
|
||||
+ "Defaulting to TRANSPORT_ETHERNET");
|
||||
nc.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user