Add filtering to notification channel settings

Allow apps that are launching this page to specify targeted subsets of
settings that should be shown.

Test: settings notification robotests
Bug: 177246841
Change-Id: Ib491c43f1861a9775e3b25f39134cdbe105a7ff8
This commit is contained in:
Julia Reynolds
2021-02-11 21:29:41 -05:00
parent d7af6821dc
commit 4dc7795eb3
66 changed files with 1067 additions and 333 deletions

View File

@@ -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<String> 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<String> preferenceFilter) {
mAppRow = appRow;
mChannel = channel;
mChannelGroup = group;
mAdmin = admin;
mConversationDrawable = conversationDrawable;
mConversationInfo = conversationInfo;
mPreferenceFilter = preferenceFilter;
}
abstract boolean isIncludedInFilter();
protected boolean checkCanBeVisible(int minImportanceVisible) {
if (mChannel == null) {
Log.w(TAG, "No channel");