Enlarge the TestableNetworkCallback default timeout

TestableNetworkCallback is using on both unit and cts tests with
same timeout 200ms. For unit tests, most of objects are mock, so
the callback should respond quickly and this interval is fine.
But for cts tests, they are running on the real system and the
callback time will depend on the system which may be over 200 ms
sometimes if the system is busy or has performance problems. So
enlarge the Network Callback default timeout to 500ms that can
reduce the test flake on cts tests. To ensure there is no impact
on no callback check, add the no callback timeout 200ms which is
the same timeout as before.

Bug: 245000567
Test: Run the FrameworksNetTests CtsNetTestCases and check
      no running time increase.
Change-Id: I31f8bc08f65a622f6ab9b6c7f0577f0b107440c1
diff --git a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
index dffdbe8..4407714 100644
--- a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
+++ b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
@@ -168,16 +168,22 @@
     }
 }
 
-private const val DEFAULT_TIMEOUT = 200L // ms
+private const val DEFAULT_TIMEOUT = 30_000L // ms
+private const val DEFAULT_NO_CALLBACK_TIMEOUT = 200L // ms
 
 open class TestableNetworkCallback private constructor(
     src: TestableNetworkCallback?,
-    val defaultTimeoutMs: Long = DEFAULT_TIMEOUT
+    val defaultTimeoutMs: Long = DEFAULT_TIMEOUT,
+    val defaultNoCallbackTimeoutMs: Long = DEFAULT_NO_CALLBACK_TIMEOUT
 ) : RecorderCallback(src) {
     @JvmOverloads
-    constructor(timeoutMs: Long = DEFAULT_TIMEOUT): this(null, timeoutMs)
+    constructor(
+        timeoutMs: Long = DEFAULT_TIMEOUT,
+        noCallbackTimeoutMs: Long = DEFAULT_NO_CALLBACK_TIMEOUT
+    ): this(null, timeoutMs, noCallbackTimeoutMs)
 
-    fun createLinkedCopy() = TestableNetworkCallback(this, defaultTimeoutMs)
+    fun createLinkedCopy() = TestableNetworkCallback(
+            this, defaultTimeoutMs, defaultNoCallbackTimeoutMs)
 
     // The last available network, or null if any network was lost since the last call to
     // onAvailable. TODO : fix this by fixing the tests that rely on this behavior
@@ -194,7 +200,7 @@
     // Make open for use in ConnectivityServiceTest which is the only one knowing its handlers.
     // TODO : remove the necessity to overload this, remove the open qualifier, and give a
     // default argument to assertNoCallback instead, possibly with @JvmOverloads if necessary.
-    open fun assertNoCallback() = assertNoCallback(defaultTimeoutMs)
+    open fun assertNoCallback() = assertNoCallback(defaultNoCallbackTimeoutMs)
 
     fun assertNoCallback(timeoutMs: Long) {
         val cb = history.poll(timeoutMs)
@@ -202,7 +208,7 @@
     }
 
     fun assertNoCallbackThat(
-        timeoutMs: Long = defaultTimeoutMs,
+        timeoutMs: Long = defaultNoCallbackTimeoutMs,
         valid: (CallbackEntry) -> Boolean
     ) {
         val cb = history.poll(timeoutMs) { valid(it) }.let {