Loading services/core/java/com/android/server/notification/GroupHelper.java +11 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.service.notification.Flags.notificationForceGrouping; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading Loading @@ -88,6 +89,7 @@ public class GroupHelper { private final int mAutogroupSparseGroupsAtCount; private final Context mContext; private final PackageManager mPackageManager; private boolean mIsTestHarnessExempted; // Only contains notifications that are not explicitly grouped by the app (aka no group or // sort key). Loading Loading @@ -174,6 +176,11 @@ public class GroupHelper { NOTIFICATION_SHADE_SECTIONS = getNotificationShadeSections(); } void setTestHarnessExempted(boolean isExempted) { // Allow E2E tests to post ungrouped notifications mIsTestHarnessExempted = ActivityManager.isRunningInUserTestHarness() && isExempted; } private String generatePackageKey(int userId, String pkg) { return userId + "|" + pkg; } Loading Loading @@ -696,6 +703,10 @@ public class GroupHelper { return; } if (mIsTestHarnessExempted) { return; } final NotificationSectioner sectioner = getSection(record); if (sectioner == null) { if (DEBUG) { Loading services/core/java/com/android/server/notification/NotificationManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -2984,6 +2984,11 @@ public class NotificationManagerService extends SystemService { }); } //Enables tests running in TH mode to be exempted from forced grouping of notifications void setTestHarnessExempted(boolean isExempted) { mGroupHelper.setTestHarnessExempted(isExempted); } private void sendRegisteredOnlyBroadcast(String action) { sendRegisteredOnlyBroadcast(new Intent(action)); } Loading services/core/java/com/android/server/notification/NotificationShellCmd.java +8 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class NotificationShellCmd extends ShellCommand { + " get <notification-key>\n" + " snooze --for <msec> <notification-key>\n" + " unsnooze <notification-key>\n" + " set_exempt_th_force_grouping [true|false]\n" ; private static final String NOTIFY_USAGE = Loading Loading @@ -428,6 +429,13 @@ public class NotificationShellCmd extends ShellCommand { } break; } case "set_exempt_th_force_grouping": { String arg = getNextArgRequired(); final boolean exemptTestHarnessFromForceGrouping = "true".equals(arg) || "1".equals(arg); mDirectService.setTestHarnessExempted(exemptTestHarnessFromForceGrouping); break; } default: return handleDefaultCommands(cmd); } Loading Loading
services/core/java/com/android/server/notification/GroupHelper.java +11 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.service.notification.Flags.notificationForceGrouping; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading Loading @@ -88,6 +89,7 @@ public class GroupHelper { private final int mAutogroupSparseGroupsAtCount; private final Context mContext; private final PackageManager mPackageManager; private boolean mIsTestHarnessExempted; // Only contains notifications that are not explicitly grouped by the app (aka no group or // sort key). Loading Loading @@ -174,6 +176,11 @@ public class GroupHelper { NOTIFICATION_SHADE_SECTIONS = getNotificationShadeSections(); } void setTestHarnessExempted(boolean isExempted) { // Allow E2E tests to post ungrouped notifications mIsTestHarnessExempted = ActivityManager.isRunningInUserTestHarness() && isExempted; } private String generatePackageKey(int userId, String pkg) { return userId + "|" + pkg; } Loading Loading @@ -696,6 +703,10 @@ public class GroupHelper { return; } if (mIsTestHarnessExempted) { return; } final NotificationSectioner sectioner = getSection(record); if (sectioner == null) { if (DEBUG) { Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -2984,6 +2984,11 @@ public class NotificationManagerService extends SystemService { }); } //Enables tests running in TH mode to be exempted from forced grouping of notifications void setTestHarnessExempted(boolean isExempted) { mGroupHelper.setTestHarnessExempted(isExempted); } private void sendRegisteredOnlyBroadcast(String action) { sendRegisteredOnlyBroadcast(new Intent(action)); } Loading
services/core/java/com/android/server/notification/NotificationShellCmd.java +8 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class NotificationShellCmd extends ShellCommand { + " get <notification-key>\n" + " snooze --for <msec> <notification-key>\n" + " unsnooze <notification-key>\n" + " set_exempt_th_force_grouping [true|false]\n" ; private static final String NOTIFY_USAGE = Loading Loading @@ -428,6 +429,13 @@ public class NotificationShellCmd extends ShellCommand { } break; } case "set_exempt_th_force_grouping": { String arg = getNextArgRequired(); final boolean exemptTestHarnessFromForceGrouping = "true".equals(arg) || "1".equals(arg); mDirectService.setTestHarnessExempted(exemptTestHarnessFromForceGrouping); break; } default: return handleDefaultCommands(cmd); } Loading