Add the flag and default enable selectAllPrefixRange
Also add MtsTetheringTest which only run if tethering mainline module is installed. Bug: 166057846 Bug: 170265597 Test: atest TetheringTests Change-Id: I434dda81eb5fab700d873a8ff3429b4222f0c7e6
This commit is contained in:
@@ -80,11 +80,6 @@ public class PrivateAddressCoordinator {
|
||||
private final SparseArray<LinkAddress> mCachedAddresses;
|
||||
|
||||
public PrivateAddressCoordinator(Context context, TetheringConfiguration config) {
|
||||
this(context, config, new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16"))));
|
||||
}
|
||||
|
||||
public PrivateAddressCoordinator(Context context, TetheringConfiguration config,
|
||||
List<IpPrefix> prefixPools) {
|
||||
mDownstreams = new ArraySet<>();
|
||||
mUpstreamPrefixMap = new ArrayMap<>();
|
||||
mConnectivityMgr = (ConnectivityManager) context.getSystemService(
|
||||
@@ -95,7 +90,11 @@ public class PrivateAddressCoordinator {
|
||||
mCachedAddresses.put(TETHERING_BLUETOOTH, new LinkAddress(LEGACY_BLUETOOTH_IFACE_ADDRESS));
|
||||
mCachedAddresses.put(TETHERING_WIFI_P2P, new LinkAddress(LEGACY_WIFI_P2P_IFACE_ADDRESS));
|
||||
|
||||
mTetheringPrefixes = prefixPools;
|
||||
mTetheringPrefixes = new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16")));
|
||||
if (config.isSelectAllPrefixRangeEnabled()) {
|
||||
mTetheringPrefixes.add(new IpPrefix("172.16.0.0/12"));
|
||||
mTetheringPrefixes.add(new IpPrefix("10.0.0.0/8"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
|
||||
/**
|
||||
* A utility class to encapsulate the various tethering configuration elements.
|
||||
*
|
||||
@@ -87,6 +86,13 @@ public class TetheringConfiguration {
|
||||
public static final String USE_LEGACY_WIFI_P2P_DEDICATED_IP =
|
||||
"use_legacy_wifi_p2p_dedicated_ip";
|
||||
|
||||
/**
|
||||
* Flag use to enable select all prefix ranges feature.
|
||||
* TODO: Remove this flag if there are no problems after M-2020-12 rolls out.
|
||||
*/
|
||||
public static final String TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES =
|
||||
"tether_enable_select_all_prefix_ranges";
|
||||
|
||||
/**
|
||||
* Default value that used to periodic polls tether offload stats from tethering offload HAL
|
||||
* to make the data warnings work.
|
||||
@@ -118,6 +124,8 @@ public class TetheringConfiguration {
|
||||
private final boolean mEnableBpfOffload;
|
||||
private final boolean mEnableWifiP2pDedicatedIp;
|
||||
|
||||
private final boolean mEnableSelectAllPrefixRange;
|
||||
|
||||
public TetheringConfiguration(Context ctx, SharedLog log, int id) {
|
||||
final SharedLog configLog = log.forSubComponent("config");
|
||||
|
||||
@@ -164,6 +172,11 @@ public class TetheringConfiguration {
|
||||
R.bool.config_tether_enable_legacy_wifi_p2p_dedicated_ip,
|
||||
false /* defaultValue */);
|
||||
|
||||
// Flags should normally not be booleans, but this is a kill-switch flag that is only used
|
||||
// to turn off the feature, so binary rollback problems do not apply.
|
||||
mEnableSelectAllPrefixRange = getDeviceConfigBoolean(
|
||||
TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES, true /* defaultValue */);
|
||||
|
||||
configLog.log(toString());
|
||||
}
|
||||
|
||||
@@ -249,6 +262,9 @@ public class TetheringConfiguration {
|
||||
|
||||
pw.print("enableWifiP2pDedicatedIp: ");
|
||||
pw.println(mEnableWifiP2pDedicatedIp);
|
||||
|
||||
pw.print("mEnableSelectAllPrefixRange: ");
|
||||
pw.println(mEnableSelectAllPrefixRange);
|
||||
}
|
||||
|
||||
/** Returns the string representation of this object.*/
|
||||
@@ -310,6 +326,10 @@ public class TetheringConfiguration {
|
||||
return mEnableBpfOffload;
|
||||
}
|
||||
|
||||
public boolean isSelectAllPrefixRangeEnabled() {
|
||||
return mEnableSelectAllPrefixRange;
|
||||
}
|
||||
|
||||
private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) {
|
||||
final int[] ifaceTypes = res.getIntArray(R.array.config_tether_upstream_types);
|
||||
final ArrayList<Integer> upstreamIfaceTypes = new ArrayList<>(ifaceTypes.length);
|
||||
|
||||
Reference in New Issue
Block a user