Add logs in IntegrationTestUtils.kt for service discovery

Bug: 338061061
Change-Id: I17f52e7272c42c3a347e32b89d9d0a64edabcd4e
This commit is contained in:
Yang Sun 2025-01-02 16:08:07 +08:00
commit be81b8415c

View file

@ -39,6 +39,7 @@ import android.os.Handler
import android.os.SystemClock
import android.system.OsConstants
import android.system.OsConstants.IPPROTO_ICMP
import android.util.Log
import androidx.test.core.app.ApplicationProvider
import com.android.compatibility.common.util.SystemUtil.runShellCommandOrThrow
import com.android.net.module.util.IpUtils
@ -84,6 +85,8 @@ import org.junit.Assert
/** Utilities for Thread integration tests. */
object IntegrationTestUtils {
private val TAG = IntegrationTestUtils::class.simpleName
// The timeout of join() after restarting ot-daemon. The device needs to send 6 Link Request
// every 5 seconds, followed by 4 Parent Request every second. So this value needs to be 40
// seconds to be safe
@ -483,6 +486,7 @@ object IntegrationTestUtils {
val serviceInfoFuture = CompletableFuture<NsdServiceInfo>()
val listener: NsdManager.DiscoveryListener = object : DefaultDiscoveryListener() {
override fun onServiceFound(serviceInfo: NsdServiceInfo) {
Log.d(TAG, "onServiceFound: $serviceInfo")
serviceInfoFuture.complete(serviceInfo)
}
}
@ -530,6 +534,7 @@ object IntegrationTestUtils {
val resolvedServiceInfoFuture = CompletableFuture<NsdServiceInfo>()
val callback: NsdManager.ServiceInfoCallback = object : DefaultServiceInfoCallback() {
override fun onServiceUpdated(serviceInfo: NsdServiceInfo) {
Log.d(TAG, "onServiceUpdated: $serviceInfo")
if (predicate.test(serviceInfo)) {
resolvedServiceInfoFuture.complete(serviceInfo)
}