[SP18.5] Create offload controller poll interval to resource
Test: atest TetheringConfigurationTest Bug: 149467454 Change-Id: I8b4ad920a4945504914d3741a9fba5c096fbf452 Merged-In: I8b4ad920a4945504914d3741a9fba5c096fbf452 (cherry-picked from aosp/1299413)
This commit is contained in:
@@ -64,6 +64,13 @@
|
||||
<string-array translatable="false" name="config_tether_dhcp_range">
|
||||
</string-array>
|
||||
|
||||
<!-- Used to config periodic polls tether offload stats from tethering offload HAL to make the
|
||||
data warnings work. 5000(ms) by default. If the device doesn't want to poll tether
|
||||
offload stats, this should be -1. Note that this setting could be override by
|
||||
runtime resource overlays.
|
||||
-->
|
||||
<integer translatable="false" name="config_tether_offload_poll_interval">5000</integer>
|
||||
|
||||
<!-- Array of ConnectivityManager.TYPE_{BLUETOOTH, ETHERNET, MOBILE, MOBILE_DUN, MOBILE_HIPRI,
|
||||
WIFI} values allowable for tethering.
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<item type="array" name="config_tether_bluetooth_regexs"/>
|
||||
<item type="array" name="config_tether_dhcp_range"/>
|
||||
<item type="bool" name="config_tether_enable_legacy_dhcp_server"/>
|
||||
<item type="integer" name="config_tether_offload_poll_interval"/>
|
||||
<item type="array" name="config_tether_upstream_types"/>
|
||||
<item type="bool" name="config_tether_upstream_automatic"/>
|
||||
<!-- Configuration values for tethering entitlement check -->
|
||||
|
||||
@@ -78,6 +78,12 @@ public class TetheringConfiguration {
|
||||
public static final String TETHER_ENABLE_LEGACY_DHCP_SERVER =
|
||||
"tether_enable_legacy_dhcp_server";
|
||||
|
||||
/**
|
||||
* Default value that used to periodic polls tether offload stats from tethering offload HAL
|
||||
* to make the data warnings work.
|
||||
*/
|
||||
public static final int DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS = 5000;
|
||||
|
||||
public final String[] tetherableUsbRegexs;
|
||||
public final String[] tetherableWifiRegexs;
|
||||
public final String[] tetherableWifiP2pRegexs;
|
||||
@@ -96,6 +102,8 @@ public class TetheringConfiguration {
|
||||
|
||||
public final int activeDataSubId;
|
||||
|
||||
private final int mOffloadPollInterval;
|
||||
|
||||
public TetheringConfiguration(Context ctx, SharedLog log, int id) {
|
||||
final SharedLog configLog = log.forSubComponent("config");
|
||||
|
||||
@@ -129,6 +137,10 @@ public class TetheringConfiguration {
|
||||
R.integer.config_mobile_hotspot_provision_check_period,
|
||||
0 /* No periodic re-check */);
|
||||
|
||||
mOffloadPollInterval = getResourceInteger(res,
|
||||
R.integer.config_tether_offload_poll_interval,
|
||||
DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS);
|
||||
|
||||
configLog.log(toString());
|
||||
}
|
||||
|
||||
@@ -189,6 +201,9 @@ public class TetheringConfiguration {
|
||||
dumpStringArray(pw, "legacyDhcpRanges", legacyDhcpRanges);
|
||||
dumpStringArray(pw, "defaultIPv4DNS", defaultIPv4DNS);
|
||||
|
||||
pw.print("offloadPollInterval: ");
|
||||
pw.println(mOffloadPollInterval);
|
||||
|
||||
dumpStringArray(pw, "provisioningApp", provisioningApp);
|
||||
pw.print("provisioningAppNoUi: ");
|
||||
pw.println(provisioningAppNoUi);
|
||||
@@ -208,6 +223,7 @@ public class TetheringConfiguration {
|
||||
makeString(tetherableBluetoothRegexs)));
|
||||
sj.add(String.format("isDunRequired:%s", isDunRequired));
|
||||
sj.add(String.format("chooseUpstreamAutomatically:%s", chooseUpstreamAutomatically));
|
||||
sj.add(String.format("offloadPollInterval:%d", mOffloadPollInterval));
|
||||
sj.add(String.format("preferredUpstreamIfaceTypes:%s",
|
||||
toIntArray(preferredUpstreamIfaceTypes)));
|
||||
sj.add(String.format("provisioningApp:%s", makeString(provisioningApp)));
|
||||
@@ -246,6 +262,10 @@ public class TetheringConfiguration {
|
||||
return (tm != null) ? tm.isTetheringApnRequired() : false;
|
||||
}
|
||||
|
||||
public int getOffloadPollInterval() {
|
||||
return mOffloadPollInterval;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -115,6 +115,8 @@ public class TetheringConfigurationTest {
|
||||
|
||||
when(mResources.getStringArray(R.array.config_tether_dhcp_range)).thenReturn(
|
||||
new String[0]);
|
||||
when(mResources.getInteger(R.integer.config_tether_offload_poll_interval)).thenReturn(
|
||||
TetheringConfiguration.DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS);
|
||||
when(mResources.getStringArray(R.array.config_tether_usb_regexs)).thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(R.array.config_tether_wifi_regexs))
|
||||
.thenReturn(new String[]{ "test_wlan\\d" });
|
||||
@@ -313,6 +315,23 @@ public class TetheringConfigurationTest {
|
||||
assertFalse(cfg.enableLegacyDhcpServer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOffloadIntervalByResource() {
|
||||
final TetheringConfiguration intervalByDefault =
|
||||
new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
assertEquals(TetheringConfiguration.DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS,
|
||||
intervalByDefault.getOffloadPollInterval());
|
||||
|
||||
final int[] testOverrides = {0, 3000, -1};
|
||||
for (final int override : testOverrides) {
|
||||
when(mResources.getInteger(R.integer.config_tether_offload_poll_interval)).thenReturn(
|
||||
override);
|
||||
final TetheringConfiguration overrideByRes =
|
||||
new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
|
||||
assertEquals(override, overrideByRes.getOffloadPollInterval());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetResourcesBySubId() {
|
||||
setUpResourceForSubId();
|
||||
|
||||
Reference in New Issue
Block a user