Suppress matched native notification alerts

This commit is contained in:
ajp_anton
2026-08-18 05:25:48 +00:00
parent 7166cfe18b
commit 68771d5836
13 changed files with 341 additions and 85 deletions
@@ -0,0 +1,44 @@
package se.ajpanton.notificationsmaster.module
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import se.ajpanton.notificationsmaster.alerts.AlertConfiguration
import se.ajpanton.notificationsmaster.alerts.AlertOutcome
import se.ajpanton.notificationsmaster.alerts.AlertProfile
import se.ajpanton.notificationsmaster.alerts.AlertRule
import se.ajpanton.notificationsmaster.alerts.AlertSource
import se.ajpanton.notificationsmaster.alerts.AlertTextMatcher
import se.ajpanton.notificationsmaster.alerts.AlertConfigurationStore
/** Installs a predictable helper policy for the AOSP LSPosed smoke test. */
@RunWith(AndroidJUnit4::class)
class AlertPolicySyncDeviceTest {
@Test
fun savesMatchingHelperPolicy() {
val profile = AlertProfile("module-test", "Module test", vibrationPattern = listOf(0, 200))
val configuration = AlertConfiguration(
profiles = listOf(profile),
rules = listOf(
AlertRule(
id = "module-helper-post",
packageName = HELPER_PACKAGE,
order = 0,
sources = setOf(AlertSource.NOTIFICATION_POST),
matcher = AlertTextMatcher(),
outcome = AlertOutcome.PLAY_PROFILE,
profileId = profile.id,
),
),
)
val store = AlertConfigurationStore(InstrumentationRegistry.getInstrumentation().targetContext)
store.save(configuration)
assertEquals(configuration, store.load())
}
private companion object {
const val HELPER_PACKAGE = "se.ajpanton.notificationsmaster.helper"
}
}