From 3556c3d7b1b509b25042975d5dcf8eb4cfc3b76c Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Wed, 21 May 2025 14:12:31 -0700 Subject: [PATCH] Ensure requestTetheredInterface() is processed before proceeding requestTetheredInterface() only returns a callback if an interface for tethering is available. The previous code timed out after 500ms which was not enough for some devices. Instead of increasing the timeout, this change calls setEthernetEnabled() which triggers a callback as soon as it was processed on the handler thread. Since this event is guaranteed to be processed after requestTetheredInterface(), the subsequent expectOnAvailable() does not have to wait at all. Test: TH Flag: EXEMPT test Bug: 418151132 Change-Id: Iff119a8e425d4071bf63fe92815061c7eb36848a --- tests/cts/net/src/android/net/cts/EthernetManagerTest.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt index a2d58ebf60..2e5ea8b1dd 100644 --- a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt +++ b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt @@ -618,7 +618,12 @@ class EthernetManagerTest { // see aosp/2123900. try { // assumeException does not exist. - requestTetheredInterface().expectOnAvailable(NO_CALLBACK_TIMEOUT_MS) + val listener = requestTetheredInterface() + // Force requestTetheredInterface() to be processed before proceeding by calling + // setEthernetEnabled() which always waits on a callback and is guaranteed to be + // processed after requestTetheredInterface(). + setEthernetEnabled(ethernetEnabled) + listener.expectOnAvailable(0) // interface used for tethering is available, throw an assumption error. assumeTrue(false) } catch (e: TimeoutException) {