Do not run diagnostics on assumption failures

Assumption failures are not actual failures, do not run connectivity
diagnostics for these.

Test: atest
Change-Id: I1d78eb6f12412e13cf4c29718ff8869ed089f491
diff --git a/staticlibs/testutils/devicetests/com/android/testutils/ConnectivityDiagnosticsCollector.kt b/staticlibs/testutils/devicetests/com/android/testutils/ConnectivityDiagnosticsCollector.kt
index 80bb99b..f5a5b4d 100644
--- a/staticlibs/testutils/devicetests/com/android/testutils/ConnectivityDiagnosticsCollector.kt
+++ b/staticlibs/testutils/devicetests/com/android/testutils/ConnectivityDiagnosticsCollector.kt
@@ -27,6 +27,7 @@
 import java.io.PrintWriter
 import java.time.ZonedDateTime
 import kotlin.test.assertNull
+import org.junit.AssumptionViolatedException
 import org.junit.runner.Description
 import org.junit.runner.notification.Failure
 
@@ -61,7 +62,9 @@
         assertNull(instance, "ConnectivityDiagnosticsCollectors were set up multiple times")
         instance = this
         TryTestConfig.setDiagnosticsCollector { throwable ->
-            collectTestFailureDiagnostics(throwable)
+            if (runOnFailure(throwable)) {
+                collectTestFailureDiagnostics(throwable)
+            }
         }
     }
 
@@ -72,7 +75,7 @@
     override fun onTestFail(testData: DataRecord, description: Description, failure: Failure) {
         // TODO: find a way to disable this behavior only on local runs, to avoid slowing them down
         // when iterating on failing tests.
-        if (!runOnFailure()) return
+        if (!runOnFailure(failure.exception)) return
         if (outputFiles.size >= MAX_DUMPS) return
         Log.i(TAG, "Collecting diagnostics for test failure. Disable by running tests with: " +
                 "atest MyModule -- " +
@@ -96,7 +99,10 @@
         flushBufferToFileMetric(testData, baseFilename)
     }
 
-    private fun runOnFailure(): Boolean {
+    private fun runOnFailure(exception: Throwable): Boolean {
+        // Assumption failures (assumeTrue/assumeFalse) are not actual failures
+        if (exception is AssumptionViolatedException) return false
+
         // Do not run on local builds (which have ro.build.version.incremental set to eng.username)
         // to avoid slowing down local runs.
         val enabledByDefault = !Build.VERSION.INCREMENTAL.startsWith("eng.")