Loading packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputNotificationRebuilder.java +9 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,15 @@ public class RemoteInputNotificationRebuilder { @NonNull public StatusBarNotification rebuildForCanceledSmartReplies( NotificationEntry entry) { return rebuildWithExistingReplies(entry); } /** * Rebuilds to include any previously-added remote input replies. * For when the app cancels a notification that has already been lifetime extended. */ @NonNull public StatusBarNotification rebuildWithExistingReplies(NotificationEntry entry) { return rebuildWithRemoteInputInserted(entry, null /* remoteInputText */, false /* showSpinner */, null /* mimeType */, null /* uri */); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ class RemoteInputCoordinator @Inject constructor( mSmartReplyController.stopSending(entry) mNotifUpdater.onInternalNotificationUpdate(newSbn, "Extending lifetime of notification with smart reply") } else { // The app may have re-cancelled a notification after it had already // been lifetime extended. // Rebuild the notification with the replies it already had to ensure // those replies continue to be displayed. val newSbn = mRebuilder.rebuildWithExistingReplies(entry) mNotifUpdater.onInternalNotificationUpdate(newSbn, "Extending lifetime of notification that has already been " + "lifetime extended.") } } else { // Notifications updated without FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt +19 −1 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ class RemoteInputCoordinatorTest : SysuiTestCase() { `when`(rebuilder.rebuildForCanceledSmartReplies(any())).thenReturn(sbn) `when`(rebuilder.rebuildForRemoteInputReply(any())).thenReturn(sbn) `when`(rebuilder.rebuildForSendingSmartReply(any(), any())).thenReturn(sbn) `when`(rebuilder.rebuildWithExistingReplies(any())).thenReturn(sbn) } val remoteInputActiveExtender get() = coordinator.mRemoteInputActiveExtender Loading Loading @@ -208,11 +209,28 @@ class RemoteInputCoordinatorTest : SysuiTestCase() { it.onEntryUpdated(entry, true) } verify(rebuilder, times(1)).rebuildForCanceledSmartReplies(entry) verify(smartReplyController, times(1)).stopSending(entry) } @Test @EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR) fun testRepeatedUpdateTriggersRebuild() { // Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag. val entry = NotificationEntryBuilder() .setId(3) .setTag("entry") .setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, true) .build() `when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(false) `when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(false) collectionListeners.forEach { it.onEntryUpdated(entry, true) } verify(rebuilder, times(1)).rebuildWithExistingReplies(entry) } @Test @EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR) fun testLifetimeExtensionListenerClearsRemoteInputs() { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputNotificationRebuilder.java +9 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,15 @@ public class RemoteInputNotificationRebuilder { @NonNull public StatusBarNotification rebuildForCanceledSmartReplies( NotificationEntry entry) { return rebuildWithExistingReplies(entry); } /** * Rebuilds to include any previously-added remote input replies. * For when the app cancels a notification that has already been lifetime extended. */ @NonNull public StatusBarNotification rebuildWithExistingReplies(NotificationEntry entry) { return rebuildWithRemoteInputInserted(entry, null /* remoteInputText */, false /* showSpinner */, null /* mimeType */, null /* uri */); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ class RemoteInputCoordinator @Inject constructor( mSmartReplyController.stopSending(entry) mNotifUpdater.onInternalNotificationUpdate(newSbn, "Extending lifetime of notification with smart reply") } else { // The app may have re-cancelled a notification after it had already // been lifetime extended. // Rebuild the notification with the replies it already had to ensure // those replies continue to be displayed. val newSbn = mRebuilder.rebuildWithExistingReplies(entry) mNotifUpdater.onInternalNotificationUpdate(newSbn, "Extending lifetime of notification that has already been " + "lifetime extended.") } } else { // Notifications updated without FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt +19 −1 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ class RemoteInputCoordinatorTest : SysuiTestCase() { `when`(rebuilder.rebuildForCanceledSmartReplies(any())).thenReturn(sbn) `when`(rebuilder.rebuildForRemoteInputReply(any())).thenReturn(sbn) `when`(rebuilder.rebuildForSendingSmartReply(any(), any())).thenReturn(sbn) `when`(rebuilder.rebuildWithExistingReplies(any())).thenReturn(sbn) } val remoteInputActiveExtender get() = coordinator.mRemoteInputActiveExtender Loading Loading @@ -208,11 +209,28 @@ class RemoteInputCoordinatorTest : SysuiTestCase() { it.onEntryUpdated(entry, true) } verify(rebuilder, times(1)).rebuildForCanceledSmartReplies(entry) verify(smartReplyController, times(1)).stopSending(entry) } @Test @EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR) fun testRepeatedUpdateTriggersRebuild() { // Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag. val entry = NotificationEntryBuilder() .setId(3) .setTag("entry") .setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, true) .build() `when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(false) `when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(false) collectionListeners.forEach { it.onEntryUpdated(entry, true) } verify(rebuilder, times(1)).rebuildWithExistingReplies(entry) } @Test @EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR) fun testLifetimeExtensionListenerClearsRemoteInputs() { Loading