Loading services/core/java/com/android/server/notification/NotificationManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -1340,6 +1340,10 @@ public class NotificationManagerService extends SystemService { nv.recycle(); reportUserInteraction(r); mAssistants.notifyAssistantActionClicked(r, action, generatedByAssistant); // Notifications that have been interacted with don't need to be lifetime extended. if (lifetimeExtensionRefactor()) { r.getSbn().getNotification().flags &= ~FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY; } } } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -8409,6 +8409,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mNotificationRecordLogger.event(0)); } @Test public void testOnNotificationActionClickLifetimeExtendedEnds() { mSetFlagsRule.enableFlags(android.app.Flags.FLAG_LIFETIME_EXTENSION_REFACTOR); final Notification.Action action = new Notification.Action.Builder(null, "text", PendingIntent.getActivity( mContext, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE)).build(); // Creates a notification marked as being lifetime extended. NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); r.getSbn().getNotification().flags |= FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY; mService.addNotification(r); // Call on action click. NotificationVisibility notificationVisibility = NotificationVisibility.obtain(r.getKey(), 1, 2, true); mService.mNotificationDelegate.onNotificationActionClick( 10, 10, r.getKey(), /*actionIndex=*/2, action, notificationVisibility, /*generatedByAssistant=*/false); // The flag is removed, so the notification is no longer lifetime extended. assertThat(r.getSbn().getNotification().flags & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY).isEqualTo(0); } @Test public void testOnAssistantNotificationActionClick() { final int actionIndex = 1; Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -1340,6 +1340,10 @@ public class NotificationManagerService extends SystemService { nv.recycle(); reportUserInteraction(r); mAssistants.notifyAssistantActionClicked(r, action, generatedByAssistant); // Notifications that have been interacted with don't need to be lifetime extended. if (lifetimeExtensionRefactor()) { r.getSbn().getNotification().flags &= ~FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY; } } } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -8409,6 +8409,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mNotificationRecordLogger.event(0)); } @Test public void testOnNotificationActionClickLifetimeExtendedEnds() { mSetFlagsRule.enableFlags(android.app.Flags.FLAG_LIFETIME_EXTENSION_REFACTOR); final Notification.Action action = new Notification.Action.Builder(null, "text", PendingIntent.getActivity( mContext, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE)).build(); // Creates a notification marked as being lifetime extended. NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); r.getSbn().getNotification().flags |= FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY; mService.addNotification(r); // Call on action click. NotificationVisibility notificationVisibility = NotificationVisibility.obtain(r.getKey(), 1, 2, true); mService.mNotificationDelegate.onNotificationActionClick( 10, 10, r.getKey(), /*actionIndex=*/2, action, notificationVisibility, /*generatedByAssistant=*/false); // The flag is removed, so the notification is no longer lifetime extended. assertThat(r.getSbn().getNotification().flags & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY).isEqualTo(0); } @Test public void testOnAssistantNotificationActionClick() { final int actionIndex = 1; Loading