Filter some Safety Center host-side tests to U+

Bug: 289978570
Bug: 290817333
Bug: 290844749
Bug: 290845409
Relnote: N/A
Test: atest SafetyCenterInteractionLoggingHostTest
Change-Id: Ia6c26996f2286b68e85d286ca6d4500d90435dd2
diff --git a/tests/hostside/safetycenter/Android.bp b/tests/hostside/safetycenter/Android.bp
index 499e44f..c66cae2 100644
--- a/tests/hostside/safetycenter/Android.bp
+++ b/tests/hostside/safetycenter/Android.bp
@@ -27,6 +27,7 @@
     libs: [
         "tradefed",
         "junit",
+        "compatibility-host-util",
     ],
     static_libs: [
         "cts-statsd-atom-host-test-utils",
diff --git a/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterInteractionLoggingHostTest.kt b/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterInteractionLoggingHostTest.kt
index 57231ba..43884d7 100644
--- a/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterInteractionLoggingHostTest.kt
+++ b/tests/hostside/safetycenter/src/android/safetycenter/hostside/SafetyCenterInteractionLoggingHostTest.kt
@@ -27,6 +27,9 @@
 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner
 import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test
 import com.google.common.truth.Truth.assertThat
+import com.android.compatibility.common.util.ApiLevelUtil
+import org.junit.Assume.assumeTrue
+
 import org.junit.After
 import org.junit.Before
 import org.junit.Ignore
@@ -71,6 +74,8 @@
 
     @Test
     fun sendNotification_recordsNotificationPostedEvent() {
+        assumeAtLeastUpsideDownCake("Safety Center notification APIs require Android U+")
+
         helperAppRule.runTest(
             testClassName = ".SafetyCenterNotificationLoggingHelperTests",
             testMethodName = "sendNotification"
@@ -85,6 +90,8 @@
 
     @Test
     fun openSubpageFromIntentExtra_recordsEventWithUnknownNavigationSource() {
+        assumeAtLeastUpsideDownCake("Safety Center subpages require Android U+")
+
         helperAppRule.runTest(TEST_CLASS_NAME, testMethodName = "openSubpageFromIntentExtra")
 
         val safetyCenterViewedAtoms = getInteractionReportedAtoms(Action.SAFETY_CENTER_VIEWED)
@@ -102,6 +109,8 @@
     @Ignore
     // TODO(b/278202773): Fix/de-flake this test
     fun openSubpageFromHomepage_recordsEventWithSafetyCenterNavigationSource() {
+        assumeAtLeastUpsideDownCake("Safety Center subpages require Android U+")
+
         helperAppRule.runTest(TEST_CLASS_NAME, testMethodName = "openSubpageFromHomepage")
 
         val safetyCenterViewedAtoms = getInteractionReportedAtoms(Action.SAFETY_CENTER_VIEWED)
@@ -118,6 +127,8 @@
     @Ignore
     // TODO(b/278202773): Fix/de-flake this test
     fun openSubpageFromSettingsSearch_recordsEventWithSettingsNavigationSource() {
+        assumeAtLeastUpsideDownCake("Safety Center subpages require Android U+")
+
         helperAppRule.runTest(TEST_CLASS_NAME, testMethodName = "openSubpageFromSettingsSearch")
 
         val safetyCenterViewedAtoms = getInteractionReportedAtoms(Action.SAFETY_CENTER_VIEWED)
@@ -138,6 +149,10 @@
             .mapNotNull { it.atom.safetyCenterInteractionReported }
             .filter { it.action == action }
 
+    private fun assumeAtLeastUpsideDownCake(message: String) {
+        assumeTrue(message, ApiLevelUtil.isAtLeast(device, 34))
+    }
+
     private companion object {
         const val TEST_CLASS_NAME = ".SafetyCenterInteractionLoggingHelperTests"
     }