Files
app_Settings/src/com/android/settings/notification/modes/ZenModeSelectBypassingAppsFragment.java
Yuri Lin 1500f3ecc0 Update ZenModeAddBypassingApps to not binder call for every app
This update already happened for ZenModeAllBypassingApps to use the new single binder call to get all packages bypassing DND. This change uses that method for bypassing apps as well as collecting the set of all apps with a nonzero number of channels.

Bug: 368623163
Bug: 394614704
Test: ZenModeAddBypassingAppsPreferenceControllerTest, manual to confirm correct behavior
Flag: android.app.nm_binder_perf_get_apps_with_channels
Change-Id: I72a1edcb07d18f5707591a5341d7a7338c23f42b
2025-02-11 17:20:46 -05:00

95 lines
3.3 KiB
Java

/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.notification.modes;
import android.app.Activity;
import android.app.Application;
import android.app.settings.SettingsEnums;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
@SearchIndexable
public class ZenModeSelectBypassingAppsFragment extends ZenModeFragmentBase implements
Indexable {
private static final String TAG = "ZenBypassingApps";
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final Activity activity = getActivity();
final Application app;
if (activity != null) {
app = activity.getApplication();
} else {
app = null;
}
return buildPreferenceControllers(context, app, this, new NotificationBackend(),
new ZenHelperBackend(context));
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
@Nullable Application app, @Nullable Fragment host,
@Nullable NotificationBackend notificationBackend,
@Nullable ZenHelperBackend zenHelperBackend) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new ZenModeAllBypassingAppsPreferenceController(context, app, host,
zenHelperBackend));
controllers.add(new ZenModeAddBypassingAppsPreferenceController(context, app, host,
notificationBackend, zenHelperBackend));
return controllers;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.zen_mode_select_bypassing_apps;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP;
}
/**
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.zen_mode_select_bypassing_apps) {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
return buildPreferenceControllers(context, null, null, null, null);
}
};
}