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

Commit 5f68bf2e authored by Richard MacGregor's avatar Richard MacGregor
Browse files

Hide notification expander arrow while screenshare

Test: manual
Bug: 325538530
Flag: ACONFIG com.android.systemui.screenshare_notification_hiding TEAMFOOD

Change-Id: If1888afe3f8d17d5bc76df4b1dece99c1c33c7d0
parent e789895c
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -119,6 +119,9 @@ class SensitiveContentCoordinatorImpl @Inject constructor(
            val needsRedaction = lockscreenUserManager.needsRedaction(entry)
            val needsRedaction = lockscreenUserManager.needsRedaction(entry)
            val isSensitive = userPublic && needsRedaction
            val isSensitive = userPublic && needsRedaction
            entry.setSensitive(isSensitive || shouldProtectNotification, deviceSensitive)
            entry.setSensitive(isSensitive || shouldProtectNotification, deviceSensitive)
            if (screenshareNotificationHiding()) {
                entry.row?.setPublicExpanderVisible(!shouldProtectNotification)
            }
        }
        }
    }
    }
}
}
+10 −2
Original line number Original line Diff line number Diff line
@@ -218,6 +218,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private boolean mShowingPublic;
    private boolean mShowingPublic;
    private boolean mSensitive;
    private boolean mSensitive;
    private boolean mSensitiveHiddenInGeneral;
    private boolean mSensitiveHiddenInGeneral;
    private boolean mShowPublicExpander = true;
    private boolean mShowingPublicInitialized;
    private boolean mShowingPublicInitialized;
    private boolean mHideSensitiveForIntrinsicHeight;
    private boolean mHideSensitiveForIntrinsicHeight;
    private float mHeaderVisibleAmount = DEFAULT_HEADER_VISIBLE_AMOUNT;
    private float mHeaderVisibleAmount = DEFAULT_HEADER_VISIBLE_AMOUNT;
@@ -599,8 +600,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mNotificationParent.updateChildrenAppearance();
            mNotificationParent.updateChildrenAppearance();
        }
        }
        onAttachedChildrenCountChanged();
        onAttachedChildrenCountChanged();
        // The public layouts expand button is always visible
        mPublicLayout.updateExpandButtons(mShowPublicExpander);
        mPublicLayout.updateExpandButtons(true);
        updateLimits();
        updateLimits();
        updateShelfIconColor();
        updateShelfIconColor();
        if (mUpdateSelfBackgroundOnUpdate) {
        if (mUpdateSelfBackgroundOnUpdate) {
@@ -2837,6 +2837,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
        }
    }
    }


    /** Sets whether this notification row should show the notification expander or not */
    public void setPublicExpanderVisible(boolean showPublicExpander) {
        if (mShowPublicExpander != showPublicExpander) {
            mShowPublicExpander = showPublicExpander;
            mPublicLayout.updateExpandButtons(mShowPublicExpander);
        }
    }

    @Override
    @Override
    public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
    public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
        mHideSensitiveForIntrinsicHeight = hideSensitive;
        mHideSensitiveForIntrinsicHeight = hideSensitive;
+21 −1
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.statusbar.notification.collection.coordinator.dagger
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.SensitiveNotificationProtectionController
import com.android.systemui.statusbar.policy.SensitiveNotificationProtectionController
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
@@ -130,6 +131,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -156,6 +158,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -196,6 +199,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -222,6 +226,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -262,6 +267,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -288,6 +294,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!).setSensitive(true, false)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -329,6 +336,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -356,6 +364,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -396,6 +405,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -422,6 +432,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -462,6 +473,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!).setSensitive(false, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -489,6 +501,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -531,6 +544,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(true)
    }
    }


    @Test
    @Test
@@ -559,6 +573,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!).setSensitive(true, true)
        verify(entry.representativeEntry!!.row!!).setPublicExpanderVisible(false)
    }
    }


    @Test
    @Test
@@ -584,6 +599,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))
        onBeforeRenderListListener.onBeforeRenderList(listOf(entry))


        verify(entry.representativeEntry!!, never()).setSensitive(any(), any())
        verify(entry.representativeEntry!!, never()).setSensitive(any(), any())
        verify(entry.representativeEntry!!.row!!, never()).setPublicExpanderVisible(any())
    }
    }


    private fun fakeNotification(notifUserId: Int, needsRedaction: Boolean): ListEntry {
    private fun fakeNotification(notifUserId: Int, needsRedaction: Boolean): ListEntry {
@@ -591,7 +607,11 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
            mock<UserHandle>().apply { whenever(identifier).thenReturn(notifUserId) }
            mock<UserHandle>().apply { whenever(identifier).thenReturn(notifUserId) }
        val mockSbn: StatusBarNotification =
        val mockSbn: StatusBarNotification =
            mock<StatusBarNotification>().apply { whenever(user).thenReturn(mockUserHandle) }
            mock<StatusBarNotification>().apply { whenever(user).thenReturn(mockUserHandle) }
        val mockEntry = mock<NotificationEntry>().apply { whenever(sbn).thenReturn(mockSbn) }
        val mockRow: ExpandableNotificationRow = mock<ExpandableNotificationRow>()
        val mockEntry = mock<NotificationEntry>().apply {
            whenever(sbn).thenReturn(mockSbn)
            whenever(row).thenReturn(mockRow)
        }
        whenever(lockscreenUserManager.needsRedaction(mockEntry)).thenReturn(needsRedaction)
        whenever(lockscreenUserManager.needsRedaction(mockEntry)).thenReturn(needsRedaction)
        whenever(mockEntry.rowExists()).thenReturn(true)
        whenever(mockEntry.rowExists()).thenReturn(true)
        return object : ListEntry("key", 0) {
        return object : ListEntry("key", 0) {