Fix issues reported by checkstyle
Test: builds
Change-Id: I41979cc8096a682c6844df0825ee56ab00a828b5
diff --git a/staticlibs/devicetests/com/android/testutils/HandlerUtils.kt b/staticlibs/devicetests/com/android/testutils/HandlerUtils.kt
index fa36209..336e12c 100644
--- a/staticlibs/devicetests/com/android/testutils/HandlerUtils.kt
+++ b/staticlibs/devicetests/com/android/testutils/HandlerUtils.kt
@@ -20,7 +20,6 @@
import android.os.Handler
import android.os.HandlerThread
import java.util.concurrent.Executor
-import kotlin.system.measureTimeMillis
import kotlin.test.fail
/**
diff --git a/staticlibs/devicetests/com/android/testutils/TapPacketReader.java b/staticlibs/devicetests/com/android/testutils/TapPacketReader.java
index fea1cd9..c36f144 100644
--- a/staticlibs/devicetests/com/android/testutils/TapPacketReader.java
+++ b/staticlibs/devicetests/com/android/testutils/TapPacketReader.java
@@ -34,6 +34,11 @@
import kotlin.Lazy;
import kotlin.LazyKt;
+/**
+ * A packet reader that runs on a TAP interface.
+ *
+ * It also implements facilities to reply to received packets.
+ */
public class TapPacketReader extends PacketReader {
private final FileDescriptor mTapFd;
private final ArrayTrackRecord<byte[]> mReceivedPackets = new ArrayTrackRecord<>();
@@ -82,6 +87,14 @@
return mReceivedPackets;
}
+ /*
+ * Send a response on the TAP interface.
+ *
+ * The passed ByteBuffer is flipped after use.
+ *
+ * @param packet The packet to send.
+ * @throws IOException if the interface can't be written to.
+ */
public void sendResponse(final ByteBuffer packet) throws IOException {
try (FileOutputStream out = new FileOutputStream(mTapFd)) {
byte[] packetBytes = new byte[packet.limit()];
diff --git a/staticlibs/hostdevice/com/android/testutils/ExceptionUtils.java b/staticlibs/hostdevice/com/android/testutils/ExceptionUtils.java
index e7dbed5..d3bda98 100644
--- a/staticlibs/hostdevice/com/android/testutils/ExceptionUtils.java
+++ b/staticlibs/hostdevice/com/android/testutils/ExceptionUtils.java
@@ -18,6 +18,9 @@
import java.util.function.Supplier;
+/**
+ * A class grouping some utilities to deal with exceptions.
+ */
public class ExceptionUtils {
/**
* Like a Consumer, but declared to throw an exception.
@@ -25,6 +28,7 @@
*/
@FunctionalInterface
public interface ThrowingConsumer<T> {
+ /** @see java.util.function.Consumer */
void accept(T t) throws Exception;
}
@@ -34,6 +38,7 @@
*/
@FunctionalInterface
public interface ThrowingSupplier<T> {
+ /** @see java.util.function.Supplier */
T get() throws Exception;
}
@@ -42,10 +47,15 @@
*/
@FunctionalInterface
public interface ThrowingRunnable {
+ /** @see java.lang.Runnable */
void run() throws Exception;
}
-
+ /**
+ * Convert a supplier that throws into one that doesn't.
+ *
+ * The returned supplier returns null in cases where the source throws.
+ */
public static <T> Supplier<T> ignoreExceptions(ThrowingSupplier<T> func) {
return () -> {
try {
@@ -56,6 +66,11 @@
};
}
+ /**
+ * Convert a runnable that throws into one that doesn't.
+ *
+ * All exceptions are ignored by the returned Runnable.
+ */
public static Runnable ignoreExceptions(ThrowingRunnable r) {
return () -> {
try {
diff --git a/staticlibs/hostdevice/com/android/testutils/MiscAsserts.kt b/staticlibs/hostdevice/com/android/testutils/MiscAsserts.kt
index 32c22c2..4e86360 100644
--- a/staticlibs/hostdevice/com/android/testutils/MiscAsserts.kt
+++ b/staticlibs/hostdevice/com/android/testutils/MiscAsserts.kt
@@ -34,7 +34,7 @@
assertEquals(expected, len, "Expected array of length $expected, but was $len for $got")
}
-// Bridge method to help write this in Java. If you're writing Kotlin, consider using native
+// Bridge method to help write this in Java. If you're writing Kotlin, consider using
// kotlin.test.assertFailsWith instead, as that method is reified and inlined.
fun <T : Exception> assertThrows(expected: Class<T>, block: ThrowingRunnable): T {
return assertFailsWith(expected.kotlin) { block.run() }