diff --git a/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java b/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java index cf7a4f753e..f8e92f0766 100644 --- a/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java +++ b/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java @@ -650,9 +650,8 @@ public class BorderRoutingTest { public void nat64_threadDevicePingIpv4InfraDevice_outboundPacketIsForwarded() throws Exception { FullThreadDevice ftd = mFtds.get(0); joinNetworkAndWaitForOmr(ftd, DEFAULT_DATASET); - // TODO: enable NAT64 via ThreadNetworkController API instead of ot-ctl mOtCtl.setNat64Cidr(NAT64_CIDR); - mOtCtl.setNat64Enabled(true); + mController.setNat64EnabledAndWait(true); waitFor(() -> mOtCtl.hasNat64PrefixInNetdata(), UPDATE_NAT64_PREFIX_TIMEOUT); ftd.ping(IPV4_SERVER_ADDR); @@ -685,8 +684,7 @@ public class BorderRoutingTest { mInfraNetworkReader = newPacketReader(mInfraNetworkTracker.getTestIface(), mHandler); FullThreadDevice ftd = mFtds.get(0); joinNetworkAndWaitForOmr(ftd, DEFAULT_DATASET); - // TODO: enable NAT64 via ThreadNetworkController API instead of ot-ctl - mOtCtl.setNat64Enabled(true); + mController.setNat64EnabledAndWait(true); mOtCtl.addPrefixInNetworkData(DHCP6_PD_PREFIX, "paros", "med"); waitFor(() -> mOtCtl.hasNat64PrefixInNetdata(), UPDATE_NAT64_PREFIX_TIMEOUT); diff --git a/thread/tests/integration/src/android/net/thread/utils/ThreadNetworkControllerWrapper.java b/thread/tests/integration/src/android/net/thread/utils/ThreadNetworkControllerWrapper.java index 4a30c45da0..295acb8ff6 100644 --- a/thread/tests/integration/src/android/net/thread/utils/ThreadNetworkControllerWrapper.java +++ b/thread/tests/integration/src/android/net/thread/utils/ThreadNetworkControllerWrapper.java @@ -200,7 +200,7 @@ public final class ThreadNetworkControllerWrapper { runAsShell( PERMISSION_THREAD_NETWORK_PRIVILEGED, () -> mController.registerConfigurationCallback(directExecutor(), callback)); - future.get(CALLBACK_TIMEOUT.toSeconds(), SECONDS); + future.get(CONFIG_TIMEOUT.toSeconds(), SECONDS); runAsShell( PERMISSION_THREAD_NETWORK_PRIVILEGED, () -> mController.unregisterConfigurationCallback(callback)); @@ -214,7 +214,14 @@ public final class ThreadNetworkControllerWrapper { () -> mController.setConfiguration( config, directExecutor(), newOutcomeReceiver(future))); - future.get(CALLBACK_TIMEOUT.toSeconds(), SECONDS); + future.get(CONFIG_TIMEOUT.toSeconds(), SECONDS); + } + + public void setNat64EnabledAndWait(boolean enabled) throws Exception { + final ThreadConfiguration config = getConfiguration(); + final ThreadConfiguration newConfig = + new ThreadConfiguration.Builder().setNat64Enabled(enabled).build(); + setConfigurationAndWait(newConfig); } private static OutcomeReceiver newOutcomeReceiver(