From 3a77e1d4a0b3395600d929a8f352e9c25a57ab72 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 24 May 2017 16:20:06 -0400 Subject: [PATCH] Allow some system channels to be blocked Test: manual Bug: 38428796 Change-Id: If6853f1d847ade968d2bd3a7454ddce0fdda62f0 --- .../settings/notification/AppNotificationSettings.java | 3 ++- .../notification/ChannelNotificationSettings.java | 2 +- .../settings/notification/NotificationSettingsBase.java | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index 2035cd2f331..efcb5a166ee 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -203,7 +203,8 @@ public class AppNotificationSettings extends NotificationSettingsBase { final NotificationChannel channel) { MasterSwitchPreference channelPref = new MasterSwitchPreference( getPrefContext()); - channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && !mAppRow.systemApp); + channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null + && isChannelBlockable(mAppRow.systemApp, channel)); channelPref.setKey(channel.getId()); channelPref.setTitle(channel.getName()); channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE); diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java index 27e60c737df..8c43a3fd748 100644 --- a/src/com/android/settings/notification/ChannelNotificationSettings.java +++ b/src/com/android/settings/notification/ChannelNotificationSettings.java @@ -232,7 +232,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { mBlockBar.setKey(KEY_BLOCK); getPreferenceScreen().addPreference(mBlockBar); - if (mAppRow.systemApp && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE) { + if (!isChannelBlockable(mAppRow.systemApp, mChannel)) { setVisible(mBlockBar, false); } diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java index 695c7967c64..bfa93557a62 100644 --- a/src/com/android/settings/notification/NotificationSettingsBase.java +++ b/src/com/android/settings/notification/NotificationSettingsBase.java @@ -443,4 +443,12 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen return lockscreenSecure; } + + protected boolean isChannelBlockable(boolean systemApp, NotificationChannel channel) { + if (!mAppRow.systemApp) { + return true; + } + return channel.isBlockableSystem() + || channel.getImportance() == NotificationManager.IMPORTANCE_NONE; + } }