diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 44a21acbe4c..707cae938b9 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"/>
-
-
-
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 15b838843a7..e5afd9d3db0 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;
@@ -47,6 +48,11 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC
return mConversationInfo != null;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_LAUNCHER);
+ }
+
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY.equals(preference.getKey())) {
diff --git a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
index cf6db877d23..0664c544bec 100644
--- a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
@@ -58,6 +58,11 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_SOUND);
+ }
+
@Override
public void updateState(Preference preference) {
if (mChannel != null) {
diff --git a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
index 59fa4407e37..3aeb73c9b25 100644
--- a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
@@ -90,7 +90,7 @@ public class AppBubbleNotificationSettings extends NotificationSettings implemen
}
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 297bfdb97bb..5e12bbd7f57 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
@@ -114,6 +114,11 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
return mAppRow != null;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
@Override
public void updateState(Preference preference) {
if (mAppRow != null) {
diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
index 4dcbcfc9044..4fab7e277ea 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndSettings.java
@@ -53,7 +53,7 @@ public class AppChannelsBypassingDndSettings extends NotificationSettings {
}
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 2054a16df26..0e89be3ddda 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -74,6 +74,11 @@ public class AppConversationListPreferenceController extends NotificationPrefere
mAppRow.pkg, mAppRow.uid);
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
@Override
public void updateState(Preference preference) {
mPreference = (PreferenceCategory) preference;
diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
index 23ccbf0c075..043ae698f54 100644
--- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
@@ -48,6 +48,11 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
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 58c18bae43a..d7694d7e45e 100644
--- a/src/com/android/settings/notification/app/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppNotificationSettings.java
@@ -79,7 +79,8 @@ public class AppNotificationSettings extends NotificationSettings {
}
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 9f8608e63c8..108fa1d7a07 100644
--- a/src/com/android/settings/notification/app/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/app/BadgePreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.notification.app;
import static android.provider.Settings.Secure.NOTIFICATION_BADGING;
+import android.app.NotificationChannel;
import android.content.Context;
import android.provider.Settings;
@@ -67,6 +68,11 @@ public class BadgePreferenceController extends NotificationPreferenceController
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 4df3e281f61..d5d516eaf73 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_LOW;
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 @@ public class BlockPreferenceController extends NotificationPreferenceController
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 f8983ff39c7..43f0baace1c 100644
--- a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
@@ -43,6 +43,11 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo
return areBubblesEnabled();
}
+ @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 ff270436df4..3439543353e 100644
--- a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
@@ -43,6 +43,11 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro
return areBubblesEnabled();
}
+ @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 8f452f7e750..6caa95e0cdd 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -21,6 +21,7 @@ import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
import android.app.ActivityManager;
import android.annotation.Nullable;
+import android.app.NotificationChannel;
import android.content.Context;
import android.provider.Settings;
@@ -84,6 +85,11 @@ public class BubblePreferenceController extends NotificationPreferenceController
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_CONVERSATION);
+ }
+
@Override
public void updateState(Preference preference) {
if (mIsAppPage && mAppRow != null) {
diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
index 236e6283e90..5b2a97325e9 100644
--- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
@@ -66,6 +66,11 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
return isGloballyEnabled() && mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid);
}
+ @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 5fd607f0adf..b1109ecbadc 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -84,6 +84,11 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
return true;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return false;
+ }
+
@Override
public void updateState(Preference preference) {
mPreference = (PreferenceCategory) preference;
diff --git a/src/com/android/settings/notification/app/ChannelNotificationSettings.java b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
index 319c7988f14..bdea30dbe3d 100644
--- a/src/com/android/settings/notification/app/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
@@ -79,7 +79,8 @@ public class ChannelNotificationSettings extends NotificationSettings {
}
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 6583a23b151..02f639c3157 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 @@ public class ConversationDemotePreferenceController extends NotificationPreferen
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 50a8b23a554..313b387a7da 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -59,6 +59,11 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
return mAppRow != null;
}
+ @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 902c81c8996..819ba836511 100644
--- a/src/com/android/settings/notification/app/ConversationNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
@@ -49,7 +49,7 @@ public class ConversationNotificationSettings extends NotificationSettings {
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 e59f277699f..9730104d303 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 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer
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 5a6fa51b2c8..24c3d2ff6a1 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 @@ public class ConversationPromotePreferenceController extends NotificationPrefere
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 5a60f3f4473..77a692f1488 100644
--- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
@@ -51,6 +51,11 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
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 f4ad6a32704..0a5bb2f9260 100644
--- a/src/com/android/settings/notification/app/DescriptionPreferenceController.java
+++ b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
@@ -54,6 +54,11 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr
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 90e6b250991..b65928aa915 100644
--- a/src/com/android/settings/notification/app/DndPreferenceController.java
+++ b/src/com/android/settings/notification/app/DndPreferenceController.java
@@ -47,6 +47,11 @@ public class DndPreferenceController extends NotificationPreferenceController
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 809871466ea..6482943544b 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -59,6 +59,11 @@ public class HeaderPreferenceController extends NotificationPreferenceController
return mAppRow != null;
}
+ @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 3aecfa87365..67fb2ff1be5 100644
--- a/src/com/android/settings/notification/app/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
@@ -22,12 +22,12 @@ import static android.app.NotificationManager.IMPORTANCE_HIGH;
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 {
@@ -60,6 +60,11 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
return mChannel.getImportance() >= IMPORTANCE_DEFAULT;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
@Override
public void updateState(Preference preference) {
if (mAppRow != null && mChannel != null) {
diff --git a/src/com/android/settings/notification/app/ImportancePreferenceController.java b/src/com/android/settings/notification/app/ImportancePreferenceController.java
index dc7f29bd537..ed3410c1459 100644
--- a/src/com/android/settings/notification/app/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/ImportancePreferenceController.java
@@ -58,6 +58,11 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
return !isDefaultChannel();
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
@Override
public void updateState(Preference preference) {
if (mAppRow!= null && mChannel != null) {
diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
index ade9653a5fc..b937e80e0d6 100644
--- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
@@ -47,9 +47,17 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
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) {
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index cf66474afc8..5c502dccbe0 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -47,9 +47,17 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
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) {
diff --git a/src/com/android/settings/notification/app/LightsPreferenceController.java b/src/com/android/settings/notification/app/LightsPreferenceController.java
index fc9f34cdc8e..d096922e348 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 @@ public class LightsPreferenceController extends NotificationPreferenceController
&& !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 69b7dc59e86..90f56b295d3 100644
--- a/src/com/android/settings/notification/app/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
@@ -60,6 +60,11 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
return mChannel.getImportance() <= IMPORTANCE_LOW;
}
+ @Override
+ boolean isIncludedInFilter() {
+ return mPreferenceFilter.contains(NotificationChannel.EDIT_IMPORTANCE);
+ }
+
@Override
public void updateState(Preference preference) {
if (mAppRow != null && mChannel != null) {
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index 14c98cfa5bb..e2eb453a780 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.RestrictedLockUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.Comparator;
+import java.util.List;
import java.util.Objects;
/**
@@ -60,6 +61,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
protected Drawable mConversationDrawable;
@Nullable
protected ShortcutInfo mConversationInfo;
+ protected List mPreferenceFilter;
public NotificationPreferenceController(Context context, NotificationBackend backend) {
super(context);
@@ -87,6 +89,9 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
}
}
if (mChannel != null) {
+ if (mPreferenceFilter != null && !isIncludedInFilter()) {
+ return false;
+ }
return mChannel.getImportance() != IMPORTANCE_NONE;
}
return true;
@@ -96,15 +101,19 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
@Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
Drawable conversationDrawable,
ShortcutInfo conversationInfo,
- RestrictedLockUtils.EnforcedAdmin admin) {
+ RestrictedLockUtils.EnforcedAdmin admin,
+ List 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 af1d9c1e7f4..44c735abc1f 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -74,6 +74,7 @@ abstract public class NotificationSettings extends DashboardFragment {
protected NotificationBackend.AppRow mAppRow;
protected Drawable mConversationDrawable;
protected ShortcutInfo mConversationInfo;
+ protected List mPreferenceFilter;
protected boolean mShowLegacyChannelConfig = false;
protected boolean mListeningToPackageRemove;
@@ -119,6 +120,7 @@ abstract public class NotificationSettings extends DashboardFragment {
loadChannel();
loadAppRow();
loadChannelGroup();
+ loadPreferencesFilter();
collectConfigActivities();
if (use(HeaderPreferenceController.class) != null) {
@@ -131,7 +133,7 @@ abstract public class NotificationSettings extends DashboardFragment {
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, null, null,
- mSuspendedAppsAdmin);
+ mSuspendedAppsAdmin, mPreferenceFilter);
}
}
}
@@ -181,9 +183,17 @@ abstract public class NotificationSettings extends DashboardFragment {
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 0d998eb9061..0c7cd2361e2 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 @@ public class NotificationsOffPreferenceController extends NotificationPreference
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 b3ac9270e66..b23b4fc86cb 100644
--- a/src/com/android/settings/notification/app/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/SoundPreferenceController.java
@@ -68,6 +68,11 @@ public class SoundPreferenceController extends NotificationPreferenceController
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel();
}
+ @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 b22c4774456..bfbe768600f 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 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
&& 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 74e42b0e7b6..a2a1d76b71c 100644
--- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
@@ -68,6 +68,11 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
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 342f3ad077d..b21991ddece 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.any;
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 androidx.preference.Preference;
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.mockito.MockitoAnnotations;
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 @@ public class AddToHomeScreenPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new AddToHomeScreenPreferenceController(mContext, mBackend);
+ when(mNc.getImportance()).thenReturn(4);
}
@Test
@@ -62,21 +71,41 @@ public class AddToHomeScreenPreferenceControllerTest {
@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 49d0a1d2911..be663d8f8c8 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.settings.notification.NotificationBackend;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class AllowSoundPreferenceControllerTest {
@@ -92,10 +96,11 @@ public class AllowSoundPreferenceControllerTest {
@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 class AllowSoundPreferenceControllerTest {
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 @@ public class AllowSoundPreferenceControllerTest {
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 @@ public class AllowSoundPreferenceControllerTest {
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 @@ public class AllowSoundPreferenceControllerTest {
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 @@ public class AllowSoundPreferenceControllerTest {
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 class AllowSoundPreferenceControllerTest {
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 class AllowSoundPreferenceControllerTest {
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 class AllowSoundPreferenceControllerTest {
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 class AllowSoundPreferenceControllerTest {
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 class AllowSoundPreferenceControllerTest {
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 d176827c08b..53ef86cecb7 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 class AppBubbleListPreferenceControllerTest {
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 class AppBubbleListPreferenceControllerTest {
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 class AppBubbleListPreferenceControllerTest {
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 class AppBubbleListPreferenceControllerTest {
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 result =
mController.filterAndSortConversations(mConvoList.getList());
@@ -144,7 +144,7 @@ public class AppBubbleListPreferenceControllerTest {
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 result =
mController.filterAndSortConversations(mConvoList.getList());
@@ -158,7 +158,7 @@ public class AppBubbleListPreferenceControllerTest {
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 41aeacbc03f..2a23abd2fed 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 @@ public class AppLinkPreferenceControllerTest {
@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 class AppLinkPreferenceControllerTest {
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 @@ public class AppLinkPreferenceControllerTest {
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 @@ public class AppLinkPreferenceControllerTest {
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 @@ public class AppLinkPreferenceControllerTest {
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 277e6b2dd7e..9cdf64dc79d 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.settings.notification.NotificationBackend;
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.RobolectricTestRunner;
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 class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
@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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 @@ public class BadgePreferenceControllerTest {
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 class BadgePreferenceControllerTest {
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 class BadgePreferenceControllerTest {
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 90c743a8b24..d65f91dd0b1 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class BlockPreferenceControllerTest {
@@ -102,7 +104,7 @@ public class BlockPreferenceControllerTest {
@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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 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 filter = new ArrayList<>();
+ filter.add(NotificationChannel.EDIT_IMPORTANCE);
+ mController.onResume(appRow, channel, null, null, null, null, filter);
assertTrue(mController.isAvailable());
}
@@ -177,7 +204,7 @@ public class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
@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 class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 @@ public class BlockPreferenceControllerTest {
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 ea963e3db1c..f4f99c7fc5a 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.settings.notification.NotificationBackend;
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
@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 @@ public class BubblePreferenceControllerTest {
@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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
@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 @@ public class BubblePreferenceControllerTest {
@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 @@ public class BubblePreferenceControllerTest {
@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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 @@ public class BubblePreferenceControllerTest {
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 f851c968657..911f9a2dd1b 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.BUBBLE_PREFERENCE_SELECTED;
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 class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
@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 class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
@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 @@ public class BubbleSummaryPreferenceControllerTest {
@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 @@ public class BubbleSummaryPreferenceControllerTest {
@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 @@ public class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
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 @@ public class BubbleSummaryPreferenceControllerTest {
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 89007f0bd7c..0591cf28a57 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 androidx.preference.Preference;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationDemotePreferenceControllerTest {
@@ -79,7 +83,7 @@ public class ConversationDemotePreferenceControllerTest {
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 @@ public class ConversationDemotePreferenceControllerTest {
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 @@ public class ConversationDemotePreferenceControllerTest {
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 428a1a8fc43..9b166ac0689 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationHeaderPreferenceControllerTest {
@@ -88,7 +90,7 @@ public class ConversationHeaderPreferenceControllerTest {
@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 class ConversationHeaderPreferenceControllerTest {
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 @@ public class ConversationHeaderPreferenceControllerTest {
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 class ConversationHeaderPreferenceControllerTest {
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 d74715c9da4..692a4b18b5c 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.times;
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 androidx.preference.PreferenceScreen;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ConversationPriorityPreferenceControllerTest {
@@ -95,7 +98,7 @@ public class ConversationPriorityPreferenceControllerTest {
@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 class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 @@ public class ConversationPriorityPreferenceControllerTest {
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 80e2dd5d103..1c049be125d 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 androidx.preference.Preference;
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.RobolectricTestRunner;
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 class ConversationPromotePreferenceControllerTest {
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 @@ public class ConversationPromotePreferenceControllerTest {
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,10 +105,31 @@ public class ConversationPromotePreferenceControllerTest {
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();
@@ -111,7 +137,7 @@ public class ConversationPromotePreferenceControllerTest {
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 @@ public class ConversationPromotePreferenceControllerTest {
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 5515a55efb6..5c9de7cb30b 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class DeletedChannelsPreferenceControllerTest {
@@ -79,14 +81,15 @@ public class DeletedChannelsPreferenceControllerTest {
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 class DeletedChannelsPreferenceControllerTest {
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 3e37327f6fc..3ce67a239ec 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 @@ public class DescriptionPreferenceControllerTest {
@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 class DescriptionPreferenceControllerTest {
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 @@ public class DescriptionPreferenceControllerTest {
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 @@ public class DescriptionPreferenceControllerTest {
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 class DescriptionPreferenceControllerTest {
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 @@ public class DescriptionPreferenceControllerTest {
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 @@ public class DescriptionPreferenceControllerTest {
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 @@ public class DescriptionPreferenceControllerTest {
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 4220beda0da..22a7b0946bc 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.settings.notification.NotificationBackend;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class DndPreferenceControllerTest {
@@ -83,7 +87,7 @@ public class DndPreferenceControllerTest {
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 @@ public class DndPreferenceControllerTest {
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 @@ public class DndPreferenceControllerTest {
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 @@ public class DndPreferenceControllerTest {
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 class DndPreferenceControllerTest {
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 class DndPreferenceControllerTest {
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 class DndPreferenceControllerTest {
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 class DndPreferenceControllerTest {
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 c4e94a9ce02..9f90a16175b 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class HeaderPreferenceControllerTest {
@@ -87,7 +89,7 @@ public class HeaderPreferenceControllerTest {
@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 class HeaderPreferenceControllerTest {
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 class HeaderPreferenceControllerTest {
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 class HeaderPreferenceControllerTest {
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 150fd2ad6a1..0db46789d19 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 org.robolectric.shadows.ShadowApplication;
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 @@ public class HighImportancePreferenceControllerTest {
@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 class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 @@ public class HighImportancePreferenceControllerTest {
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 class HighImportancePreferenceControllerTest {
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 class HighImportancePreferenceControllerTest {
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 class HighImportancePreferenceControllerTest {
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 3de7e7ce312..223fa23324b 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 androidx.preference.PreferenceScreen;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class ImportancePreferenceControllerTest {
@@ -94,7 +98,7 @@ public class ImportancePreferenceControllerTest {
@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 class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 @@ public class ImportancePreferenceControllerTest {
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 aa87539e7c6..eb8046567b2 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.mock;
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 androidx.preference.PreferenceScreen;
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.RuntimeEnvironment;
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 @@ public class InvalidConversationInfoPreferenceControllerTest {
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 @@ public class InvalidConversationInfoPreferenceControllerTest {
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,10 +115,31 @@ public class InvalidConversationInfoPreferenceControllerTest {
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);
@@ -121,7 +147,7 @@ public class InvalidConversationInfoPreferenceControllerTest {
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 4bfc1b4eb7a..965191c2966 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.settings.testutils.shadow.SettingsShadowResources;
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.RuntimeEnvironment;
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 @@ public class InvalidConversationPreferenceControllerTest {
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 @@ public class InvalidConversationPreferenceControllerTest {
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 @@ public class InvalidConversationPreferenceControllerTest {
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 class InvalidConversationPreferenceControllerTest {
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 class InvalidConversationPreferenceControllerTest {
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 class InvalidConversationPreferenceControllerTest {
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 class InvalidConversationPreferenceControllerTest {
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 4f3b4962ea6..e51a9e003ba 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.settings.testutils.shadow.SettingsShadowResources;
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.RuntimeEnvironment;
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 @@ public class LightsPreferenceControllerTest {
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 @@ public class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 @@ public class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 @@ public class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 class LightsPreferenceControllerTest {
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 f0468204202..3907db22f92 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 org.robolectric.shadows.ShadowApplication;
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 @@ public class MinImportancePreferenceControllerTest {
@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 class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 @@ public class MinImportancePreferenceControllerTest {
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 class MinImportancePreferenceControllerTest {
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 class MinImportancePreferenceControllerTest {
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 class MinImportancePreferenceControllerTest {
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 a9e4361d37d..1fb9942fcb2 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class NotificationPreferenceControllerTest {
@@ -90,7 +92,7 @@ public class NotificationPreferenceControllerTest {
@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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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,11 +124,25 @@ public class NotificationPreferenceControllerTest {
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 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();
@@ -135,7 +151,7 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
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 @@ public class NotificationPreferenceControllerTest {
@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 class NotificationPreferenceControllerTest {
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());
}
@@ -364,6 +383,11 @@ public class NotificationPreferenceControllerTest {
super(context, backend);
}
+ @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 cfbe5f7120d..34e94a042f9 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 androidx.preference.Preference;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class NotificationsOffPreferenceControllerTest {
@@ -72,7 +76,7 @@ public class NotificationsOffPreferenceControllerTest {
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 @@ public class NotificationsOffPreferenceControllerTest {
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 @@ public class NotificationsOffPreferenceControllerTest {
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 @@ public class NotificationsOffPreferenceControllerTest {
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 class NotificationsOffPreferenceControllerTest {
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 0d18c1f9aef..c79b97d3ba2 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.SettingsPreferenceFragment;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class SoundPreferenceControllerTest {
@@ -108,7 +112,7 @@ public class SoundPreferenceControllerTest {
@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 class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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,10 +137,27 @@ public class SoundPreferenceControllerTest {
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);
@@ -152,7 +173,7 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 @@ public class SoundPreferenceControllerTest {
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 06a319f7ad1..0fb5e72eb51 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.settings.notification.NotificationBackend;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
public class VibrationPreferenceControllerTest {
@@ -98,7 +102,7 @@ public class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 @@ public class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 @@ public class VibrationPreferenceControllerTest {
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 @@ public class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 class VibrationPreferenceControllerTest {
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 2150c820afc..a0612086aa0 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.notification.NotificationBackend;
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 @@ public class VisibilityPreferenceControllerTest {
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 class VisibilityPreferenceControllerTest {
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,14 +140,31 @@ public class VisibilityPreferenceControllerTest {
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);
@@ -160,7 +179,7 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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 @@ public class VisibilityPreferenceControllerTest {
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);