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

Commit 0aaa4026 authored by Julia Reynolds's avatar Julia Reynolds Committed by Automerger Merge Worker
Browse files

Merge "Revert "Clocks were switching too frequently"" into tm-dev am: 203d94b1 am: c0780685

parents 28b7f291 c0780685
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.NotificationLockscreenUserManager
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider
@@ -74,7 +72,7 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
    private val lockscreenUserManager: NotificationLockscreenUserManager,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val highPriorityProvider: HighPriorityProvider,
    private val statusBarStateController: SysuiStatusBarStateController,
    private val statusBarStateController: StatusBarStateController,
    private val broadcastDispatcher: BroadcastDispatcher,
    private val secureSettings: SecureSettings,
    private val globalSettings: GlobalSettings
@@ -107,8 +105,7 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
                if (uri == showSilentNotifsUri) {
                    readShowSilentNotificationSetting()
                }
                if (statusBarStateController.getCurrentOrUpcomingState()
                        == StatusBarState.KEYGUARD) {
                if (keyguardStateController.isShowing) {
                    notifyStateChanged("Settings $uri changed")
                }
            }
@@ -134,14 +131,13 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(

        // register (maybe) public mode changed callbacks:
        statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
            override fun onUpcomingStateChanged(state: Int) {
                notifyStateChanged("onStatusBarUpcomingStateChanged")
            override fun onStateChanged(state: Int) {
                notifyStateChanged("onStatusBarStateChanged")
            }
        })
        broadcastDispatcher.registerReceiver(object : BroadcastReceiver() {
            override fun onReceive(context: Context, intent: Intent) {
                if (statusBarStateController.getCurrentOrUpcomingState()
                        == StatusBarState.KEYGUARD) {
                if (keyguardStateController.isShowing) {
                    // maybe public mode changed
                    notifyStateChanged(intent.action!!)
                }
@@ -163,7 +159,7 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(

    override fun shouldHideNotification(entry: NotificationEntry): Boolean = when {
        // Keyguard state doesn't matter if the keyguard is not showing.
        statusBarStateController.getCurrentOrUpcomingState() != StatusBarState.KEYGUARD -> false
        !keyguardStateController.isShowing -> false
        // Notifications not allowed on the lockscreen, always hide.
        !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
        // User settings do not allow this notification on the lockscreen, so hide it.
+11 −14
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@ import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;

import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.collection.EntryUtilKt.modifyEntry;
import static com.android.systemui.util.mockito.KotlinMockitoHelpersKt.argThat;

@@ -58,7 +56,6 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -94,7 +91,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
    @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
    @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    @Mock private HighPriorityProvider mHighPriorityProvider;
    @Mock private SysuiStatusBarStateController mStatusBarStateController;
    @Mock private StatusBarStateController mStatusBarStateController;
    @Mock private BroadcastDispatcher mBroadcastDispatcher;
    private final FakeSettings mFakeSettings = new FakeSettings();

@@ -182,7 +179,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

        callback.onUpcomingStateChanged(0);
        callback.onStateChanged(0);

        verify(listener).accept(anyString());
    }
@@ -203,7 +200,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        callback.onReceive(mContext, new Intent(Intent.ACTION_USER_SWITCHED));

        verify(listener).accept(anyString());
@@ -211,7 +208,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {

    @Test
    public void notifyListeners_onSettingChange_lockScreenShowNotifs() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

@@ -222,7 +219,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {

    @Test
    public void notifyListeners_onSettingChange_lockScreenAllowPrivateNotifs() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

@@ -268,7 +265,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {

    @Test
    public void notifyListeners_onSettingChange_zenMode() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

@@ -279,7 +276,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {

    @Test
    public void notifyListeners_onSettingChange_lockScreenShowSilentNotifs() {
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        Consumer<String> listener = mock(Consumer.class);
        mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);

@@ -301,7 +298,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
    public void keyguardNotShowing() {
        // GIVEN the lockscreen isn't showing
        setupUnfilteredState(mEntry);
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(SHADE);
        when(mKeyguardStateController.isShowing()).thenReturn(false);

        // THEN don't filter out the entry
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
@@ -443,7 +440,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
     */
    private void setupUnfilteredState(NotificationEntry entry) {
        // keyguard is showing
        when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
        when(mKeyguardStateController.isShowing()).thenReturn(true);

        // show notifications on the lockscreen
        when(mLockscreenUserManager.shouldShowLockscreenNotifications()).thenReturn(true);
@@ -491,7 +488,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
                    @BindsInstance NotificationLockscreenUserManager lockscreenUserManager,
                    @BindsInstance KeyguardUpdateMonitor keyguardUpdateMonitor,
                    @BindsInstance HighPriorityProvider highPriorityProvider,
                    @BindsInstance SysuiStatusBarStateController statusBarStateController,
                    @BindsInstance StatusBarStateController statusBarStateController,
                    @BindsInstance BroadcastDispatcher broadcastDispatcher,
                    @BindsInstance SecureSettings secureSettings,
                    @BindsInstance GlobalSettings globalSettings