summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java14
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java68
2 files changed, 60 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 5182dfe60fcc..499927b97119 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -11953,8 +11953,10 @@ public class NotificationManagerService extends SystemService {
assistant.onNotificationEnqueuedWithChannel(sbnHolder, r.getChannel(),
update);
}
+ } catch (DeadObjectException ex) {
+ Slog.wtf(TAG, "unable to notify assistant (enqueued): " + info, ex);
} catch (RemoteException ex) {
- Slog.e(TAG, "unable to notify assistant (enqueued): " + assistant, ex);
+ Slog.e(TAG, "unable to notify assistant (enqueued): " + info, ex);
}
}
}
@@ -12075,19 +12077,21 @@ public class NotificationManagerService extends SystemService {
r.getSbn(),
r.getNotificationType(),
true /* sameUserOnly */,
- (assistant, sbnToPost) -> {
+ (info, sbnToPost) -> {
try {
if (android.app.Flags.noSbnholder()) {
- assistant.onNotificationSnoozedUntilContextFull(
+ info.onNotificationSnoozedUntilContextFull(
sbnToPost, snoozeCriterionId);
} else {
final StatusBarNotificationHolder sbnHolder =
new StatusBarNotificationHolder(sbnToPost);
- assistant.onNotificationSnoozedUntilContext(
+ info.onNotificationSnoozedUntilContext(
sbnHolder, snoozeCriterionId);
}
+ } catch (DeadObjectException ex) {
+ Slog.wtf(TAG, "unable to notify assistant (snoozed): " + info, ex);
} catch (RemoteException ex) {
- Slog.e(TAG, "unable to notify assistant (snoozed): " + assistant, ex);
+ Slog.e(TAG, "unable to notify assistant (snoozed): " + info, ex);
}
});
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java
index b34b1fb39a7f..bf3333349b82 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java
@@ -907,10 +907,18 @@ public class NotificationListenersTest extends UiServiceTestCase {
ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
verify(mNm.mHandler, times(1)).post(runnableCaptor.capture());
runnableCaptor.getValue().run();
- ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
- ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
- verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
- StatusBarNotification sbnResult = sbnCaptor.getValue().get();
+ StatusBarNotification sbnResult = null;
+ if (android.app.Flags.noSbnholder()) {
+ ArgumentCaptor<StatusBarNotification> sbnCaptor =
+ ArgumentCaptor.forClass(StatusBarNotification.class);
+ verify(sysuiListener, times(1)).onNotificationPostedFull(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue();
+ } else {
+ ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
+ ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
+ verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue().get();
+ }
assertThat(sbnResult.getNotification()
.extras.getCharSequence(Notification.EXTRA_TITLE).toString())
.isEqualTo("new title");
@@ -920,7 +928,7 @@ public class NotificationListenersTest extends UiServiceTestCase {
}
@Test
- public void testListenerPostLifeimteExtension_postsToAppropriateListeners() throws Exception {
+ public void testListenerPostLifetimeExtension_postsToAppropriateListeners() throws Exception {
mSetFlagsRule.enableFlags(android.app.Flags.FLAG_LIFETIME_EXTENSION_REFACTOR);
// Create original notification, with FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY.
@@ -998,16 +1006,29 @@ public class NotificationListenersTest extends UiServiceTestCase {
r.run();
}
- ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
- ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
- verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
- StatusBarNotification sbnResult = sbnCaptor.getValue().get();
+ StatusBarNotification sbnResult = null;
+ if (android.app.Flags.noSbnholder()) {
+ ArgumentCaptor<StatusBarNotification> sbnCaptor =
+ ArgumentCaptor.forClass(StatusBarNotification.class);
+ verify(sysuiListener, times(1)).onNotificationPostedFull(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue();
+ } else {
+ ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
+ ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
+ verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue().get();
+ }
assertThat(sbnResult.getNotification()
.extras.getCharSequence(Notification.EXTRA_TITLE).toString())
.isEqualTo("new title");
- verify(otherListener1, times(1)).onNotificationPosted(any(), any());
- verify(otherListener2, times(1)).onNotificationPosted(any(), any());
+ if (android.app.Flags.noSbnholder()) {
+ verify(otherListener1, times(1)).onNotificationPostedFull(any(), any());
+ verify(otherListener2, times(1)).onNotificationPostedFull(any(), any());
+ } else {
+ verify(otherListener1, times(1)).onNotificationPosted(any(), any());
+ verify(otherListener2, times(1)).onNotificationPosted(any(), any());
+ }
}
@Test
@@ -1083,16 +1104,29 @@ public class NotificationListenersTest extends UiServiceTestCase {
r.run();
}
- ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
- ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
- verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
- StatusBarNotification sbnResult = sbnCaptor.getValue().get();
+ StatusBarNotification sbnResult = null;
+ if (android.app.Flags.noSbnholder()) {
+ ArgumentCaptor<StatusBarNotification> sbnCaptor =
+ ArgumentCaptor.forClass(StatusBarNotification.class);
+ verify(sysuiListener, times(1)).onNotificationPostedFull(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue();
+ } else {
+ ArgumentCaptor<IStatusBarNotificationHolder> sbnCaptor =
+ ArgumentCaptor.forClass(IStatusBarNotificationHolder.class);
+ verify(sysuiListener, times(1)).onNotificationPosted(sbnCaptor.capture(), any());
+ sbnResult = sbnCaptor.getValue().get();
+ }
assertThat(sbnResult.getNotification()
.extras.getCharSequence(Notification.EXTRA_TITLE).toString())
.isEqualTo("new title");
- verify(otherListener1, times(1)).onNotificationPosted(any(), any());
- verify(otherListener2, times(1)).onNotificationPosted(any(), any());
+ if (android.app.Flags.noSbnholder()) {
+ verify(otherListener1, times(1)).onNotificationPostedFull(any(), any());
+ verify(otherListener2, times(1)).onNotificationPostedFull(any(), any());
+ } else {
+ verify(otherListener1, times(1)).onNotificationPosted(any(), any());
+ verify(otherListener2, times(1)).onNotificationPosted(any(), any());
+ }
}
/**