summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yuri Lin <yurilin@google.com> 2025-03-20 13:49:33 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-20 13:49:33 -0700
commitd9dda7a75e0e6d3bcac12e533c10167ad3fd458d (patch)
treebbfb7e38d3ee7d2c23de2c10b78862f03bd660d7
parenta2eb1d342076988f34ddd820b335d281f6c0737e (diff)
parentcfd420e6cfff005df77e06a8d13c1defb1353753 (diff)
Merge "Don't allow RONS to be bundled" into main
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java4
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java52
2 files changed, 56 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index c1e46a68b733..de20b82f505c 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -7410,6 +7410,10 @@ public class NotificationManagerService extends SystemService {
adjustments);
if (newChannel == null || newChannel.getId().equals(r.getChannel().getId())) {
adjustments.remove(KEY_TYPE);
+ } else if (android.app.Flags.apiRichOngoing() && hasFlag(r.getNotification().flags,
+ FLAG_PROMOTED_ONGOING)) {
+ // Don't bundle any promoted ongoing notifications
+ adjustments.remove(KEY_TYPE);
} else {
// Save the app-provided type for logging.
int classification = adjustments.getInt(KEY_TYPE);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 159b3fd7b5c3..b9b4a78df0ca 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -17682,6 +17682,58 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
}
@Test
+ @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING,
+ android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION,
+ android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI})
+ public void testApplyAdjustment_promotedOngoingNotification_doesNotApply() throws Exception {
+ // promoted ongoing notification which should not have the adjustment applied
+ Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId())
+ .setSmallIcon(android.R.drawable.sym_def_app_icon)
+ .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
+ .setColor(Color.WHITE)
+ .setColorized(true)
+ .setOngoing(true)
+ .setFlag(FLAG_PROMOTED_ONGOING, true) // add manually since we're skipping post
+ .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
+ .build();
+
+ StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 9, null, mUid, 0,
+ n, UserHandle.getUserHandleForUid(mUid), null, 0);
+ final NotificationRecord r = new NotificationRecord(mContext, sbn,
+ mTestNotificationChannel);
+
+ // regular notification record for contrast
+ final NotificationRecord r2 = generateNotificationRecord(mTestNotificationChannel);
+
+ mService.addNotification(r);
+ mService.addNotification(r2);
+ NotificationManagerService.WorkerHandler handler = mock(
+ NotificationManagerService.WorkerHandler.class);
+ mService.setHandler(handler);
+ when(mAssistants.isAdjustmentKeyTypeAllowed(anyInt())).thenReturn(true);
+ when(mAssistants.isAdjustmentAllowedForPackage(anyString(), anyString())).thenReturn(true);
+
+ Bundle signals = new Bundle();
+ signals.putInt(KEY_TYPE, TYPE_NEWS);
+ Bundle signals2 = new Bundle(signals); // copy for the second adjustment
+ Adjustment adjustment = new Adjustment(
+ r.getSbn().getPackageName(), r.getKey(), signals, "", r.getUser().getIdentifier());
+ Adjustment a2 = new Adjustment(r2.getSbn().getPackageName(), r2.getKey(), signals2, "",
+ r2.getUser().getIdentifier());
+ when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true);
+ mBinderService.applyAdjustmentsFromAssistant(null, List.of(adjustment, a2));
+
+ waitForIdle();
+
+ r.applyAdjustments();
+ r2.applyAdjustments();
+
+ // promoted ongoing notification does not get bundled; regular one does
+ assertThat(r.getChannel().getId()).isEqualTo(mTestNotificationChannel.getId());
+ assertThat(r2.getChannel().getId()).isEqualTo(NEWS_ID);
+ }
+
+ @Test
@EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING})
public void testSetCanBePromoted_granted_noui() throws Exception {
testSetCanBePromoted_granted();