This value shouldn't be used on "real" ZenPolicy objects sent to or returned from
- * {@link android.app.NotificationManager}; it's a way of representing rules with interruption
- * filter = {@link NotificationManager#INTERRUPTION_FILTER_ALL} in the UI.
- */
- public static final int CHANNEL_POLICY_ALL = -1;
-
static final String MANUAL_DND_MODE_ID = "manual_dnd";
- @SuppressLint("WrongConstant")
- private static final ZenPolicy POLICY_INTERRUPTION_FILTER_ALL =
- new ZenPolicy.Builder()
- .allowChannels(CHANNEL_POLICY_ALL)
- .allowAllSounds()
- .showAllVisualEffects()
- .build();
-
// Must match com.android.server.notification.ZenModeHelper#applyCustomPolicy.
private static final ZenPolicy POLICY_INTERRUPTION_FILTER_ALARMS =
new ZenPolicy.Builder()
@@ -141,10 +123,8 @@ class ZenMode {
public ZenPolicy getPolicy() {
switch (mRule.getInterruptionFilter()) {
case INTERRUPTION_FILTER_PRIORITY:
- return requireNonNull(mRule.getZenPolicy());
-
case NotificationManager.INTERRUPTION_FILTER_ALL:
- return POLICY_INTERRUPTION_FILTER_ALL;
+ return requireNonNull(mRule.getZenPolicy());
case NotificationManager.INTERRUPTION_FILTER_ALARMS:
return POLICY_INTERRUPTION_FILTER_ALARMS;
@@ -172,31 +152,8 @@ class ZenMode {
return;
}
- // A policy with CHANNEL_POLICY_ALL is only a UI representation of the
- // INTERRUPTION_FILTER_ALL filter. Thus, switching to or away to this value only updates
- // the filter, discarding the rest of the supplied policy.
- if (policy.getAllowedChannels() == CHANNEL_POLICY_ALL
- && currentPolicy.getAllowedChannels() != CHANNEL_POLICY_ALL) {
- if (mIsManualDnd) {
- throw new IllegalArgumentException("Manual DND cannot have CHANNEL_POLICY_ALL");
- }
- mRule.setInterruptionFilter(INTERRUPTION_FILTER_ALL);
- // Preserve the existing policy, e.g. if the user goes PRIORITY -> ALL -> PRIORITY that
- // shouldn't discard all other policy customizations. The existing policy will be a
- // synthetic one if the rule originally had filter NONE or ALARMS_ONLY and that's fine.
- if (mRule.getZenPolicy() == null) {
- mRule.setZenPolicy(currentPolicy);
- }
- return;
- } else if (policy.getAllowedChannels() != CHANNEL_POLICY_ALL
- && currentPolicy.getAllowedChannels() == CHANNEL_POLICY_ALL) {
- mRule.setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY);
- // Go back to whatever policy the rule had before, unless the rule never had one, in
- // which case we use the supplied policy (which we know has a valid allowedChannels).
- if (mRule.getZenPolicy() == null) {
- mRule.setZenPolicy(policy);
- }
- return;
+ if (mRule.getInterruptionFilter() == INTERRUPTION_FILTER_ALL) {
+ Log.wtf(TAG, "Able to change policy without filtering being enabled");
}
// If policy is customized from any of the "special" ones, make the rule PRIORITY.
diff --git a/src/com/android/settings/notification/modes/ZenModeAppsFragment.java b/src/com/android/settings/notification/modes/ZenModeAppsFragment.java
index 73329a242fd..19035ddcf78 100644
--- a/src/com/android/settings/notification/modes/ZenModeAppsFragment.java
+++ b/src/com/android/settings/notification/modes/ZenModeAppsFragment.java
@@ -37,10 +37,6 @@ public class ZenModeAppsFragment extends ZenModeFragmentBase {
context, ZenModeAppsPreferenceController.KEY_PRIORITY, mBackend));
controllers.add(new ZenModeAppsPreferenceController(
context, ZenModeAppsPreferenceController.KEY_NONE, mBackend));
- // TODO: b/308819928 - The manual DND mode cannot have the ALL type;
- // unify the controllers into one and only create a preference if isManualDnd is false.
- controllers.add(new ZenModeAppsPreferenceController(
- context, ZenModeAppsPreferenceController.KEY_ALL, mBackend));
return controllers;
}
diff --git a/src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java
index 691c92e2e3c..6835e6cd853 100644
--- a/src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java
+++ b/src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java
@@ -16,6 +16,8 @@
package com.android.settings.notification.modes;
+import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
+
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
import android.content.Context;
@@ -45,10 +47,12 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
private static final String TAG = "ZenModeAppsLinkPreferenceController";
private final ZenModeSummaryHelper mSummaryHelper;
+ private final ApplicationsState mApplicationsState;
private ApplicationsState.Session mAppSession;
private final ZenHelperBackend mHelperBackend;
private ZenMode mZenMode;
private Preference mPreference;
+ private final Fragment mHost;
ZenModeAppsLinkPreferenceController(Context context, String key, Fragment host,
ApplicationsState applicationsState, ZenModesBackend backend,
@@ -56,9 +60,13 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
super(context, key, backend);
mSummaryHelper = new ZenModeSummaryHelper(mContext, helperBackend);
mHelperBackend = helperBackend;
- if (applicationsState != null && host != null) {
- mAppSession = applicationsState.newSession(mAppSessionCallbacks, host.getLifecycle());
- }
+ mApplicationsState = applicationsState;
+ mHost = host;
+ }
+
+ @Override
+ public boolean isAvailable(ZenMode zenMode) {
+ return zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL;
}
@Override
@@ -73,6 +81,9 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
.toIntent());
mZenMode = zenMode;
mPreference = preference;
+ if (mApplicationsState != null && mHost != null) {
+ mAppSession = mApplicationsState.newSession(mAppSessionCallbacks, mHost.getLifecycle());
+ }
triggerUpdateAppsBypassingDndSummaryText();
}
diff --git a/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java
index 704bce04504..d5ef0440b5e 100644
--- a/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java
+++ b/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java
@@ -38,11 +38,9 @@ public class ZenModeAppsPreferenceController extends
static final String KEY_PRIORITY = "zen_mode_apps_priority";
static final String KEY_NONE = "zen_mode_apps_none";
- static final String KEY_ALL = "zen_mode_apps_all";
String mModeId;
-
public ZenModeAppsPreferenceController(@NonNull Context context,
@NonNull String key, @Nullable ZenModesBackend backend) {
super(context, key, backend);
@@ -79,13 +77,6 @@ public class ZenModeAppsPreferenceController extends
== ZenPolicy.CHANNEL_POLICY_NONE;
pref.setChecked(policy_none);
break;
- case KEY_ALL:
- // A UI-only setting; the underlying policy never actually has this value,
- // but ZenMode acts as though it does for the sake of UI consistency.
- boolean policy_all = zenMode.getPolicy().getAllowedChannels()
- == ZenMode.CHANNEL_POLICY_ALL;
- pref.setChecked(policy_all);
- break;
}
}
@@ -96,8 +87,6 @@ public class ZenModeAppsPreferenceController extends
return savePolicy(p -> p.allowChannels(ZenPolicy.CHANNEL_POLICY_PRIORITY));
case KEY_NONE:
return savePolicy(p -> p.allowChannels(ZenPolicy.CHANNEL_POLICY_NONE));
- case KEY_ALL:
- return savePolicy(p -> p.allowChannels(ZenMode.CHANNEL_POLICY_ALL));
}
return true;
}
diff --git a/src/com/android/settings/notification/modes/ZenModeFragment.java b/src/com/android/settings/notification/modes/ZenModeFragment.java
index ee497ae74df..f2f47b99ceb 100644
--- a/src/com/android/settings/notification/modes/ZenModeFragment.java
+++ b/src/com/android/settings/notification/modes/ZenModeFragment.java
@@ -53,6 +53,8 @@ public class ZenModeFragment extends ZenModeFragmentBase {
context, "mode_display_settings", mBackend, mHelperBackend));
prefControllers.add(new ZenModeSetTriggerLinkPreferenceController(context,
"zen_automatic_trigger_category", this, mBackend));
+ prefControllers.add(new InterruptionFilterPreferenceController(
+ context, "allow_filtering", mBackend));
return prefControllers;
}
diff --git a/src/com/android/settings/notification/modes/ZenModeFragmentBase.java b/src/com/android/settings/notification/modes/ZenModeFragmentBase.java
index e086524a427..67cc13beb4a 100644
--- a/src/com/android/settings/notification/modes/ZenModeFragmentBase.java
+++ b/src/com/android/settings/notification/modes/ZenModeFragmentBase.java
@@ -120,10 +120,6 @@ abstract class ZenModeFragmentBase extends ZenModesFragmentBase {
}
for (List