Add filtering to notification channel settings
Allow apps that are launching this page to specify targeted subsets of
settings that should be shown.
Test: settings notification robotests
Bug: 177246841
Change-Id: Ib491c43f1861a9775e3b25f39134cdbe105a7ff8
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 44a21ac..707cae9 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -65,11 +65,6 @@
android:summary="@string/promote_conversation_summary"
settings:allowDividerAbove="true"/>
- <PreferenceCategory
- android:key="channel_advanced"
- android:order="50"
- settings:initialExpandedChildrenCount="0">
-
<!-- Default ringtone -->
<com.android.settings.notification.app.NotificationSoundPreference
android:key="ringtone"
@@ -120,7 +115,6 @@
android:order="18"
android:title="@string/app_settings_link"
settings:allowDividerAbove="true"/>
- </PreferenceCategory>
<com.android.settings.notification.app.NotificationFooterPreference
android:key="desc"
diff --git a/src/com/android/settings/notification/AppBubbleListPreferenceController.java b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
index 31f185b..bf7fcc0 100644
--- a/src/com/android/settings/notification/AppBubbleListPreferenceController.java
+++ b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
@@ -32,7 +32,6 @@
import android.widget.ImageView;
import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
@@ -67,8 +66,10 @@
@Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
Drawable conversationDrawable,
ShortcutInfo conversationInfo,
- RestrictedLockUtils.EnforcedAdmin admin) {
- super.onResume(appRow, channel, group, conversationDrawable, conversationInfo, admin);
+ RestrictedLockUtils.EnforcedAdmin admin,
+ List<String> preferenceFilter) {
+ super.onResume(appRow, channel, group, conversationDrawable, conversationInfo, admin,
+ preferenceFilter);
// In case something changed in the foreground (e.g. via bubble button on notification)
loadConversationsAndPopulate();
}
diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
index 15b8388..e5afd9d 100644
--- a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
+++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.content.Context;
import android.util.Slog;
@@ -48,6 +49,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_LAUNCHER);
+ }
+
+ @Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY.equals(preference.getKey())) {
try {
diff --git a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
index cf6db87..0664c54 100644
--- a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
@@ -59,6 +59,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_SOUND);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
index 59fa440..3aeb73c 100644
--- a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
@@ -90,7 +90,7 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, null, null, null, null, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, null, null, null, null, mSuspendedAppsAdmin, null);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
index 297bfdb..5e12bbd 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
@@ -115,6 +115,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow != null) {
loadAppChannels();
diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
index 4dcbcfc..4fab7e2 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
@@ -53,7 +53,7 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, null, null, null, null, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, null, null, null, null, mSuspendedAppsAdmin, null);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
index 2054a16..0e89be3 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -75,6 +75,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public void updateState(Preference preference) {
mPreference = (PreferenceCategory) preference;
loadConversationsAndPopulate();
diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
index 23ccbf0..043ae69 100644
--- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
@@ -48,6 +48,11 @@
return mAppRow.settingsIntent != null;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
preference.setIntent(mAppRow.settingsIntent);
diff --git a/src/com/android/settings/notification/app/AppNotificationSettings.java b/src/com/android/settings/notification/app/AppNotificationSettings.java
index 58c18ba..d7694d7 100644
--- a/src/com/android/settings/notification/app/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppNotificationSettings.java
@@ -79,7 +79,8 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin,
+ null);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/BadgePreferenceController.java b/src/com/android/settings/notification/app/BadgePreferenceController.java
index 9f8608e..108fa1d 100644
--- a/src/com/android/settings/notification/app/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/app/BadgePreferenceController.java
@@ -18,6 +18,7 @@
import static android.provider.Settings.Secure.NOTIFICATION_BADGING;
+import android.app.NotificationChannel;
import android.content.Context;
import android.provider.Settings;
@@ -67,6 +68,11 @@
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_LAUNCHER);
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/app/BlockPreferenceController.java b/src/com/android/settings/notification/app/BlockPreferenceController.java
index 4df3e28..d5d516e 100644
--- a/src/com/android/settings/notification/app/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/app/BlockPreferenceController.java
@@ -20,6 +20,7 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.widget.Switch;
@@ -55,9 +56,17 @@
if (mAppRow == null) {
return false;
}
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
public void updateState(Preference preference) {
SettingsMainSwitchPreference bar = (SettingsMainSwitchPreference) preference;
if (bar != null) {
diff --git a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
index f8983ff..43f0baa 100644
--- a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
@@ -44,6 +44,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY;
}
diff --git a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
index ff27043..3439543 100644
--- a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
@@ -44,6 +44,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY;
}
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 8f452f7..6caa95e 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -21,6 +21,7 @@
import android.app.ActivityManager;
import android.annotation.Nullable;
+import android.app.NotificationChannel;
import android.content.Context;
import android.provider.Settings;
@@ -85,6 +86,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mIsAppPage && mAppRow != null) {
mHasSentInvalidMsg = mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
index 236e628..5b2a973 100644
--- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
@@ -67,6 +67,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY;
}
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index 5fd607f..b1109ec 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -85,6 +85,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public void updateState(Preference preference) {
mPreference = (PreferenceCategory) preference;
// Load channel settings
diff --git a/src/com/android/settings/notification/app/ChannelNotificationSettings.java b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
index 319c798..bdea30d 100644
--- a/src/com/android/settings/notification/app/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
@@ -79,7 +79,8 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin,
+ mPreferenceFilter);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
index 6583a23..02f639c 100644
--- a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.content.Context;
import android.text.TextUtils;
@@ -56,6 +57,11 @@
return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
public void updateState(Preference preference) {
preference.setEnabled(mAdmin == null);
}
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index 50a8b23..313b387 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -60,6 +60,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return true;
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow != null && mFragment != null) {
diff --git a/src/com/android/settings/notification/app/ConversationNotificationSettings.java b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
index 902c81c..819ba83 100644
--- a/src/com/android/settings/notification/app/ConversationNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
@@ -49,7 +49,7 @@
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,
- mConversationInfo, mSuspendedAppsAdmin);
+ mConversationInfo, mSuspendedAppsAdmin, null);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
index e59f277..9730104 100644
--- a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.content.Context;
import android.util.Pair;
@@ -53,6 +54,12 @@
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE)
+ || mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
index 5a6fa51..24c3d2f 100644
--- a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.content.Context;
import android.text.TextUtils;
@@ -56,6 +57,11 @@
return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
public void updateState(Preference preference) {
preference.setEnabled(mAdmin == null);
}
diff --git a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
index 5a60f3f..77a692f 100644
--- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
@@ -51,6 +51,11 @@
return mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
diff --git a/src/com/android/settings/notification/app/DescriptionPreferenceController.java b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
index f4ad6a3..0a5bb2f 100644
--- a/src/com/android/settings/notification/app/DescriptionPreferenceController.java
+++ b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
@@ -54,6 +54,11 @@
return false;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
if (mChannel != null) {
diff --git a/src/com/android/settings/notification/app/DndPreferenceController.java b/src/com/android/settings/notification/app/DndPreferenceController.java
index 90e6b25..b65928a 100644
--- a/src/com/android/settings/notification/app/DndPreferenceController.java
+++ b/src/com/android/settings/notification/app/DndPreferenceController.java
@@ -47,6 +47,11 @@
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_ZEN);
+ }
+
public void updateState(Preference preference) {
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index 8098714..6482943 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -60,6 +60,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return true;
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow != null && mFragment != null) {
diff --git a/src/com/android/settings/notification/app/HighImportancePreferenceController.java b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
index 3aecfa8..67fb2ff 100644
--- a/src/com/android/settings/notification/app/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
@@ -22,12 +22,12 @@
import android.app.NotificationChannel;
import android.content.Context;
+import androidx.preference.Preference;
+
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedSwitchPreference;
-import androidx.preference.Preference;
-
public class HighImportancePreferenceController extends NotificationPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
@@ -61,6 +61,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow != null && mChannel != null) {
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
diff --git a/src/com/android/settings/notification/app/ImportancePreferenceController.java b/src/com/android/settings/notification/app/ImportancePreferenceController.java
index dc7f29b..ed3410c 100644
--- a/src/com/android/settings/notification/app/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/ImportancePreferenceController.java
@@ -59,6 +59,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow!= null && mChannel != null) {
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
index ade9653..b937e80 100644
--- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
@@ -47,10 +47,18 @@
if (mAppRow.banned) {
return false;
}
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow == null) {
return;
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index cf66474..5c502dc 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -47,10 +47,18 @@
if (mAppRow.banned) {
return false;
}
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow == null) {
return;
diff --git a/src/com/android/settings/notification/app/LightsPreferenceController.java b/src/com/android/settings/notification/app/LightsPreferenceController.java
index fc9f34c..d096922 100644
--- a/src/com/android/settings/notification/app/LightsPreferenceController.java
+++ b/src/com/android/settings/notification/app/LightsPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.provider.Settings;
@@ -53,6 +54,11 @@
&& !isDefaultChannel();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_LOCKED_DEVICE);
+ }
+
public void updateState(Preference preference) {
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/app/MinImportancePreferenceController.java b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
index 69b7dc5..90f56b2 100644
--- a/src/com/android/settings/notification/app/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
@@ -61,6 +61,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
+ @Override
public void updateState(Preference preference) {
if (mAppRow != null && mChannel != null) {
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index 14c98cf..e2eb453 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -36,6 +36,7 @@
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.Comparator;
+import java.util.List;
import java.util.Objects;
/**
@@ -60,6 +61,7 @@
protected Drawable mConversationDrawable;
@Nullable
protected ShortcutInfo mConversationInfo;
+ protected List<String> mPreferenceFilter;
public NotificationPreferenceController(Context context, NotificationBackend backend) {
super(context);
@@ -87,6 +89,9 @@
}
}
if (mChannel != null) {
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
return mChannel.getImportance() != IMPORTANCE_NONE;
}
return true;
@@ -96,15 +101,19 @@
@Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
Drawable conversationDrawable,
ShortcutInfo conversationInfo,
- RestrictedLockUtils.EnforcedAdmin admin) {
+ RestrictedLockUtils.EnforcedAdmin admin,
+ List<String> preferenceFilter) {
mAppRow = appRow;
mChannel = channel;
mChannelGroup = group;
mAdmin = admin;
mConversationDrawable = conversationDrawable;
mConversationInfo = conversationInfo;
+ mPreferenceFilter = preferenceFilter;
}
+ abstract boolean isIncludedInFilter();
+
protected boolean checkCanBeVisible(int minImportanceVisible) {
if (mChannel == null) {
Log.w(TAG, "No channel");
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index af1d9c1..44c735a 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -74,6 +74,7 @@
protected NotificationBackend.AppRow mAppRow;
protected Drawable mConversationDrawable;
protected ShortcutInfo mConversationInfo;
+ protected List<String> mPreferenceFilter;
protected boolean mShowLegacyChannelConfig = false;
protected boolean mListeningToPackageRemove;
@@ -119,6 +120,7 @@
loadChannel();
loadAppRow();
loadChannelGroup();
+ loadPreferencesFilter();
collectConfigActivities();
if (use(HeaderPreferenceController.class) != null) {
@@ -131,7 +133,7 @@
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, null, null,
- mSuspendedAppsAdmin);
+ mSuspendedAppsAdmin, mPreferenceFilter);
}
}
}
@@ -181,9 +183,17 @@
loadChannel();
loadConversation();
loadChannelGroup();
+ loadPreferencesFilter();
collectConfigActivities();
}
+ private void loadPreferencesFilter() {
+ Intent intent = getActivity().getIntent();
+ mPreferenceFilter = intent != null
+ ? intent.getStringArrayListExtra(Settings.EXTRA_CHANNEL_FILTER_LIST)
+ : null;
+ }
+
private void loadChannel() {
Intent intent = getActivity().getIntent();
String channelId = intent != null ? intent.getStringExtra(Settings.EXTRA_CHANNEL_ID) : null;
diff --git a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
index 0d998eb..0c7cd23 100644
--- a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.content.Context;
import androidx.preference.Preference;
@@ -42,11 +43,19 @@
if (mAppRow == null) {
return false;
}
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
// Available only when other controllers are unavailable - this UI replaces the UI that
// would give more detailed notification controls.
return !super.isAvailable();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
public void updateState(Preference preference) {
if (mAppRow != null) {
if (mChannel != null) {
diff --git a/src/com/android/settings/notification/app/SoundPreferenceController.java b/src/com/android/settings/notification/app/SoundPreferenceController.java
index b3ac927..b23b4fc 100644
--- a/src/com/android/settings/notification/app/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/SoundPreferenceController.java
@@ -69,6 +69,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_SOUND);
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
diff --git a/src/com/android/settings/notification/app/VibrationPreferenceController.java b/src/com/android/settings/notification/app/VibrationPreferenceController.java
index b22c477..bfbe768 100644
--- a/src/com/android/settings/notification/app/VibrationPreferenceController.java
+++ b/src/com/android/settings/notification/app/VibrationPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification.app;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Vibrator;
@@ -54,6 +55,11 @@
&& mVibrator.hasVibrator();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_VIBRATION);
+ }
+
public void updateState(Preference preference) {
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/app/VisibilityPreferenceController.java b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
index 74e42b0..a2a1d76 100644
--- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
@@ -68,6 +68,11 @@
return checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_LOCKED_DEVICE);
+ }
+
public void updateState(Preference preference) {
if (mChannel != null && mAppRow != null) {
RestrictedListPreference pref = (RestrictedListPreference) preference;
diff --git a/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
index 342f3ad..b21991d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
@@ -22,7 +22,9 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.app.NotificationChannel;
import android.content.Context;
import android.content.pm.ShortcutInfo;
@@ -30,6 +32,8 @@
import com.android.settings.notification.NotificationBackend;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,12 +42,16 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class AddToHomeScreenPreferenceControllerTest {
private Context mContext;
@Mock
private NotificationBackend mBackend;
+ @Mock
+ private NotificationChannel mNc;
private AddToHomeScreenPreferenceController mController;
@@ -52,6 +60,7 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new AddToHomeScreenPreferenceController(mContext, mBackend);
+ when(mNc.getImportance()).thenReturn(4);
}
@Test
@@ -62,21 +71,41 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void testIsAvailable() {
ShortcutInfo si = mock(ShortcutInfo.class);
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class),
+ mNc, null, null, si, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class),
+ mNc, null, null, si, null,
+ ImmutableList.of(NotificationChannel.EDIT_LAUNCHER));
+ assertTrue(mController.isAvailable());
+ }
+
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class),
+ mNc, null, null, si, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testHandlePreferenceTreeClick() {
ShortcutInfo si = mock(ShortcutInfo.class);
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null,
+ null);
Preference pref = new Preference(RuntimeEnvironment.application);
pref.setKey("add_to_home");
diff --git a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
index 49d0a1d..be663d8 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
@@ -44,6 +44,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,6 +56,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class AllowSoundPreferenceControllerTest {
@@ -92,10 +96,11 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(null, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null,
+ null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +108,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +117,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something new");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,16 +127,37 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
+ mController.onResume(appRow, channel, null, null, null, null, ImmutableList.of(
+ NotificationChannel.EDIT_SOUND));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -145,7 +171,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -158,7 +184,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -170,7 +196,8 @@
public void testUpdateState_checkedForHighImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -181,7 +208,8 @@
public void testUpdateState_checkedForUnspecifiedImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -192,7 +220,8 @@
public void testUpdateState_notCheckedForLowImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +232,8 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -220,7 +250,8 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/AppBubbleListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AppBubbleListPreferenceControllerTest.java
index d176827..53ef86c 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AppBubbleListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AppBubbleListPreferenceControllerTest.java
@@ -104,7 +104,7 @@
public void isAvailable_BUBBLE_PREFERENCE_NONE_false() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertThat(mController.isAvailable()).isFalse();
}
@@ -113,7 +113,7 @@
public void isAvailable_BUBBLE_PREFERENCE_SELECTED_true() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -122,7 +122,7 @@
public void isAvailable_BUBBLE_PREFERENCE_ALL_true() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -131,7 +131,7 @@
public void filterAndSortConversations_BUBBLE_PREFERENCE_SELECTED_filtersAllowedBubbles() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
List<ConversationChannelWrapper> result =
mController.filterAndSortConversations(mConvoList.getList());
@@ -144,7 +144,7 @@
public void filterAndSortConversations_BUBBLE_PREFERENCE_ALL_filtersExcludedBubbles() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
List<ConversationChannelWrapper> result =
mController.filterAndSortConversations(mConvoList.getList());
@@ -158,7 +158,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
appRow.pkg = "PKG";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.mPreference = new PreferenceCategory(mContext);
ConversationChannelWrapper ccw = mConvoList.getList().get(0);
diff --git a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
index 41aeacb..2a23abd 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
@@ -75,7 +75,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -83,7 +83,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -92,7 +92,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -102,7 +102,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -113,16 +113,21 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_alwaysFiltered() {
+ assertFalse(mController.isIncludedInFilter());
+ }
+
+ @Test
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
Intent intent = new Intent("action");
appRow.settingsIntent = intent;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
index 277e6b2..9cdf64d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
@@ -47,6 +47,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,6 +59,9 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
public class BadgePreferenceControllerTest {
@@ -93,7 +98,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -102,7 +107,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +117,7 @@
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,7 +127,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 0);
assertFalse(mController.isAvailable());
@@ -131,7 +136,7 @@
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -144,7 +149,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -156,7 +161,7 @@
appRow.showBadge = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -168,18 +173,43 @@
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertFalse(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.showBadge = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
+
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.showBadge = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_LAUNCHER));
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
+
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -193,7 +223,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -206,7 +236,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canShowBadge()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -214,7 +244,7 @@
assertTrue(pref.isChecked());
when(channel.canShowBadge()).thenReturn(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -224,14 +254,14 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
assertTrue(pref.isChecked());
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -244,7 +274,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setShowBadge(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -263,7 +293,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setShowBadge(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -279,7 +309,7 @@
public void testOnPreferenceChange_on_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -296,7 +326,7 @@
public void testOnPreferenceChange_off_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
index 90c743a..d65f91d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
@@ -59,6 +59,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class BlockPreferenceControllerTest {
@@ -102,7 +104,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +114,7 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -122,7 +124,7 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -132,7 +134,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -140,7 +142,8 @@
public void testIsAvailable_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null,
+ null);
assertTrue(mController.isAvailable());
}
@@ -148,7 +151,7 @@
public void testIsAvailable_AppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -158,17 +161,41 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
- public void testIsAvailable_nonSystemApp() {
+ public void testIsAvailable_nonSystemApp_noFilter() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = false;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ ArrayList<String> filter = new ArrayList<>();
+ filter.add("no");
+ mController.onResume(appRow, channel, null, null, null, null, filter);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = false;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ ArrayList<String> filter = new ArrayList<>();
+ filter.add(NotificationChannel.EDIT_IMPORTANCE);
+ mController.onResume(appRow, channel, null, null, null, null, filter);
assertTrue(mController.isAvailable());
}
@@ -177,7 +204,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedImportance = true;
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.getSwitchBar().isEnabled());
}
@@ -186,7 +213,8 @@
public void testIsEnabled_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null,
+ null);
mController.updateState(mPreference);
assertFalse(mPreference.getSwitchBar().isEnabled());
}
@@ -195,7 +223,7 @@
public void testIsEnabled_systemAppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.getSwitchBar().isEnabled());
}
@@ -206,7 +234,7 @@
appRow.systemApp = true;
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setBlockable(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mPreference.getSwitchBar().isEnabled());
}
@@ -217,7 +245,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
@@ -230,7 +258,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
@@ -242,7 +270,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
@@ -252,7 +280,7 @@
@Test
public void testIsEnabled_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(mPreference);
@@ -263,13 +291,13 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mPreference.isChecked());
@@ -280,20 +308,20 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
appRow.banned = true;
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
when(group.isBlocked()).thenReturn(true);
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
when(group.isBlocked()).thenReturn(false);
mController.updateState(mPreference);
@@ -304,21 +332,21 @@
public void testUpdateState_channelBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
appRow.banned = true;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
appRow.banned = false;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mPreference.isChecked());
@@ -328,7 +356,7 @@
public void testUpdateState_noCrashIfCalledTwice() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
mController.updateState(mPreference);
}
@@ -337,7 +365,7 @@
public void testUpdateState_doesNotResetImportance() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
assertEquals(IMPORTANCE_LOW, channel.getImportance());
@@ -350,7 +378,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_UNSPECIFIED);
when(mBackend.onlyHasDefaultChannel(anyString(), anyInt())).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
@@ -372,7 +400,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
channel.setOriginalImportance(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
index ea963e3..f4f99c7 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
@@ -60,6 +60,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -125,7 +127,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -135,7 +137,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -146,7 +148,7 @@
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -154,7 +156,7 @@
@Test
public void isNotAvailable_ifOffGlobally_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -164,7 +166,7 @@
@Test
public void isNotAvailable_ifLowRam() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
final ShadowActivityManager activityManager =
Shadow.extract(mContext.getSystemService(ActivityManager.class));
@@ -178,7 +180,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -188,7 +190,7 @@
@Test
public void isAvailable_ifNotLowRam() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
final ShadowActivityManager activityManager =
@@ -200,7 +202,7 @@
@Test
public void isAvailable_app_evenIfOffGlobally() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -210,7 +212,7 @@
@Test
public void isAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -223,7 +225,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -235,18 +237,43 @@
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@Test
+ public void isAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_CONVERSATION));
+ Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
+
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void isAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
+
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void updateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -261,7 +288,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
mAppPageController.onResume(appRow, channel, null,
- null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class), null);
BubblePreference pref = new BubblePreference(mContext);
mAppPageController.updateState(pref);
@@ -276,7 +303,7 @@
appRow.pkg = "a";
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -291,7 +318,7 @@
appRow.pkg = "a";
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBubble()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -299,7 +326,7 @@
assertTrue(pref.isChecked());
when(channel.canBubble()).thenReturn(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -312,20 +339,20 @@
appRow.pkg = "a";
appRow.label = "App!";
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
mAppPageController.updateState(pref);
assertEquals(BUBBLE_PREFERENCE_ALL, pref.getSelectedPreference());
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
mAppPageController.updateState(pref);
assertEquals(BUBBLE_PREFERENCE_NONE, pref.getSelectedPreference());
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
mAppPageController.updateState(pref);
assertEquals(BUBBLE_PREFERENCE_SELECTED, pref.getSelectedPreference());
@@ -339,7 +366,7 @@
appRow.pkg = "a";
appRow.label = "App!";
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
mAppPageController.updateState(pref);
@@ -354,7 +381,7 @@
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -374,7 +401,7 @@
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -393,7 +420,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -413,7 +440,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -433,7 +460,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -452,7 +479,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -471,7 +498,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "a";
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mAppPageController.onResume(appRow, null, null, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null, null);
BubblePreference pref = new BubblePreference(mContext);
mAppPageController.onPreferenceChange(pref, BUBBLE_PREFERENCE_NONE);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
index f851c96..911f9a2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
@@ -23,8 +23,6 @@
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_OFF;
import static com.android.settings.notification.app.BubblePreferenceController.SYSTEM_WIDE_ON;
@@ -92,14 +90,14 @@
public void isAvailable_appBlocked_shouldReturnFalse() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_NOTIFICATION_BUBBLESisOn_shouldReturnTrue() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -107,7 +105,7 @@
@Test
public void isAvailable_NOTIFICATION_BUBBLESisOn_neverSentMsg_shouldReturnFalse() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
when(mBackend.hasSentValidMsg(anyString(), anyInt())).thenReturn(false);
assertFalse(mController.isAvailable());
@@ -117,7 +115,7 @@
public void isAvailable_NOTIFICATION_BUBBLESisOff_shouldReturnFalse() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
SYSTEM_WIDE_OFF);
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -128,7 +126,7 @@
SYSTEM_WIDE_OFF);
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(mAppRow, channel, null, null, null, null);
+ mController.onResume(mAppRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -139,7 +137,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(mAppRow, channel, null, null, null, null);
+ mController.onResume(mAppRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -147,7 +145,7 @@
@Test
public void isAvailable_lowRam_shouldReturnFalse() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
final ShadowActivityManager activityManager =
Shadow.extract(mContext.getSystemService(ActivityManager.class));
@@ -158,7 +156,7 @@
@Test
public void isAvailable_notLowRam_shouldReturnTrue() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
final ShadowActivityManager activityManager =
Shadow.extract(mContext.getSystemService(ActivityManager.class));
@@ -169,7 +167,7 @@
@Test
public void updateState_setsIntent() {
mAppRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mController.onResume(mAppRow, null, null, null, null, null);
+ mController.onResume(mAppRow, null, null, null, null, null, null);
Preference pref = new Preference(mContext);
mController.updateState(pref);
@@ -182,7 +180,7 @@
SYSTEM_WIDE_OFF);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
String noneString = mContext.getString(R.string.bubble_app_setting_none);
assertEquals(noneString, mController.getSummary());
@@ -195,7 +193,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_NONE;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
String noneString = mContext.getString(R.string.bubble_app_setting_none);
assertEquals(noneString, mController.getSummary());
@@ -208,7 +206,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
String allString = mContext.getString(R.string.bubble_app_setting_all);
assertEquals(allString, mController.getSummary());
@@ -221,7 +219,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.bubblePreference = BUBBLE_PREFERENCE_SELECTED;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
String selectedString = mContext.getString(R.string.bubble_app_setting_selected);
assertEquals(selectedString, mController.getSummary());
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
index 89007f0..0591cf2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
@@ -36,6 +36,8 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.notification.NotificationBackend;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,6 +48,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationDemotePreferenceControllerTest {
@@ -79,7 +83,7 @@
public void testIsAvailable_notConversation() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -89,7 +93,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -99,17 +103,38 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_CONVERSATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testHandlePreferenceClick() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = mock(Preference.class);
when(pref.getKey()).thenReturn("demote");
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
index 428a1a8..9b166ac 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
@@ -49,6 +49,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationHeaderPreferenceControllerTest {
@@ -88,7 +90,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -96,7 +98,15 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_ignoresFilter() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, null, null, null, null, null, new ArrayList<>());
assertTrue(mController.isAvailable());
}
@@ -105,11 +115,11 @@
ShortcutInfo si = mock(ShortcutInfo.class);
when(si.getLabel()).thenReturn("hello");
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, si, null);
+ mController.onResume(appRow, null, null, null, si, null, null);
assertEquals(si.getLabel(), mController.getLabel());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertEquals(channel.getName(), mController.getLabel());
}
@@ -117,25 +127,25 @@
public void testGetSummary() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertEquals("", mController.getSummary());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertEquals(appRow.label, mController.getSummary());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertTrue(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null, null);
assertEquals("", mController.getSummary());
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceControllerTest.java
index d74715c..692a4b1 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceControllerTest.java
@@ -34,7 +34,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
@@ -47,6 +46,8 @@
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,6 +58,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationPriorityPreferenceControllerTest {
@@ -95,7 +98,7 @@
@Test
public void testIsAvailable_notChannelNull() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,16 +106,37 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_IMPORTANCE));
+ assertTrue(mController.isAvailable());
+
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_CONVERSATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new ConversationPriorityPreference(mContext, null);
mController.updateState(pref);
@@ -126,7 +150,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ConversationPriorityPreference(mContext, null);
mController.updateState(pref);
@@ -141,7 +165,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ConversationPriorityPreference(mContext, null);
mController.updateState(pref);
@@ -156,7 +180,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ConversationPriorityPreference(mContext, null);
mController.updateState(pref);
@@ -170,7 +194,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setImportantConversation(true);
channel.setOriginalImportance(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
ConversationPriorityPreference pref = mock(ConversationPriorityPreference.class);
mController.updateState(pref);
@@ -185,7 +209,8 @@
public void testImportanceLowToImportant() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ConversationPriorityPreference pref = new ConversationPriorityPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -203,7 +228,8 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setAllowBubbles(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ConversationPriorityPreference pref = new ConversationPriorityPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -222,7 +248,8 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
channel.setAllowBubbles(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ConversationPriorityPreference pref = new ConversationPriorityPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -241,7 +268,8 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setAllowBubbles(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ConversationPriorityPreference pref = new ConversationPriorityPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -261,7 +289,8 @@
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setAllowBubbles(true);
channel.setImportantConversation(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ConversationPriorityPreference pref = new ConversationPriorityPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
index 80e2dd5..1c049be 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
@@ -38,6 +38,8 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.notification.NotificationBackend;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,6 +50,9 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.sql.Array;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationPromotePreferenceControllerTest {
@@ -81,7 +86,7 @@
public void testIsAvailable_notConversation() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -90,7 +95,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -100,18 +105,39 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_CONVERSATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testHandlePreferenceClick() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(true);
channel.setBypassDnd(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = mock(Preference.class);
when(pref.getKey()).thenReturn("convo_promote");
@@ -133,7 +159,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setConversationId("a", "a");
channel.setDemoted(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = mock(Preference.class);
when(pref.getKey()).thenReturn("wrong");
diff --git a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
index 5515a55..5c9de7c 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
@@ -46,6 +46,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class DeletedChannelsPreferenceControllerTest {
@@ -79,14 +81,15 @@
public void isAvailable_appScreen_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_groupScreen_never() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null,
+ null);
assertFalse(mController.isAvailable());
}
@@ -94,28 +97,29 @@
public void isAvailable_channelScreen_never() {
mController.onResume(
new NotificationBackend.AppRow(), mock(NotificationChannel.class), null, null, null,
- null);
+ null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen_notIfNoDeletedChannels() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(0);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
+ mController.onResume(
+ new NotificationBackend.AppRow(), null, null, null, null, null, new ArrayList<>());
assertTrue(mController.isAvailable());
}
@Test
public void updateState() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null, null);
Preference pref = mock(Preference.class);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
index 3e37327..3ce67a2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
@@ -74,7 +74,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -82,7 +82,7 @@
public void testIsAvailable_notIfChannelGroupBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -91,7 +91,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -100,7 +100,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -108,7 +108,7 @@
public void testIsAvailable_notIfNoChannelGroupDesc() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -118,7 +118,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -128,17 +128,22 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_alwaysFiltered() {
+ assertFalse(mController.isIncludedInFilter());
+ }
+
+ @Test
public void testUpdateState_channel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -153,7 +158,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
index 4220bed..22a7b09 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
@@ -44,6 +44,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,6 +56,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class DndPreferenceControllerTest {
@@ -83,7 +87,7 @@
public void testIsAvailable_app() {
when(mNm.getNotificationPolicy()).thenReturn(new NotificationManager.Policy(0, 0, 0, 0));
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -93,16 +97,37 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ when(mNm.getNotificationPolicy()).thenReturn(new NotificationManager.Policy(0, 0, 0, 1));
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_MIN);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_ZEN));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ when(mNm.getNotificationPolicy()).thenReturn(new NotificationManager.Policy(0, 0, 0, 1));
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_MIN);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -115,7 +140,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -128,7 +153,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -140,7 +165,8 @@
public void testUpdateState_bypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -152,7 +178,8 @@
public void testUpdateState_noBypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -164,7 +191,8 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -182,7 +210,8 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
index c4e94a9..9f90a16 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
@@ -48,6 +48,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class HeaderPreferenceControllerTest {
@@ -87,7 +89,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -95,7 +97,15 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_ignoredFilter() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, null, null, null, null, null, new ArrayList<>());
assertTrue(mController.isAvailable());
}
@@ -103,20 +113,20 @@
public void testGetLabel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertEquals(group.getName(), mController.getLabel());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertEquals(channel.getName(), mController.getLabel());
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
}
@@ -124,25 +134,25 @@
public void testGetSummary() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertEquals("", mController.getSummary());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertEquals(appRow.label, mController.getSummary());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertTrue(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null, null);
assertEquals("", mController.getSummary());
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
index 150fd2a..0db4678 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
@@ -52,6 +52,10 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.google.common.collect.ImmutableList;
+
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class HighImportancePreferenceControllerTest {
@@ -88,7 +92,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -96,7 +100,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -105,7 +109,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -115,7 +119,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -124,16 +128,35 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_IMPORTANCE));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -147,7 +170,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -162,7 +185,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -177,7 +200,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -189,7 +212,7 @@
public void testUpdateState_high() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -201,7 +224,7 @@
public void testUpdateState_default() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -213,7 +236,8 @@
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
index 3de7e7c..223fa23 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
@@ -48,6 +48,8 @@
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,6 +60,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ImportancePreferenceControllerTest {
@@ -94,7 +98,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -102,7 +106,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -113,7 +117,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,7 +126,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -132,7 +136,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -141,16 +145,35 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_IMPORTANCE));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -164,7 +187,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -179,7 +202,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -194,7 +217,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -206,7 +229,7 @@
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
ImportancePreference pref = mock(ImportancePreference.class);
mController.updateState(pref);
@@ -221,7 +244,8 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -239,7 +263,8 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
index aa87539..eb80465 100644
--- a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
@@ -24,6 +24,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.UserManager;
@@ -34,6 +35,8 @@
import com.android.settings.notification.NotificationBackend;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.google.common.collect.ImmutableList;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -46,6 +49,8 @@
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class InvalidConversationInfoPreferenceControllerTest {
@@ -90,7 +95,7 @@
appRow.pkg = "hi";
appRow.uid = 0;
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -100,7 +105,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -110,18 +115,39 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.pkg = "hi";
+ appRow.uid = 0;
+ mController.onResume(appRow, null, null, null, null, null, ImmutableList.of(
+ NotificationChannel.EDIT_CONVERSATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.pkg = "hi";
+ appRow.uid = 0;
+ mController.onResume(appRow, null, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState() {
when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
appRow.label = "plum";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Preference pref = new Preference(mContext);
mController.updateState(pref);
assertTrue(pref.getSummary().toString().contains(appRow.label));
diff --git a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationPreferenceControllerTest.java
index 4bfc1b4..965191c 100644
--- a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationPreferenceControllerTest.java
@@ -16,10 +16,6 @@
package com.android.settings.notification.app;
-import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
-import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
-import static android.app.NotificationManager.IMPORTANCE_HIGH;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -45,6 +41,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -57,6 +55,8 @@
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class InvalidConversationPreferenceControllerTest {
@@ -102,7 +102,7 @@
appRow.pkg = "hi";
appRow.uid = 0;
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +112,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,17 +122,38 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.pkg = "hi";
+ appRow.uid = 0;
+ mController.onResume(appRow, null, null, null, null, null, ImmutableList.of(
+ NotificationChannel.EDIT_CONVERSATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.pkg = "hi";
+ appRow.uid = 0;
+ mController.onResume(appRow, null, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
appRow.uid = 0;
mController.onResume(appRow, null, null,
- null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -144,7 +165,7 @@
public void testUpdateState_notChecked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "pkg";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
when(mBackend.hasUserDemotedInvalidMsgApp(anyString(), anyInt())).thenReturn(false);
@@ -157,7 +178,7 @@
public void testUpdateState_checked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "pkg";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
when(mBackend.hasUserDemotedInvalidMsgApp(anyString(), anyInt())).thenReturn(true);
@@ -170,7 +191,7 @@
public void testOnPreferenceChange_toggleEnabled() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "pkg";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
when(mBackend.hasUserDemotedInvalidMsgApp(anyString(), anyInt())).thenReturn(true);
@@ -189,7 +210,7 @@
public void testOnPreferenceChange_toggleDisabled() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "pkg";
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
when(mBackend.hasUserDemotedInvalidMsgApp(anyString(), anyInt())).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
index 4f3b496..e51a9e0 100644
--- a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
@@ -46,6 +46,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -58,6 +60,10 @@
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
+import javax.annotation.concurrent.Immutable;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class LightsPreferenceControllerTest {
@@ -107,7 +113,7 @@
com.android.internal.R.bool.config_intrusiveNotificationLed, false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +122,7 @@
Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -124,7 +130,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -133,7 +139,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -141,16 +147,33 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_LOCKED_DEVICE));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -163,7 +186,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -175,7 +198,8 @@
public void testUpdateState_lightsOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -186,7 +210,8 @@
public void testUpdateState_lightsOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -197,7 +222,8 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -214,7 +240,8 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
index f046820..3907db2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
@@ -52,6 +52,10 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.google.common.collect.ImmutableList;
+
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class MinImportancePreferenceControllerTest {
@@ -88,7 +92,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -96,7 +100,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -105,7 +109,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -115,7 +119,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -124,16 +128,35 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_IMPORTANCE));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -147,7 +170,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -162,7 +185,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -177,7 +200,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -189,7 +212,7 @@
public void testUpdateState_min() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -201,7 +224,7 @@
public void testUpdateState_low() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -213,7 +236,8 @@
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
index a9e4361..1fb9942 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
@@ -54,6 +54,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class NotificationPreferenceControllerTest {
@@ -90,7 +92,7 @@
@Test
public void isAvailable_notIfNull() {
- mController.onResume(null, null, null, null, null, null);
+ mController.onResume(null, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -99,7 +101,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
mController.onResume(appRow, mock(NotificationChannel.class),
- mock(NotificationChannelGroup.class), null, null, null);
+ mock(NotificationChannelGroup.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -111,7 +113,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,12 +124,26 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
when(group.isBlocked()).thenReturn(true);
assertFalse(mController.isAvailable());
}
@Test
+ public void isAvailable_notIfFailsFilterCheck() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+ NotificationChannelGroup group = mock(NotificationChannelGroup.class);
+ when(group.isBlocked()).thenReturn(false);
+ ArrayList<String> filter = new ArrayList<>();
+ filter.add("something");
+
+ mController.onResume(appRow, channel, group, null, null, null, filter);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void isAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
@@ -135,7 +151,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, channel, group, null, null, null);
+ mController.onResume(appRow, channel, group, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -146,7 +162,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
- mController.onResume(appRow, channel, group, null, null, admin);
+ mController.onResume(appRow, channel, group, null, null, admin, null);
assertEquals(appRow, mController.mAppRow);
assertEquals(channel, mController.mChannel);
@@ -160,7 +176,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -170,7 +186,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_LOW));
}
@@ -180,7 +196,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -190,7 +206,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.checkCanBeVisible(IMPORTANCE_DEFAULT));
}
@@ -200,7 +216,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
mController.saveChannel();
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
@@ -212,11 +228,11 @@
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isChannelBlockable());
when(channel.isImportanceLockedByOEM()).thenReturn(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -227,7 +243,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -238,7 +254,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockable()).thenReturn(false);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -250,7 +266,7 @@
when(channel.isBlockable()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -261,7 +277,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockable()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -273,7 +289,7 @@
when(channel.isBlockable()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -284,7 +300,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@@ -296,7 +312,7 @@
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -308,7 +324,7 @@
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -319,7 +335,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertFalse(mController.isChannelGroupBlockable());
}
@@ -330,13 +346,14 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@Test
public void testIsDefaultChannel_noChannel() {
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null,
+ null);
assertFalse(mController.isDefaultChannel());
}
@@ -344,7 +361,8 @@
@Test
public void testIsDefaultChannel_nonDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null,
+ null, null);
assertFalse(mController.isDefaultChannel());
}
@@ -353,7 +371,8 @@
public void testIsDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn(NotificationChannel.DEFAULT_CHANNEL_ID);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null,
+ null, null);
assertTrue(mController.isDefaultChannel());
}
@@ -365,6 +384,11 @@
}
@Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
+ @Override
public String getPreferenceKey() {
return null;
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
index cfbe5f7..34e94a0 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
@@ -34,6 +34,8 @@
import com.android.settings.notification.NotificationBackend;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,6 +45,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class NotificationsOffPreferenceControllerTest {
@@ -72,7 +76,7 @@
public void testIsAvailable_yesIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -81,7 +85,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -90,16 +94,35 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_IMPORTANCE));
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
public void testUpdateState_channel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -113,7 +136,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null, null, null);
+ mController.onResume(appRow, null, group, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -126,7 +149,7 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
index 0d18c1f..c79b97d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
@@ -53,6 +53,8 @@
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,6 +67,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class SoundPreferenceControllerTest {
@@ -108,7 +112,7 @@
@Test
public void testIsAvailable_notIfChannelNull() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +120,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +129,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -133,11 +137,28 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_SOUND));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testDisplayPreference_savesPreference() {
NotificationSoundPreference pref = mock(NotificationSoundPreference.class);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -152,7 +173,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
Preference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -166,7 +187,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
Preference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -182,7 +203,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
when(channel.getSound()).thenReturn(sound);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -198,7 +219,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(sound, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -238,7 +259,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_ALARM).build());
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -259,7 +280,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build());
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -280,7 +301,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_UNKNOWN).build());
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
diff --git a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
index 06a319f..0fb5e72 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
@@ -45,6 +45,8 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,6 +57,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class VibrationPreferenceControllerTest {
@@ -98,7 +102,7 @@
when(mVibrator.hasVibrator()).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -106,7 +110,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -115,7 +119,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -123,16 +127,33 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_VIBRATION));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -145,7 +166,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -158,7 +179,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -170,7 +191,8 @@
public void testUpdateState_vibrateOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -182,7 +204,8 @@
public void testUpdateState_vibrateOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -194,7 +217,8 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -210,7 +234,8 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null,
+ null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
index 2150c82..a061208 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
@@ -51,6 +51,8 @@
import com.android.settings.testutils.shadow.ShadowRestrictionUtils;
import com.android.settingslib.RestrictedLockUtils;
+import com.google.common.collect.ImmutableList;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -121,7 +123,7 @@
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -129,7 +131,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -138,15 +140,32 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
+ public void testIsAvailable_filteredIn() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null,
+ ImmutableList.of(NotificationChannel.EDIT_LOCKED_DEVICE));
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_filteredOut() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null, new ArrayList<>());
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
public void testUpdateState_disabledByAdmin_disableSecure() {
ShadowRestrictionUtils.setRestricted(true);
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
@@ -160,7 +179,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -182,7 +201,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
- RestrictedLockUtils.EnforcedAdmin.class));
+ RestrictedLockUtils.EnforcedAdmin.class), null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -197,7 +216,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -222,7 +241,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -245,7 +264,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -262,7 +281,7 @@
public void testUpdateState_noGlobalRestriction() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -293,7 +312,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -312,7 +331,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -331,7 +350,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -350,7 +369,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null, null, null);
+ mController.onResume(appRow, channel, null, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);