Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90f32b67 authored by Richard MacGregor's avatar Richard MacGregor
Browse files

Invalidate pipeline on state change

When SensitiveNotificationProtectionController state changes, invalidate
notification pipeline. This is done via SensitiveContentCoordinator due
to its usage of that state in onBeforeRenderList

Bug: 327024492
Test: atest SensitiveContentCoordinatorTest
Flag: ACONFIG com.android.server.notification.screenshare_notification_hiding DISABLED
Change-Id: I083f7a1e85849ea9811cd90eada79e5388beaceb
parent 6505660c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,9 +63,16 @@ class SensitiveContentCoordinatorImpl @Inject constructor(
        SensitiveContentCoordinator,
        DynamicPrivacyController.Listener,
        OnBeforeRenderListListener {
    private val onSensitiveStateChanged = Runnable() {
        invalidateList("onSensitiveStateChanged")
    }

    override fun attach(pipeline: NotifPipeline) {
        dynamicPrivacyController.addListener(this)
        if (screenshareNotificationHiding()) {
            sensitiveNotificationProtectionController
                .registerSensitiveStateListener(onSensitiveStateChanged)
        }
        pipeline.addOnBeforeRenderListListener(this)
        pipeline.addPreRenderInvalidator(this)
    }
+20 −0
Original line number Diff line number Diff line
@@ -93,6 +93,26 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        verify(invalidationListener).onPluggableInvalidated(eq(invalidator), any())
    }

    @Test
    @EnableFlags(FLAG_SCREENSHARE_NOTIFICATION_HIDING)
    fun onSensitiveStateChanged_invokeInvalidationListener() {
        coordinator.attach(pipeline)
        val invalidator =
            withArgCaptor<Invalidator> { verify(pipeline).addPreRenderInvalidator(capture()) }
        val onSensitiveStateChangedListener =
            withArgCaptor<Runnable> {
                verify(sensitiveNotificationProtectionController)
                    .registerSensitiveStateListener(capture())
            }

        val invalidationListener = mock<Pluggable.PluggableListener<Invalidator>>()
        invalidator.setInvalidationListener(invalidationListener)

        onSensitiveStateChangedListener.run()

        verify(invalidationListener).onPluggableInvalidated(eq(invalidator), any())
    }

    @Test
    fun onBeforeRenderList_deviceUnlocked_notifDoesNotNeedRedaction() {
        coordinator.attach(pipeline)