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

Commit f3bc47b0 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB] Don't do anything special when a HUN comes in.

Now that notifications show the app icon, we don't need the status bar
to show the app name when a HUN comes in for anti-spoofing -- the HUN
itself will show the app icon which protects us against spoofing. This
CL removes all of status bar's custom HUN behavior.

Bug: 385740230
Flag: com.android.systemui.status_bar_no_hun_behavior

Test: atest HomeStatusBarViewModelTest HeadsUpAppearanceControllerTest
CollapsedStatusBarFragmentTest

Test: with StatusBarRootModernization flag off, verify status bar
doesn't change when HUN appears
Test: with StatusBarRootModernization flag on, verify status bar doesn't
change when HUN appears

Test: receive HUN while on lockscreen with bypass enabled -> verify
keyguard status bar doesn't show HUN icon&name

Test: with StatusBarNotificationChips flag on, post promoted
notification then tap chip -> verify chip hides its own text
Test: with StatusBarNotificationChips flag on, verify chips stay visible
when HUN comes in

Change-Id: Ib0f3709adde0b4b0e7c68425ecde0cd59431f445
parent 9356d6f4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -492,6 +492,14 @@ flag {
    bug: "372964148"
}

flag {
    name: "status_bar_no_hun_behavior"
    namespace: "systemui"
    description: "When there's a HUN, don't show the HUN text or icon in the status bar. Instead, "
       "continue showing the usual status bar."
    bug: "385740230"
}

