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

Commit 14ec8fe5 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add protective null check

For tests and possibly rare race conditions

Test: KeyguardNotificationVisibilityProviderTest
Fixes: 324014574
Change-Id: Ib87b90dd2a5df6404b315071b02c601ad7bda8b6
parent 8bfdef2a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -223,7 +223,8 @@ class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
            // ranking.lockscreenVisibilityOverride contains possibly out of date DPC and Setting
            // info, and NotificationLockscreenUserManagerImpl is already listening for updates
            // to those
            entry.ranking.channel.lockscreenVisibility == VISIBILITY_SECRET
            entry.ranking.channel != null && entry.ranking.channel.lockscreenVisibility ==
                    VISIBILITY_SECRET
        } else {
            entry.ranking.lockscreenVisibilityOverride == VISIBILITY_SECRET
        }
+17 −0
Original line number Diff line number Diff line
@@ -471,6 +471,23 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
        assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void publicMode_nullChannel_allowed() {
        mFeatureFlags.set(Flags.NOTIF_LS_BACKGROUND_THREAD, true);
        // GIVEN an 'unfiltered-keyguard-showing' state
        setupUnfilteredState(mEntry);

        // WHEN the notification's user is in public mode and settings are configured to disallow
        // notifications in public mode
        when(mLockscreenUserManager.isLockscreenPublicMode(CURR_USER_ID)).thenReturn(true);
        mEntry.setRanking(new RankingBuilder()
                .setKey(mEntry.getKey())
                .setVisibilityOverride(VISIBILITY_SECRET).build());

        // THEN allow the entry
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void publicMode_notifDisallowed() {
        mFeatureFlags.set(Flags.NOTIF_LS_BACKGROUND_THREAD, true);