Loading services/core/java/com/android/server/notification/NotificationManagerService.java +9 −5 Original line number Diff line number Diff line Loading @@ -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); } } } Loading Loading @@ -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); } }); } services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +51 −17 Original line number Diff line number Diff line Loading @@ -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(); 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); Loading @@ -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. Loading Loading @@ -998,17 +1006,30 @@ public class NotificationListenersTest extends UiServiceTestCase { r.run(); } 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); 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 public void testNotifyPostedLocked_postsToAppropriateListeners() throws Exception { Loading Loading @@ -1083,17 +1104,30 @@ public class NotificationListenersTest extends UiServiceTestCase { r.run(); } 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); 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()); } } /** * Helper method to test the thread safety of some operations. Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +9 −5 Original line number Diff line number Diff line Loading @@ -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); } } } Loading Loading @@ -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); } }); }
services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +51 −17 Original line number Diff line number Diff line Loading @@ -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(); 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); Loading @@ -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. Loading Loading @@ -998,17 +1006,30 @@ public class NotificationListenersTest extends UiServiceTestCase { r.run(); } 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); 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 public void testNotifyPostedLocked_postsToAppropriateListeners() throws Exception { Loading Loading @@ -1083,17 +1104,30 @@ public class NotificationListenersTest extends UiServiceTestCase { r.run(); } 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()); StatusBarNotification sbnResult = sbnCaptor.getValue().get(); sbnResult = sbnCaptor.getValue().get(); } assertThat(sbnResult.getNotification() .extras.getCharSequence(Notification.EXTRA_TITLE).toString()) .isEqualTo("new title"); 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()); } } /** * Helper method to test the thread safety of some operations. Loading