flag {
    name: "promote_notifications_automatically"
    namespace: "systemui"
+35 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.notification.icon.ui.viewmodel

import android.graphics.Rect
import android.graphics.drawable.Icon
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -36,6 +38,7 @@ import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.power.shared.model.WakefulnessState
import com.android.systemui.shade.shadeTestUtil
import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
@@ -258,6 +261,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati
        }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIcon_animateOnAppear_shadeCollapsed() =
        testScope.runTest {
            val icon: Icon = mock()
@@ -285,6 +289,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati
        }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIcon_dontAnimateOnAppear_shadeExpanded() =
        testScope.runTest {
            val icon: Icon = mock()
@@ -312,6 +317,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati
        }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIcon_updateWhenIconDataChanges() =
        testScope.runTest {
            val icon: Icon = mock()
@@ -339,6 +345,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati
        }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIcon_lastMessageIsFromReply_notNull() =
        testScope.runTest {
            val icon: Icon = mock()
@@ -362,4 +369,32 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati

            assertThat(isolatedIcon?.value?.notifKey).isEqualTo("notif1")
        }

    @Test
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIcon_noHunBehaviorFlagEnabled_doesNothing() =
        testScope.runTest {
            val icon: Icon = mock()
            val isolatedIcon by collectLastValue(underTest.isolatedIcon)
            runCurrent()

            headsUpViewStateRepository.isolatedNotification.value = "notif1"
            runCurrent()

            activeNotificationsRepository.activeNotifications.value =
                ActiveNotificationsStore.Builder()
                    .apply {
                        addIndividualNotif(
                            activeNotificationModel(
                                key = "notif1",
                                groupKey = "group",
                                statusBarIcon = icon,
                            )
                        )
                    }
                    .build()
            runCurrent()

            assertThat(isolatedIcon?.value).isNull()
        }
}
+62 −10
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.shade.shadeViewController
import com.android.systemui.statusbar.HeadsUpStatusBarView
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.commandQueue
import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.domain.interactor.headsUpNotificationIconInteractor
@@ -118,6 +119,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun showingEntryUpdated_whenPinnedBySystem() {
        row.setPinnedStatus(PinnedStatus.PinnedBySystem)
        setHeadsUpNotifOnManager(entry)
@@ -133,8 +135,18 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showingEntryUpdated_whenPinnedByUser_andFlagOff() {
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun showingEntryNotUpdated_whenPinnedBySystem_whenNoHunBehaviorEnabled() {
        row.setPinnedStatus(PinnedStatus.PinnedBySystem)
        setHeadsUpNotifOnManager(entry)
        underTest.onHeadsUpPinned(entry)

        assertThat(headsUpStatusBarView.showingEntry).isNull()
    }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarNoHunBehavior.FLAG_NAME)
    fun showingEntryUpdated_whenPinnedByUser_andNotifChipsFlagOff() {
        row.setPinnedStatus(PinnedStatus.PinnedByUser)
        setHeadsUpNotifOnManager(entry)
        underTest.onHeadsUpPinned(entry)
@@ -144,7 +156,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showingEntryNotUpdated_whenPinnedByUser_andFlagOn() {
    fun showingEntryNotUpdated_whenPinnedByUser_andNotifChipsFlagOn() {
        // WHEN the HUN was pinned by the user
        row.setPinnedStatus(PinnedStatus.PinnedByUser)
        setHeadsUpNotifOnManager(entry)
@@ -155,6 +167,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun pinnedStatusUpdatedToSystem_whenPinnedBySystem() {
        row.setPinnedStatus(PinnedStatus.PinnedBySystem)
        setHeadsUpNotifOnManager(entry)
@@ -167,9 +180,20 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
        assertThat(underTest.pinnedStatus).isEqualTo(PinnedStatus.NotPinned)
    }

    @Test
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun pinnedStatusNotUpdatedToSystem_whenPinnedBySystem_whenNoHunBehaviorEnabled() {
        row.setPinnedStatus(PinnedStatus.PinnedBySystem)
        setHeadsUpNotifOnManager(entry)
        underTest.onHeadsUpPinned(entry)

        assertThat(underTest.pinnedStatus).isEqualTo(PinnedStatus.NotPinned)
    }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun pinnedStatusUpdatedToNotPinned_whenPinnedByUser_andFlagOn() {
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun pinnedStatusUpdatedToNotPinned_whenPinnedByUser_andNotifChipsFlagOn() {
        row.setPinnedStatus(PinnedStatus.PinnedByUser)
        setHeadsUpNotifOnManager(entry)
        underTest.onHeadsUpPinned(entry)
@@ -182,6 +206,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIconSet_whenPinnedBySystem() =
        kosmos.runTest {
            val latestIsolatedIcon by
@@ -201,8 +226,22 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun isolatedIconSet_whenPinnedByUser_andFlagOff() =
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIconNotSet_whenPinnedBySystem_whenNoHunBehaviorEnabled() =
        kosmos.runTest {
            val latestIsolatedIcon by
                collectLastValue(kosmos.headsUpNotificationIconInteractor.isolatedNotification)

            row.setPinnedStatus(PinnedStatus.PinnedBySystem)
            setHeadsUpNotifOnManager(entry)
            underTest.onHeadsUpPinned(entry)

            assertThat(latestIsolatedIcon).isNull()
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarNoHunBehavior.FLAG_NAME)
    fun isolatedIconSet_whenPinnedByUser_andNotifChipsFlagOff() =
        kosmos.runTest {
            val latestIsolatedIcon by
                collectLastValue(kosmos.headsUpNotificationIconInteractor.isolatedNotification)
@@ -216,7 +255,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun isolatedIconNotSet_whenPinnedByUser_andFlagOn() =
    fun isolatedIconNotSet_whenPinnedByUser_andNotifChipsFlagOn() =
        kosmos.runTest {
            val latestIsolatedIcon by
                collectLastValue(kosmos.headsUpNotificationIconInteractor.isolatedNotification)
@@ -243,6 +282,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun operatorNameViewUpdated_whenPinnedBySystem() {
        underTest.setAnimationsEnabled(false)

@@ -258,8 +298,20 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun operatorNameViewUpdated_whenPinnedByUser_andFlagOff() {
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun operatorNameViewNotUpdated_whenPinnedBySystem_whenNoHunBehaviorEnabled() {
        underTest.setAnimationsEnabled(false)

        row.setPinnedStatus(PinnedStatus.PinnedBySystem)
        setHeadsUpNotifOnManager(entry)
        underTest.onHeadsUpPinned(entry)

        assertThat(operatorNameView.visibility).isEqualTo(View.VISIBLE)
    }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarNoHunBehavior.FLAG_NAME)
    fun operatorNameViewUpdated_whenPinnedByUser_andNotifChipsFlagOff() {
        underTest.setAnimationsEnabled(false)

        row.setPinnedStatus(PinnedStatus.PinnedByUser)
@@ -271,7 +323,7 @@ class HeadsUpAppearanceControllerTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun operatorNameViewNotUpdated_whenPinnedByUser_andFlagOn() {
    fun operatorNameViewNotUpdated_whenPinnedByUser_andNotifChipsFlagOn() {
        underTest.setAnimationsEnabled(false)

        // WHEN the row was pinned by the user
+58 −7
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import com.android.systemui.statusbar.events.data.repository.systemStatusEventAn
import com.android.systemui.statusbar.events.shared.model.SystemEventAnimationState.AnimatingIn
import com.android.systemui.statusbar.events.shared.model.SystemEventAnimationState.AnimatingOut
import com.android.systemui.statusbar.events.shared.model.SystemEventAnimationState.Idle
import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore
import com.android.systemui.statusbar.notification.data.repository.UnconfinedFakeHeadsUpRowRepository
@@ -552,9 +553,10 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
        }

    @Test
    fun shouldShowOperatorNameView_allowedByInteractor_hunPinned_false() =
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun shouldShowOperatorNameView_allowedByInteractor_hunPinned_noHunBehaviorFlagOff_false() =
        kosmos.runTest {
            kosmos.setHomeStatusBarInteractorShowOperatorName(false)
            kosmos.setHomeStatusBarInteractorShowOperatorName(true)

            transitionKeyguardToGone()

@@ -565,7 +567,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser),
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

@@ -574,6 +576,31 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
            assertThat(latest).isFalse()
        }

    @Test
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun shouldShowOperatorNameView_allowedByInteractor_hunPinned_noHunBehaviorFlagOn_true() =
        kosmos.runTest {
            kosmos.setHomeStatusBarInteractorShowOperatorName(true)

            transitionKeyguardToGone()

            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            // WHEN there is an active HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            val latest by collectLastValue(underTest.shouldShowOperatorNameView)

            // THEN we still show the operator name view if NoHunBehavior flag is enabled
            assertThat(latest).isTrue()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardNotGone_noHun_false() =
        kosmos.runTest {
@@ -692,7 +719,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun isClockVisible_allowedByFlags_hunPinnedByUser_visible() =
    fun isClockVisible_allowedByDisableFlags_hunPinnedByUser_visible() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isClockVisible)
            transitionKeyguardToGone()
@@ -711,7 +738,8 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
        }

    @Test
    fun isClockVisible_allowedByFlags_hunPinnedBySystem_notVisible() =
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isClockVisible_allowedByDisableFlags_hunPinnedBySystem_noHunBehaviorFlagOff_notVisible() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isClockVisible)
            transitionKeyguardToGone()
@@ -730,7 +758,29 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
        }

    @Test
    fun isClockVisible_allowedByFlags_hunBecomesInactive_visibleAgain() =
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isClockVisible_allowedByDisableFlags_hunPinnedBySystem_noHunBehaviorFlagOn_visible() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isClockVisible)
            transitionKeyguardToGone()

            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)
            // WHEN there is an active HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN we still show the clock view if NoHunBehavior flag is enabled
            assertThat(latest!!.visibility).isEqualTo(View.VISIBLE)
        }

    @Test
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isClockVisible_allowedByDisableFlags_hunBecomesInactive_visibleAgain() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isClockVisible)
            transitionKeyguardToGone()
@@ -753,7 +803,8 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
        }

    @Test
    fun isClockVisible_disabledByFlags_hunBecomesInactive_neverVisible() =
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isClockVisible_disableFlagsProhibitClock_hunBecomesInactive_neverVisible() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isClockVisible)
            transitionKeyguardToGone()
+25 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.ui.viewmodel

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -32,6 +34,7 @@ import com.android.systemui.scene.data.repository.sceneContainerRepository
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.domain.interactor.keyguardStatusBarInteractor
import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior
import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor
@@ -127,7 +130,8 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa

    @Test
    @EnableSceneContainer
    fun isVisible_headsUpStatusBarShown_false() =
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isVisible_headsUpShown_noHunBehaviorFlagOff_false() =
        testScope.runTest {
            val latest by collectLastValue(underTest.isVisible)

@@ -144,6 +148,26 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa
            assertThat(latest).isFalse()
        }

    @Test
    @EnableSceneContainer
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun isVisible_headsUpShown_noHunBehaviorFlagOn_true() =
        testScope.runTest {
            val latest by collectLastValue(underTest.isVisible)

            // WHEN HUN displayed on the bypass lock screen
            headsUpRepository.setNotifications(FakeHeadsUpRowRepository("key 0", isPinned = true))
            keyguardTransitionRepository.emitInitialStepsFromOff(
                KeyguardState.LOCKSCREEN,
                testSetup = true,
            )
            kosmos.sceneContainerRepository.snapToScene(Scenes.Lockscreen)
            faceAuthRepository.isBypassEnabled.value = true

            // THEN KeyguardStatusBar is still visible because StatusBarNoHunBehavior is enabled
            assertThat(latest).isTrue()
        }

    @Test
    fun isVisible_sceneLockscreen_andNotDozing_andNotShowingHeadsUpStatusBar_true() =
        testScope.runTest {
Loading