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

Commit a088c85c authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Check importance to determine if notif sounds" into rvc-dev am: 10649bff

Change-Id: Iaa3746e48d87628d95343f67c3b66db8b7eb7dfd
parents 2327a3b6 10649bff
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -19,11 +19,13 @@ import static android.app.Notification.VISIBILITY_SECRET;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;


import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_MEDIA_CONTROLS;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
@@ -351,7 +353,10 @@ public class NotificationLockscreenUserManagerImpl implements
        boolean exceedsPriorityThreshold;
        boolean exceedsPriorityThreshold;
        if (NotificationUtils.useNewInterruptionModel(mContext)
        if (NotificationUtils.useNewInterruptionModel(mContext)
                && hideSilentNotificationsOnLockscreen()) {
                && hideSilentNotificationsOnLockscreen()) {
            exceedsPriorityThreshold = entry.getBucket() != BUCKET_SILENT;
            exceedsPriorityThreshold =
                    entry.getBucket() == BUCKET_MEDIA_CONTROLS
                            || (entry.getBucket() != BUCKET_SILENT
                            && entry.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT);
        } else {
        } else {
            exceedsPriorityThreshold = !entry.getRanking().isAmbient();
            exceedsPriorityThreshold = !entry.getRanking().isAmbient();
        }
        }
+41 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.content.Intent.ACTION_USER_SWITCHED;
import static android.content.Intent.ACTION_USER_SWITCHED;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;


import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_MEDIA_CONTROLS;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_PEOPLE;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT;


import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertFalse;
@@ -233,6 +235,45 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(entry));
        assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(entry));
    }
    }


    @Test
    public void testShowSilentNotificationsPeopleBucket_settingSaysHide() {
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
        Settings.Secure.putInt(mContext.getContentResolver(),
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);

        final Notification notification = mock(Notification.class);
        when(notification.isForegroundService()).thenReturn(true);
        NotificationEntry entry = new NotificationEntryBuilder()
                .setImportance(IMPORTANCE_LOW)
                .setNotification(notification)
                .build();
        entry.setBucket(BUCKET_PEOPLE);
        assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(entry));
    }

    @Test
    public void testShowSilentNotificationsMediaBucket_settingSaysHide() {
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
        Settings.Secure.putInt(mContext.getContentResolver(),
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);

        final Notification notification = mock(Notification.class);
        when(notification.isForegroundService()).thenReturn(true);
        NotificationEntry entry = new NotificationEntryBuilder()
                .setImportance(IMPORTANCE_LOW)
                .setNotification(notification)
                .build();
        entry.setBucket(BUCKET_MEDIA_CONTROLS);
        // always show media controls, even if they're silent
        assertTrue(mLockscreenUserManager.shouldShowOnKeyguard(entry));
    }

    private class TestNotificationLockscreenUserManager
    private class TestNotificationLockscreenUserManager
            extends NotificationLockscreenUserManagerImpl {
            extends NotificationLockscreenUserManagerImpl {
        public TestNotificationLockscreenUserManager(Context context) {
        public TestNotificationLockscreenUserManager(Context context) {