[Thread] allow disabling border router auto-join
Test: verified that when the config is set to `false`, thread won't start up after reboots: ``` ➜ main-aosp-2 adb shell ot-ctl state leader Done ➜ main-aosp-2 adb reboot ➜ main-aosp-2 adb shell ot-ctl state /system/bin/sh: ot-ctl: inaccessible or not found ➜ main-aosp-2 adb root ➜ main-aosp-2 adb shell ot-ctl state disabled Done ``` Bug: 378587036 Change-Id: I4d1c90ab3121f39219cbaf795879a7ba91db02a3
This commit is contained in:
parent
7b7ff96c29
commit
d2fc66d4bb
4 changed files with 15 additions and 0 deletions
|
|
@ -79,4 +79,10 @@
|
|||
to the devices, or reaching to Thread end devices doesn't require border routing to work.
|
||||
-->
|
||||
<bool name="config_thread_srp_server_wait_for_border_routing_enabled">true</bool>
|
||||
|
||||
<!-- Whether this border router will automatically join the previous connected network after
|
||||
device reboots. Setting this value to false can allow the user to control the lifecycle of
|
||||
the Thread border router state on this device.
|
||||
-->
|
||||
<bool name="config_thread_border_router_auto_join_enabled">true</bool>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
<item type="string" name="config_thread_model_name" />
|
||||
<item type="array" name="config_thread_mdns_vendor_specific_txts" />
|
||||
<item type="bool" name="config_thread_srp_server_wait_for_border_routing_enabled" />
|
||||
<item type="bool" name="config_thread_border_router_auto_join_enabled" />
|
||||
</policy>
|
||||
</overlayable>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -626,11 +626,14 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
|
|||
private OtDaemonConfiguration newOtDaemonConfig(ThreadConfiguration threadConfig) {
|
||||
int srpServerConfig = R.bool.config_thread_srp_server_wait_for_border_routing_enabled;
|
||||
boolean srpServerWaitEnabled = mResources.get().getBoolean(srpServerConfig);
|
||||
int autoJoinConfig = R.bool.config_thread_border_router_auto_join_enabled;
|
||||
boolean autoJoinEnabled = mResources.get().getBoolean(autoJoinConfig);
|
||||
return new OtDaemonConfiguration.Builder()
|
||||
.setBorderRouterEnabled(threadConfig.isBorderRouterEnabled())
|
||||
.setNat64Enabled(threadConfig.isNat64Enabled())
|
||||
.setDhcpv6PdEnabled(threadConfig.isDhcpv6PdEnabled())
|
||||
.setSrpServerWaitForBorderRoutingEnabled(srpServerWaitEnabled)
|
||||
.setBorderRouterAutoJoinEnabled(autoJoinEnabled)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,6 +234,8 @@ public final class ThreadNetworkControllerServiceTest {
|
|||
when(mResources.getBoolean(
|
||||
eq(R.bool.config_thread_srp_server_wait_for_border_routing_enabled)))
|
||||
.thenReturn(true);
|
||||
when(mResources.getBoolean(eq(R.bool.config_thread_border_router_auto_join_enabled)))
|
||||
.thenReturn(true);
|
||||
when(mResources.getString(eq(R.string.config_thread_vendor_name)))
|
||||
.thenReturn(TEST_VENDOR_NAME);
|
||||
when(mResources.getString(eq(R.string.config_thread_vendor_oui)))
|
||||
|
|
@ -291,6 +293,8 @@ public final class ThreadNetworkControllerServiceTest {
|
|||
when(mResources.getBoolean(
|
||||
eq(R.bool.config_thread_srp_server_wait_for_border_routing_enabled)))
|
||||
.thenReturn(false);
|
||||
when(mResources.getBoolean(eq(R.bool.config_thread_border_router_auto_join_enabled)))
|
||||
.thenReturn(false);
|
||||
when(mResources.getString(eq(R.string.config_thread_vendor_name)))
|
||||
.thenReturn(TEST_VENDOR_NAME);
|
||||
when(mResources.getString(eq(R.string.config_thread_vendor_oui)))
|
||||
|
|
@ -304,6 +308,7 @@ public final class ThreadNetworkControllerServiceTest {
|
|||
mTestLooper.dispatchAll();
|
||||
|
||||
assertThat(mFakeOtDaemon.getConfiguration().srpServerWaitForBorderRoutingEnabled).isFalse();
|
||||
assertThat(mFakeOtDaemon.getConfiguration().borderRouterAutoJoinEnabled).isFalse();
|
||||
MeshcopTxtAttributes meshcopTxts = mFakeOtDaemon.getOverriddenMeshcopTxtAttributes();
|
||||
assertThat(meshcopTxts.vendorName).isEqualTo(TEST_VENDOR_NAME);
|
||||
assertThat(meshcopTxts.vendorOui).isEqualTo(TEST_VENDOR_OUI_BYTES);
|
||||
|
|
|
|||
Loading…
Reference in a new issue