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
This commit is contained in:
@@ -23,6 +23,7 @@ import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED_BY
|
||||
|
||||
import static com.android.server.notification.Flags.notificationHideUnusedChannels;
|
||||
|
||||
import android.annotation.FlaggedApi;
|
||||
import android.app.Flags;
|
||||
import android.app.INotificationManager;
|
||||
import android.app.NotificationChannel;
|
||||
@@ -54,6 +55,7 @@ import android.text.format.DateUtils;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.util.CollectionUtils;
|
||||
@@ -66,10 +68,13 @@ import com.android.settingslib.utils.StringUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class NotificationBackend {
|
||||
private static final String TAG = "NotificationBackend";
|
||||
@@ -367,6 +372,20 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of all apps that have any notification channels (not including deleted ones).
|
||||
*/
|
||||
@FlaggedApi(Flags.FLAG_NM_BINDER_PERF_GET_APPS_WITH_CHANNELS)
|
||||
public @NonNull Set<String> getPackagesWithAnyChannels(int userId) {
|
||||
try {
|
||||
List<String> packages = sINM.getPackagesWithAnyChannels(userId);
|
||||
return new HashSet<>(packages);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return Collections.EMPTY_SET;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateChannel(String pkg, int uid, NotificationChannel channel) {
|
||||
try {
|
||||
sINM.updateNotificationChannelForPackage(pkg, uid, channel);
|
||||
|
||||
Reference in New Issue
Block a user