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

Commit 1fe10944 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Allow apps with dnd access to bypass DND

That is, to create channels that bypass DND,
unless the user has expressed a preference
for that channel

Change-Id: Ic4593eac726b690946f44b3c61494b629a5ad73a
Fixes: 74525735
Test: runtest systemui-notification
parent dedfd8fe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -250,6 +250,7 @@ public class NotificationDataTest extends SysuiTestCase {

    @Test
    public void testShouldFilterHiddenNotifications() {
        initStatusBarNotification(false);
        // setup
        when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false);
        when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
+2 −1
Original line number Diff line number Diff line
@@ -2149,7 +2149,8 @@ public class NotificationManagerService extends SystemService {
                final NotificationChannel channel = channels.get(i);
                Preconditions.checkNotNull(channel, "channel in list is null");
                mRankingHelper.createNotificationChannel(pkg, uid, channel,
                        true /* fromTargetApp */);
                        true /* fromTargetApp */, mConditionProviders.isPackageOrComponentAllowed(
                                pkg, UserHandle.getUserId(uid)));
                mListeners.notifyNotificationChannelChanged(pkg,
                        UserHandle.getUserHandleForUid(uid),
                        mRankingHelper.getNotificationChannel(pkg, uid, channel.getId(), false),
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public interface RankingConfig {
    ParceledListSlice<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
            int uid, boolean includeDeleted, boolean includeNonGrouped);
    void createNotificationChannel(String pkg, int uid, NotificationChannel channel,
            boolean fromTargetApp);
            boolean fromTargetApp, boolean hasDndAccess);
    void updateNotificationChannel(String pkg, int uid, NotificationChannel channel, boolean fromUser);
    NotificationChannel getNotificationChannel(String pkg, int uid, String channelId, boolean includeDeleted);
    void deleteNotificationChannel(String pkg, int uid, String channelId);
+5 −4
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ public class RankingHelper implements RankingConfig {

    @Override
    public void createNotificationChannel(String pkg, int uid, NotificationChannel channel,
            boolean fromTargetApp) {
            boolean fromTargetApp, boolean hasDndAccess) {
        Preconditions.checkNotNull(pkg);
        Preconditions.checkNotNull(channel);
        Preconditions.checkNotNull(channel.getId());
@@ -610,8 +610,9 @@ public class RankingHelper implements RankingConfig {
                existing.setImportance(channel.getImportance());
            }

            // system apps can bypass dnd if the user hasn't changed any fields on the channel yet
            if (existing.getUserLockedFields() == 0 & isSystemApp) {
            // system apps and dnd access apps can bypass dnd if the user hasn't changed any
            // fields on the channel yet
            if (existing.getUserLockedFields() == 0 && (isSystemApp || hasDndAccess)) {
                existing.setBypassDnd(channel.canBypassDnd());
            }

@@ -624,7 +625,7 @@ public class RankingHelper implements RankingConfig {
        }

        // Reset fields that apps aren't allowed to set.
        if (fromTargetApp && !isSystemApp) {
        if (fromTargetApp && !(isSystemApp || hasDndAccess)) {
            channel.setBypassDnd(r.priority == Notification.PRIORITY_MAX);
        }
        if (fromTargetApp) {
+97 −73

File changed.

Preview size limit exceeded, changes collapsed.