[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 translatable="false" name="config_tether_dhcp_range">
|
||||||
</string-array>
|
</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,
|
<!-- Array of ConnectivityManager.TYPE_{BLUETOOTH, ETHERNET, MOBILE, MOBILE_DUN, MOBILE_HIPRI,
|
||||||
WIFI} values allowable for tethering.
|
WIFI} values allowable for tethering.
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<item type="array" name="config_tether_bluetooth_regexs"/>
|
<item type="array" name="config_tether_bluetooth_regexs"/>
|
||||||
<item type="array" name="config_tether_dhcp_range"/>
|
<item type="array" name="config_tether_dhcp_range"/>
|
||||||
<item type="bool" name="config_tether_enable_legacy_dhcp_server"/>
|
<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="array" name="config_tether_upstream_types"/>
|
||||||
<item type="bool" name="config_tether_upstream_automatic"/>
|
<item type="bool" name="config_tether_upstream_automatic"/>
|
||||||
<!-- Configuration values for tethering entitlement check -->
|
<!-- Configuration values for tethering entitlement check -->
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ public class TetheringConfiguration {
|
|||||||
public static final String TETHER_ENABLE_LEGACY_DHCP_SERVER =
|
public static final String TETHER_ENABLE_LEGACY_DHCP_SERVER =
|
||||||
"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[] tetherableUsbRegexs;
|
||||||
public final String[] tetherableWifiRegexs;
|
public final String[] tetherableWifiRegexs;
|
||||||
public final String[] tetherableWifiP2pRegexs;
|
public final String[] tetherableWifiP2pRegexs;
|
||||||
@@ -96,6 +102,8 @@ public class TetheringConfiguration {
|
|||||||
|
|
||||||
public final int activeDataSubId;
|
public final int activeDataSubId;
|
||||||
|
|
||||||
|
private final int mOffloadPollInterval;
|
||||||
|
|
||||||
public TetheringConfiguration(Context ctx, SharedLog log, int id) {
|
public TetheringConfiguration(Context ctx, SharedLog log, int id) {
|
||||||
final SharedLog configLog = log.forSubComponent("config");
|
final SharedLog configLog = log.forSubComponent("config");
|
||||||
|
|
||||||
@@ -129,6 +137,10 @@ public class TetheringConfiguration {
|
|||||||
R.integer.config_mobile_hotspot_provision_check_period,
|
R.integer.config_mobile_hotspot_provision_check_period,
|
||||||
0 /* No periodic re-check */);
|
0 /* No periodic re-check */);
|
||||||
|
|
||||||
|
mOffloadPollInterval = getResourceInteger(res,
|
||||||
|
R.integer.config_tether_offload_poll_interval,
|
||||||
|
DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS);
|
||||||
|
|
||||||
configLog.log(toString());
|
configLog.log(toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +201,9 @@ public class TetheringConfiguration {
|
|||||||
dumpStringArray(pw, "legacyDhcpRanges", legacyDhcpRanges);
|
dumpStringArray(pw, "legacyDhcpRanges", legacyDhcpRanges);
|
||||||
dumpStringArray(pw, "defaultIPv4DNS", defaultIPv4DNS);
|
dumpStringArray(pw, "defaultIPv4DNS", defaultIPv4DNS);
|
||||||
|
|
||||||
|
pw.print("offloadPollInterval: ");
|
||||||
|
pw.println(mOffloadPollInterval);
|
||||||
|
|
||||||
dumpStringArray(pw, "provisioningApp", provisioningApp);
|
dumpStringArray(pw, "provisioningApp", provisioningApp);
|
||||||
pw.print("provisioningAppNoUi: ");
|
pw.print("provisioningAppNoUi: ");
|
||||||
pw.println(provisioningAppNoUi);
|
pw.println(provisioningAppNoUi);
|
||||||
@@ -208,6 +223,7 @@ public class TetheringConfiguration {
|
|||||||
makeString(tetherableBluetoothRegexs)));
|
makeString(tetherableBluetoothRegexs)));
|
||||||
sj.add(String.format("isDunRequired:%s", isDunRequired));
|
sj.add(String.format("isDunRequired:%s", isDunRequired));
|
||||||
sj.add(String.format("chooseUpstreamAutomatically:%s", chooseUpstreamAutomatically));
|
sj.add(String.format("chooseUpstreamAutomatically:%s", chooseUpstreamAutomatically));
|
||||||
|
sj.add(String.format("offloadPollInterval:%d", mOffloadPollInterval));
|
||||||
sj.add(String.format("preferredUpstreamIfaceTypes:%s",
|
sj.add(String.format("preferredUpstreamIfaceTypes:%s",
|
||||||
toIntArray(preferredUpstreamIfaceTypes)));
|
toIntArray(preferredUpstreamIfaceTypes)));
|
||||||
sj.add(String.format("provisioningApp:%s", makeString(provisioningApp)));
|
sj.add(String.format("provisioningApp:%s", makeString(provisioningApp)));
|
||||||
@@ -246,6 +262,10 @@ public class TetheringConfiguration {
|
|||||||
return (tm != null) ? tm.isTetheringApnRequired() : false;
|
return (tm != null) ? tm.isTetheringApnRequired() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOffloadPollInterval() {
|
||||||
|
return mOffloadPollInterval;
|
||||||
|
}
|
||||||
|
|
||||||
private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) {
|
private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) {
|
||||||
final int[] ifaceTypes = res.getIntArray(R.array.config_tether_upstream_types);
|
final int[] ifaceTypes = res.getIntArray(R.array.config_tether_upstream_types);
|
||||||
final ArrayList<Integer> upstreamIfaceTypes = new ArrayList<>(ifaceTypes.length);
|
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(
|
when(mResources.getStringArray(R.array.config_tether_dhcp_range)).thenReturn(
|
||||||
new String[0]);
|
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_usb_regexs)).thenReturn(new String[0]);
|
||||||
when(mResources.getStringArray(R.array.config_tether_wifi_regexs))
|
when(mResources.getStringArray(R.array.config_tether_wifi_regexs))
|
||||||
.thenReturn(new String[]{ "test_wlan\\d" });
|
.thenReturn(new String[]{ "test_wlan\\d" });
|
||||||
@@ -313,6 +315,23 @@ public class TetheringConfigurationTest {
|
|||||||
assertFalse(cfg.enableLegacyDhcpServer);
|
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
|
@Test
|
||||||
public void testGetResourcesBySubId() {
|
public void testGetResourcesBySubId() {
|
||||||
setUpResourceForSubId();
|
setUpResourceForSubId();
|
||||||
|
|||||||
Reference in New Issue
Block a user