summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/ConversationNotificationProcessorTest.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt67
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java207
-rw-r--r--services/core/java/com/android/server/notification/NotificationRecord.java2
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java70
5 files changed, 223 insertions, 142 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/ConversationNotificationProcessorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/ConversationNotificationProcessorTest.kt
index 0caddf46cd3a..d56890dc5d3f 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/ConversationNotificationProcessorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/ConversationNotificationProcessorTest.kt
@@ -137,9 +137,28 @@ class ConversationNotificationProcessorTest : SysuiTestCase() {
@Test
@EnableFlags(Flags.FLAG_NM_SUMMARIZATION)
+ fun processNotification_messagingStyleUpdateSummarizationToNull() {
+ val nb = getMessagingNotification()
+ val newRow: ExpandableNotificationRow = testHelper.createRow(nb.build())
+ newRow.entry.setRanking(
+ RankingBuilder(newRow.entry.ranking).setSummarization("hello").build()
+ )
+ assertThat(conversationNotificationProcessor.processNotification(newRow.entry, nb, logger))
+ .isNotNull()
+
+ newRow.entry.setRanking(RankingBuilder(newRow.entry.ranking).setSummarization(null).build())
+
+ assertThat(conversationNotificationProcessor.processNotification(newRow.entry, nb, logger))
+ .isNotNull()
+ assertThat(nb.build().extras.getCharSequence(EXTRA_SUMMARIZED_CONTENT)).isNull()
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_NM_SUMMARIZATION)
fun processNotification_messagingStyleWithoutSummarization() {
val nb = getMessagingNotification()
val newRow: ExpandableNotificationRow = testHelper.createRow(nb.build())
+
assertThat(conversationNotificationProcessor.processNotification(newRow.entry, nb, logger))
.isNotNull()
assertThat(nb.build().extras.getCharSequence(EXTRA_SUMMARIZED_CONTENT)).isNull()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
index df8fb5e75368..afbec7f356b2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
@@ -71,46 +71,49 @@ constructor(
Notification.MessagingStyle.CONVERSATION_TYPE_IMPORTANT
else if (entry.ranking.isConversation)
Notification.MessagingStyle.CONVERSATION_TYPE_NORMAL
- else
- Notification.MessagingStyle.CONVERSATION_TYPE_LEGACY
+ else Notification.MessagingStyle.CONVERSATION_TYPE_LEGACY
entry.ranking.conversationShortcutInfo?.let { shortcutInfo ->
logger.logAsyncTaskProgress(entry.logKey, "getting shortcut icon")
messagingStyle.shortcutIcon = launcherApps.getShortcutIcon(shortcutInfo)
shortcutInfo.label?.let { label -> messagingStyle.conversationTitle = label }
}
- if (NmSummarizationUiFlag.isEnabled && !TextUtils.isEmpty(entry.ranking.summarization)) {
- val icon = context.getDrawable(R.drawable.ic_notification_summarization)?.mutate()
- val imageSpan =
- icon?.let {
- it.setBounds(
- /* left= */ 0,
- /* top= */ 0,
- icon.getIntrinsicWidth(),
- icon.getIntrinsicHeight(),
- )
- ImageSpan(it, ImageSpan.ALIGN_CENTER)
- }
- val decoratedSummary =
- SpannableString("x " + entry.ranking.summarization).apply {
- setSpan(
- /* what = */ imageSpan,
- /* start = */ 0,
- /* end = */ 1,
- /* flags = */ Spanned.SPAN_INCLUSIVE_EXCLUSIVE,
- )
- entry.ranking.summarization?.let {
+ if (NmSummarizationUiFlag.isEnabled) {
+ if (!TextUtils.isEmpty(entry.ranking.summarization)) {
+ val icon = context.getDrawable(R.drawable.ic_notification_summarization)?.mutate()
+ val imageSpan =
+ icon?.let {
+ it.setBounds(
+ /* left= */ 0,
+ /* top= */ 0,
+ icon.getIntrinsicWidth(),
+ icon.getIntrinsicHeight(),
+ )
+ ImageSpan(it, ImageSpan.ALIGN_CENTER)
+ }
+ val decoratedSummary =
+ SpannableString("x " + entry.ranking.summarization).apply {
setSpan(
- /* what = */ StyleSpan(Typeface.ITALIC),
- /* start = */ 2,
- /* end = */ it.length + 2,
- /* flags = */ Spanned.SPAN_EXCLUSIVE_INCLUSIVE,
+ /* what = */ imageSpan,
+ /* start = */ 0,
+ /* end = */ 1,
+ /* flags = */ Spanned.SPAN_INCLUSIVE_EXCLUSIVE,
)
+ entry.ranking.summarization?.let {
+ setSpan(
+ /* what = */ StyleSpan(Typeface.ITALIC),
+ /* start = */ 2,
+ /* end = */ it.length + 2,
+ /* flags = */ Spanned.SPAN_EXCLUSIVE_INCLUSIVE,
+ )
+ }
}
- }
- entry.sbn.notification.extras.putCharSequence(
- EXTRA_SUMMARIZED_CONTENT,
- decoratedSummary,
- )
+ entry.sbn.notification.extras.putCharSequence(
+ EXTRA_SUMMARIZED_CONTENT,
+ decoratedSummary,
+ )
+ } else {
+ entry.sbn.notification.extras.putCharSequence(EXTRA_SUMMARIZED_CONTENT, null)
+ }
}
messagingStyle.unreadMessageCount =
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 06fc9b083086..947f0a51b528 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1877,73 +1877,35 @@ public class NotificationManagerService extends SystemService {
}
};
- private void unclassifyNotificationsForUser(final int userId) {
- if (DBG) {
- Slog.v(TAG, "unclassifyForUser: " + userId);
- }
- unclassifyNotificationsFiltered((r) -> r.getUserId() == userId);
+ private void applyNotificationUpdateForUser(final int userId,
+ NotificationUpdate notificationUpdate) {
+ applyUpdateForNotificationsFiltered((r) -> r.getUserId() == userId,
+ notificationUpdate);
}
- private void unclassifyNotificationsForUid(final int userId, @NonNull final String pkg) {
- if (DBG) {
- Slog.v(TAG, "unclassifyForUid userId: " + userId + " pkg: " + pkg);
- }
- unclassifyNotificationsFiltered((r) ->
+ private void applyNotificationUpdateForUid(final int userId, @NonNull final String pkg,
+ NotificationUpdate notificationUpdate) {
+ applyUpdateForNotificationsFiltered((r) ->
r.getUserId() == userId
- && Objects.equals(r.getSbn().getPackageName(), pkg));
+ && Objects.equals(r.getSbn().getPackageName(), pkg),
+ notificationUpdate);
}
- private void unclassifyNotificationsForUserAndType(final int userId,
- final @Types int bundleType) {
- if (DBG) {
- Slog.v(TAG,
- "unclassifyForUserAndType userId: " + userId + " bundleType: " + bundleType);
- }
+ private void applyNotificationUpdateForUserAndChannelType(final int userId,
+ final @Types int bundleType, NotificationUpdate notificationUpdate) {
final String bundleChannelId = NotificationChannel.getChannelIdForBundleType(bundleType);
- unclassifyNotificationsFiltered((r) ->
+ applyUpdateForNotificationsFiltered((r) ->
r.getUserId() == userId
&& r.getChannel() != null
- && Objects.equals(bundleChannelId, r.getChannel().getId()));
+ && Objects.equals(bundleChannelId, r.getChannel().getId()),
+ notificationUpdate);
}
- private void unclassifyNotificationsFiltered(Predicate<NotificationRecord> filter) {
- if (!(notificationClassificationUi() && notificationRegroupOnClassification())) {
- return;
- }
- synchronized (mNotificationLock) {
- for (int i = 0; i < mEnqueuedNotifications.size(); i++) {
- final NotificationRecord r = mEnqueuedNotifications.get(i);
- if (filter.test(r)) {
- unclassifyNotificationLocked(r);
- }
- }
-
- for (int i = 0; i < mNotificationList.size(); i++) {
- final NotificationRecord r = mNotificationList.get(i);
- if (filter.test(r)) {
- unclassifyNotificationLocked(r);
- }
- }
- }
- }
-
- @GuardedBy("mNotificationLock")
- private void unclassifyNotificationLocked(@NonNull final NotificationRecord r) {
- if (DBG) {
- Slog.v(TAG, "unclassifyNotification: " + r);
- }
- // Only NotificationRecord's mChannel is updated when bundled, the Notification
- // mChannelId will always be the original channel.
- String origChannelId = r.getNotification().getChannelId();
- NotificationChannel originalChannel = mPreferencesHelper.getNotificationChannel(
- r.getSbn().getPackageName(), r.getUid(), origChannelId, false);
- String currChannelId = r.getChannel().getId();
- boolean isClassified = NotificationChannel.SYSTEM_RESERVED_IDS.contains(currChannelId);
- if (originalChannel != null && !origChannelId.equals(currChannelId) && isClassified) {
- r.updateNotificationChannel(originalChannel);
- mGroupHelper.onNotificationUnbundled(r,
- GroupHelper.isOriginalGroupSummaryPresent(r, mSummaryByGroupKey));
- }
+ private void applyNotificationUpdateForUserAndType(final int userId,
+ final @Types int bundleType, NotificationUpdate notificationUpdate) {
+ applyUpdateForNotificationsFiltered(
+ (r) -> r.getUserId() == userId && r.getBundleType() == bundleType,
+ notificationUpdate);
}
@VisibleForTesting
@@ -1956,7 +1918,7 @@ public class NotificationManagerService extends SystemService {
if (r == null) {
return;
}
- unclassifyNotificationLocked(r);
+ unclassifyNotificationLocked(r, true);
}
}
@@ -1974,50 +1936,36 @@ public class NotificationManagerService extends SystemService {
}
}
- private void reclassifyNotificationsFiltered(Predicate<NotificationRecord> filter) {
- if (!(notificationClassificationUi() && notificationRegroupOnClassification())) {
- return;
- }
- synchronized (mNotificationLock) {
- for (int i = 0; i < mEnqueuedNotifications.size(); i++) {
- final NotificationRecord r = mEnqueuedNotifications.get(i);
- if (filter.test(r)) {
- reclassifyNotificationLocked(r, false);
- }
- }
-
- for (int i = 0; i < mNotificationList.size(); i++) {
- final NotificationRecord r = mNotificationList.get(i);
- if (filter.test(r)) {
- reclassifyNotificationLocked(r, true);
- }
- }
- }
- }
-
- private void reclassifyNotificationsForUserAndType(final int userId,
- final @Types int bundleType) {
+ @GuardedBy("mNotificationLock")
+ private void unclassifyNotificationLocked(@NonNull final NotificationRecord r,
+ boolean isPosted) {
if (DBG) {
- Slog.v(TAG, "reclassifyNotificationsForUserAndType userId: " + userId + " bundleType: "
- + bundleType);
+ Slog.v(TAG, "unclassifyNotification: " + r);
}
- reclassifyNotificationsFiltered(
- (r) -> r.getUserId() == userId && r.getBundleType() == bundleType);
- }
-
- private void reclassifyNotificationsForUid(final int userId, final String pkg) {
- if (DBG) {
- Slog.v(TAG, "reclassifyNotificationsForUid userId: " + userId + " pkg: " + pkg);
+ // Only NotificationRecord's mChannel is updated when bundled, the Notification
+ // mChannelId will always be the original channel.
+ String origChannelId = r.getNotification().getChannelId();
+ NotificationChannel originalChannel = mPreferencesHelper.getNotificationChannel(
+ r.getSbn().getPackageName(), r.getUid(), origChannelId, false);
+ String currChannelId = r.getChannel().getId();
+ boolean isClassified = NotificationChannel.SYSTEM_RESERVED_IDS.contains(currChannelId);
+ if (originalChannel != null && !origChannelId.equals(currChannelId) && isClassified) {
+ r.updateNotificationChannel(originalChannel);
+ mGroupHelper.onNotificationUnbundled(r,
+ GroupHelper.isOriginalGroupSummaryPresent(r, mSummaryByGroupKey));
}
- reclassifyNotificationsFiltered((r) ->
- r.getUserId() == userId && Objects.equals(r.getSbn().getPackageName(), pkg));
}
- private void reclassifyNotificationsForUser(final int userId) {
- if (DBG) {
- Slog.v(TAG, "reclassifyAllNotificationsForUser: " + userId);
- }
- reclassifyNotificationsFiltered((r) -> r.getUserId() == userId);
+ @GuardedBy("mNotificationLock")
+ private void unsummarizeNotificationLocked(@NonNull final NotificationRecord r,
+ boolean isPosted) {
+ Bundle signals = new Bundle();
+ signals.putString(KEY_SUMMARIZATION, null);
+ Adjustment adjustment = new Adjustment(r.getSbn().getPackageName(), r.getKey(), signals, "",
+ r.getSbn().getUserId());
+ r.addAdjustment(adjustment);
+ mRankingHandler.requestSort();
+
}
@GuardedBy("mNotificationLock")
@@ -2043,6 +1991,33 @@ public class NotificationManagerService extends SystemService {
}
}
+ /**
+ * Given a filter and a function to update a notification record, runs that function on all
+ * enqueued and posted notifications that match the filter
+ */
+ private void applyUpdateForNotificationsFiltered(Predicate<NotificationRecord> filter,
+ NotificationUpdate notificationUpdate) {
+ synchronized (mNotificationLock) {
+ for (int i = 0; i < mEnqueuedNotifications.size(); i++) {
+ final NotificationRecord r = mEnqueuedNotifications.get(i);
+ if (filter.test(r)) {
+ notificationUpdate.apply(r, false);
+ }
+ }
+
+ for (int i = 0; i < mNotificationList.size(); i++) {
+ final NotificationRecord r = mNotificationList.get(i);
+ if (filter.test(r)) {
+ notificationUpdate.apply(r, true);
+ }
+ }
+ }
+ }
+
+ private interface NotificationUpdate {
+ void apply(NotificationRecord r, boolean isPosted);
+ }
+
NotificationManagerPrivate mNotificationManagerPrivate = new NotificationManagerPrivate() {
@Nullable
@Override
@@ -4475,9 +4450,11 @@ public class NotificationManagerService extends SystemService {
public void allowAssistantAdjustment(String adjustmentType) {
checkCallerIsSystemOrSystemUiOrShell();
mAssistants.allowAdjustmentType(adjustmentType);
+ int userId = UserHandle.getUserId(Binder.getCallingUid());
if ((notificationClassificationUi() && notificationRegroupOnClassification())) {
if (KEY_TYPE.equals(adjustmentType)) {
- reclassifyNotificationsForUser(UserHandle.getUserId(Binder.getCallingUid()));
+ applyNotificationUpdateForUser(userId,
+ NotificationManagerService.this::reclassifyNotificationLocked);
}
}
handleSavePolicyFile();
@@ -4488,9 +4465,17 @@ public class NotificationManagerService extends SystemService {
public void disallowAssistantAdjustment(String adjustmentType) {
checkCallerIsSystemOrSystemUiOrShell();
mAssistants.disallowAdjustmentType(adjustmentType);
+ int userId = UserHandle.getUserId(Binder.getCallingUid());
if ((notificationClassificationUi() && notificationRegroupOnClassification())) {
if (KEY_TYPE.equals(adjustmentType)) {
- unclassifyNotificationsForUser(UserHandle.getUserId(Binder.getCallingUid()));
+ applyNotificationUpdateForUser(userId,
+ NotificationManagerService.this::unclassifyNotificationLocked);
+ }
+ }
+ if (nmSummarizationUi() || nmSummarization()) {
+ if (KEY_SUMMARIZATION.equals(adjustmentType)) {
+ applyNotificationUpdateForUser(userId,
+ NotificationManagerService.this::unsummarizeNotificationLocked);
}
}
handleSavePolicyFile();
@@ -4539,11 +4524,13 @@ public class NotificationManagerService extends SystemService {
mAssistants.setAssistantAdjustmentKeyTypeState(type, enabled);
if ((notificationClassificationUi() && notificationRegroupOnClassification())) {
if (enabled) {
- reclassifyNotificationsForUserAndType(
- UserHandle.getUserId(Binder.getCallingUid()), type);
+ applyNotificationUpdateForUserAndType(
+ UserHandle.getUserId(Binder.getCallingUid()), type,
+ NotificationManagerService.this::reclassifyNotificationLocked);
} else {
- unclassifyNotificationsForUserAndType(
- UserHandle.getUserId(Binder.getCallingUid()), type);
+ applyNotificationUpdateForUserAndChannelType(
+ UserHandle.getUserId(Binder.getCallingUid()), type,
+ NotificationManagerService.this::unclassifyNotificationLocked);
}
}
handleSavePolicyFile();
@@ -4569,11 +4556,17 @@ public class NotificationManagerService extends SystemService {
if (notificationClassificationUi() && notificationRegroupOnClassification()
&& key.equals(KEY_TYPE)) {
if (enabled) {
- reclassifyNotificationsForUid(UserHandle.getUserId(Binder.getCallingUid()),
- pkg);
+ applyNotificationUpdateForUid(UserHandle.getUserId(Binder.getCallingUid()),
+ pkg, NotificationManagerService.this::reclassifyNotificationLocked);
} else {
- unclassifyNotificationsForUid(UserHandle.getUserId(Binder.getCallingUid()),
- pkg);
+ applyNotificationUpdateForUid(UserHandle.getUserId(Binder.getCallingUid()),
+ pkg, NotificationManagerService.this::unclassifyNotificationLocked);
+ }
+ }
+ if (nmSummarization() || nmSummarizationUi()) {
+ if (KEY_SUMMARIZATION.equals(key) && !enabled) {
+ applyNotificationUpdateForUid(UserHandle.getUserId(Binder.getCallingUid()),
+ pkg, NotificationManagerService.this::unsummarizeNotificationLocked);
}
}
handleSavePolicyFile();
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index cec5a93a2a15..700f6fafe2d7 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -999,7 +999,7 @@ public final class NotificationRecord {
return null;
}
- public String getSummarization() {
+ public @Nullable String getSummarization() {
if ((android.app.Flags.nmSummarizationUi() || android.app.Flags.nmSummarization())) {
return mSummarization;
}
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 902171d614d9..f24ebc42bcee 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -24,6 +24,7 @@ import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.NOT_
import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.SHOW_IMMEDIATELY;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.Flags.FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS;
+import static android.app.Flags.FLAG_NM_SUMMARIZATION;
import static android.app.Flags.FLAG_SORT_SECTION_BY_TIME;
import static android.app.Notification.EXTRA_ALLOW_DURING_SETUP;
import static android.app.Notification.EXTRA_PICTURE;
@@ -105,6 +106,7 @@ import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
import static android.service.notification.Adjustment.KEY_CONTEXTUAL_ACTIONS;
import static android.service.notification.Adjustment.KEY_IMPORTANCE;
+import static android.service.notification.Adjustment.KEY_SUMMARIZATION;
import static android.service.notification.Adjustment.KEY_TEXT_REPLIES;
import static android.service.notification.Adjustment.KEY_TYPE;
import static android.service.notification.Adjustment.KEY_USER_SENTIMENT;
@@ -18308,9 +18310,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
// Post some notifications and classify in different bundles
final int numNotifications = NotificationChannel.SYSTEM_RESERVED_IDS.size();
final int numNewsNotifications = 1;
+ List<String> postedNotificationKeys = new ArrayList();
for (int i = 0; i < numNotifications; i++) {
NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, i, mUserId);
mService.addNotification(r);
+ postedNotificationKeys.add(r.getKey());
Bundle signals = new Bundle();
final int adjustmentType = i + 1;
signals.putInt(Adjustment.KEY_TYPE, adjustmentType);
@@ -18330,7 +18334,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
waitForIdle();
//Check that all notifications classified as TYPE_NEWS have been unbundled
- for (NotificationRecord record : mService.mNotificationList) {
+ for (String key : postedNotificationKeys) {
+ NotificationRecord record= mService.mNotificationsByKey.get(key);
// Check that the original channel was restored
// for notifications classified as TYPE_NEWS
if (record.getBundleType() == TYPE_NEWS) {
@@ -18355,7 +18360,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
// Check that the bundle channel was restored
verify(mRankingHandler, times(numNewsNotifications)).requestSort();
- for (NotificationRecord record : mService.mNotificationList) {
+ for (String key : postedNotificationKeys) {
+ NotificationRecord record= mService.mNotificationsByKey.get(key);
assertThat(record.getChannel().getId()).isIn(NotificationChannel.SYSTEM_RESERVED_IDS);
}
}
@@ -18425,6 +18431,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
}
@Test
+ @EnableFlags({FLAG_NM_SUMMARIZATION})
+ public void testDisableBundleAdjustmentByPkg_unsummarizesNotifications() throws Exception {
+ NotificationManagerService.WorkerHandler handler = mock(
+ NotificationManagerService.WorkerHandler.class);
+ mService.setHandler(handler);
+ when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true);
+ when(mAssistants.isServiceTokenValidLocked(any())).thenReturn(true);
+ when(mAssistants.isAdjustmentKeyTypeAllowed(anyInt())).thenReturn(true);
+ when(mAssistants.isAdjustmentAllowedForPackage(anyString(), anyString())).thenReturn(true);
+
+ NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, mUserId);
+ mService.addNotification(r);
+ Bundle signals = new Bundle();
+ signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, "hello");
+ Adjustment adjustment = new Adjustment(r.getSbn().getPackageName(), r.getKey(), signals,
+ "", r.getUser().getIdentifier());
+ mBinderService.applyAdjustmentFromAssistant(null, adjustment);
+ waitForIdle();
+ r.applyAdjustments();
+ Mockito.clearInvocations(mRankingHandler);
+
+ // Disable summarization for package
+ mBinderService.setAdjustmentSupportedForPackage(KEY_SUMMARIZATION, mPkg, false);
+ verify(mRankingHandler).requestSort();
+ mService.handleRankingSort();
+
+ assertThat(mService.mNotificationsByKey.get(r.getKey()).getSummarization()).isNull();
+ }
+
+ @Test
@EnableFlags({FLAG_NOTIFICATION_CLASSIFICATION,
FLAG_NOTIFICATION_FORCE_GROUPING,
FLAG_NOTIFICATION_REGROUP_ON_CLASSIFICATION,
@@ -18627,6 +18663,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
}
@Test
+ @EnableFlags({FLAG_NM_SUMMARIZATION})
+ public void testDisableBundleAdjustment_unsummarizesNotifications() throws Exception {
+ NotificationManagerService.WorkerHandler handler = mock(
+ NotificationManagerService.WorkerHandler.class);
+ mService.setHandler(handler);
+ when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true);
+ when(mAssistants.isServiceTokenValidLocked(any())).thenReturn(true);
+ when(mAssistants.isAdjustmentKeyTypeAllowed(anyInt())).thenReturn(true);
+ when(mAssistants.isAdjustmentAllowedForPackage(anyString(), anyString())).thenReturn(true);
+
+ NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, mUserId);
+ mService.addNotification(r);
+ Bundle signals = new Bundle();
+ signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, "hello");
+ Adjustment adjustment = new Adjustment(r.getSbn().getPackageName(), r.getKey(), signals,
+ "", r.getUser().getIdentifier());
+ mBinderService.applyAdjustmentFromAssistant(null, adjustment);
+ waitForIdle();
+ r.applyAdjustments();
+ Mockito.clearInvocations(mRankingHandler);
+
+ // Disable summarization for package
+ mBinderService.disallowAssistantAdjustment(KEY_SUMMARIZATION);
+ verify(mRankingHandler).requestSort();
+ mService.handleRankingSort();
+
+ assertThat(mService.mNotificationsByKey.get(r.getKey()).getSummarization()).isNull();
+ }
+
+ @Test
@EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING)
public void clearAll_fromUser_willSendDeleteIntentForCachedSummaries() throws Exception {
NotificationRecord n = generateNotificationRecord(