Merge "introduce BpfClassic.h"
diff --git a/staticlibs/device/com/android/net/module/util/structs/IaPdOption.java b/staticlibs/device/com/android/net/module/util/structs/IaPdOption.java
index 5a09c40..dbf79dc 100644
--- a/staticlibs/device/com/android/net/module/util/structs/IaPdOption.java
+++ b/staticlibs/device/com/android/net/module/util/structs/IaPdOption.java
@@ -50,15 +50,15 @@
public static final int LENGTH = 12; // option length excluding IA_PD options
@Field(order = 0, type = Type.S16)
- public short code;
+ public final short code;
@Field(order = 1, type = Type.S16)
- public short length;
+ public final short length;
@Field(order = 2, type = Type.U32)
- public long id;
+ public final long id;
@Field(order = 3, type = Type.U32)
- public long t1;
+ public final long t1;
@Field(order = 4, type = Type.U32)
- public long t2;
+ public final long t2;
IaPdOption(final short code, final short length, final long id, final long t1,
final long t2) {
diff --git a/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java b/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
index 1ac21ff..cd974e6 100644
--- a/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
+++ b/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
@@ -55,17 +55,17 @@
public static final int LENGTH = 25; // option length excluding IAprefix-options
@Field(order = 0, type = Type.S16)
- public short code;
+ public final short code;
@Field(order = 1, type = Type.S16)
- public short length;
+ public final short length;
@Field(order = 2, type = Type.U32)
- public long preferred;
+ public final long preferred;
@Field(order = 3, type = Type.U32)
- public long valid;
+ public final long valid;
@Field(order = 4, type = Type.U8)
- public short prefixLen;
+ public final short prefixLen;
@Field(order = 5, type = Type.ByteArray, arraysize = 16)
- public byte[] prefix;
+ public final byte[] prefix;
IaPrefixOption(final short code, final short length, final long preferred,
final long valid, final short prefixLen, final byte[] prefix) {
diff --git a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitychecker/ConnectivityCheckTest.kt b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitychecker/ConnectivityCheckTest.kt
index f34ca22..f72938d 100644
--- a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitychecker/ConnectivityCheckTest.kt
+++ b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitychecker/ConnectivityCheckTest.kt
@@ -29,10 +29,10 @@
import com.android.testutils.RecorderCallback
import com.android.testutils.TestableNetworkCallback
import com.android.testutils.tryTest
-import org.junit.Test
-import org.junit.runner.RunWith
import kotlin.test.assertTrue
import kotlin.test.fail
+import org.junit.Test
+import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ConnectivityCheckTest {
@@ -76,7 +76,7 @@
.addTransportType(TRANSPORT_CELLULAR)
.addCapability(NET_CAPABILITY_INTERNET).build(), cb)
tryTest {
- cb.eventuallyExpectOrNull<RecorderCallback.CallbackEntry.Available>()
+ cb.poll { it is RecorderCallback.CallbackEntry.Available }
?: fail("The device does not have mobile data available. Check that it is " +
"setup with a SIM card that has a working data plan, and that the " +
"APN configuration is valid.")
@@ -84,4 +84,4 @@
cm.unregisterNetworkCallback(cb)
}
}
-}
\ No newline at end of file
+}
diff --git a/staticlibs/testutils/devicetests/com/android/testutils/ConnectUtil.kt b/staticlibs/testutils/devicetests/com/android/testutils/ConnectUtil.kt
index 7b5ad01..71f7877 100644
--- a/staticlibs/testutils/devicetests/com/android/testutils/ConnectUtil.kt
+++ b/staticlibs/testutils/devicetests/com/android/testutils/ConnectUtil.kt
@@ -32,6 +32,7 @@
import android.os.SystemClock
import android.util.Log
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
+import com.android.testutils.RecorderCallback.CallbackEntry
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import kotlin.test.assertNotNull
@@ -72,9 +73,7 @@
val config = getOrCreateWifiConfiguration()
connectToWifiConfig(config)
}
- val cb = callback.eventuallyExpectOrNull<RecorderCallback.CallbackEntry.Available>(
- timeoutMs = WIFI_CONNECT_TIMEOUT_MS)
-
+ val cb = callback.poll(WIFI_CONNECT_TIMEOUT_MS) { it is CallbackEntry.Available }
assertNotNull(cb, "Could not connect to a wifi access point within " +
"$WIFI_CONNECT_TIMEOUT_MS ms. Check that the test device has a wifi network " +
"configured, and that the test access point is functioning properly.")
@@ -201,4 +200,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
index 485799c..e7d86e0 100644
--- a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
+++ b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
@@ -220,7 +220,8 @@
* Long.MAX_VALUE.
*/
@JvmOverloads
- fun poll(timeoutMs: Long = defaultTimeoutMs): CallbackEntry? = history.poll(timeoutMs)
+ fun poll(timeoutMs: Long = defaultTimeoutMs, predicate: (CallbackEntry) -> Boolean = { true }) =
+ history.poll(timeoutMs, predicate)
/**
* Get the next callback or throw if timeout.
@@ -385,7 +386,7 @@
timeoutMs: Long = defaultTimeoutMs,
from: Int = mark,
crossinline predicate: (T) -> Boolean = { true }
- ): T = eventuallyExpectOrNull(timeoutMs, from, predicate).also {
+ ): T = history.poll(timeoutMs, from) { it is T && predicate(it) }.also {
assertNotNull(it, "Callback ${T::class} not received within ${timeoutMs}ms")
} as T
@@ -407,7 +408,7 @@
assertNotNull(it, "Callback ${type.java} not received within ${timeoutMs}ms")
} as T
- // TODO (b/157405399) straighten and unify the method names
+ // TODO (b/157405399) remove this method when there are no longer any uses of it.
inline fun <reified T : CallbackEntry> eventuallyExpectOrNull(
timeoutMs: Long = defaultTimeoutMs,
from: Int = mark,