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

Commit 788bf656 authored by Darrell Shi's avatar Darrell Shi
Browse files

Do not hide notifications on dream

Currently notifications are hidden when dreaming because it is
considered showing keyguard. However, the dream status bar needs
notifications to display the ongoing call chip in the dream status bar.
This change excludes the dreaming case from hiding notifications.

Test: atest KeyguardNotificationVisibilityProviderTest
Test: verified ongoing call chip showing in dream status bar
Fix: 422469252
Flag: com.android.systemui.ongoing_activity_chips_on_dream
Change-Id: Ied7ffc66989f9245c4d9d078b417972782ed6141
parent 02e10010
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.app.NotificationChannel;
import android.content.Context;
import android.os.Handler;
import android.os.UserHandle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.provider.Settings;
import android.testing.TestableLooper;

@@ -51,6 +53,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.CoreStartable;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.ambient.statusbar.shared.flag.OngoingActivityChipsOnDream;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FakeFeatureFlagsClassic;
@@ -304,6 +307,36 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
        assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @EnableFlags(OngoingActivityChipsOnDream.FLAG_NAME)
    @Test
    public void dreaming_flagEnabled_doNotHideNotifications() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        mSecureSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true);
        mSecureSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
        mEntry = new NotificationEntryBuilder()
                .setUser(new UserHandle(NOTIF_USER_ID))
                .setImportance(IMPORTANCE_LOW)
                .build();
        when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false);
        when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(true);
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @DisableFlags(OngoingActivityChipsOnDream.FLAG_NAME)
    @Test
    public void dreaming_flagDisabled_hideNotifications() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        mSecureSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true);
        mSecureSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
        mEntry = new NotificationEntryBuilder()
                .setUser(new UserHandle(NOTIF_USER_ID))
                .setImportance(IMPORTANCE_LOW)
                .build();
        when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false);
        when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(true);
        assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void hideSilentOnLockscreenSetting() {
        // GIVEN an 'unfiltered-keyguard-showing' state and notifications shown on lockscreen
+4 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import android.provider.Settings
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.systemui.CoreStartable
import com.android.systemui.ambient.statusbar.shared.flag.OngoingActivityChipsOnDream
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlagsClassic
@@ -186,6 +187,9 @@ constructor(

    override fun shouldHideNotification(entry: NotificationEntry): Boolean =
        when {
            // Don't hide notifications if we're in a dream. The dream status bar needs
            // notifications to render ongoing call chip.
            OngoingActivityChipsOnDream.isEnabled && keyguardUpdateMonitor.isDreaming -> false
            // Keyguard state doesn't matter if the keyguard is not showing.
            !isLockedOrLocking -> false
            // Notifications not allowed on the lockscreen, always hide.