From 90d11a169043c9272ac11a088147d138b09166ef Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 17 Jan 2018 16:24:36 -0800 Subject: [PATCH] Fixed an issue where the notification wouldn't go away When autocancelling, the logic wasn't working anymore after we kept a notification around for a while. This is now properly working. Change-Id: I73f5485577e6ae081411638a4e3bd4f08cffc23c Fixes: 27851227 Bug: 63708826 Test: add notification with auto-cancel, reply from it, click on it again --- .../systemui/statusbar/NotificationData.java | 5 +++ .../statusbar/NotificationEntryManager.java | 1 + .../systemui/statusbar/phone/StatusBar.java | 32 ++++++++++++------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 9c893b6a1b150..127f3f918fba5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -272,6 +272,11 @@ public class NotificationData { public Throwable getDebugThrowable() { return mDebugThrowable; } + + public void onRemoteInputInserted() { + lastRemoteInputSent = NOT_LAUNCHED_YET; + remoteInputTextWhenReset = null; + } } private final ArrayMap mEntries = new ArrayMap<>(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java index 6249ace79aef7..5b06874219e61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java @@ -498,6 +498,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), newNotification, sbn.getUser(), sbn.getOverrideGroupKey(), sbn.getPostTime()); boolean updated = false; + entry.onRemoteInputInserted(); try { updateNotificationInternal(newSbn, null); updated = true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index af65a86676e8f..5e08ec3575fcc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -4931,18 +4931,11 @@ public class StatusBar extends SystemUI implements DemoMode, // system process is dead if we're here. } if (parentToCancelFinal != null) { - // We have to post it to the UI thread for synchronization - mHandler.post(() -> { - Runnable removeRunnable = - () -> mEntryManager.performRemoveNotification(parentToCancelFinal); - if (isCollapsing()) { - // To avoid lags we're only performing the remove - // after the shade was collapsed - addPostCollapseAction(removeRunnable); - } else { - removeRunnable.run(); - } - }); + removeNotification(parentToCancelFinal); + } + if (shouldAutoCancel(sbn)) { + // Automatically remove all notifications that we may have kept around longer + removeNotification(sbn); } }; @@ -4966,6 +4959,21 @@ public class StatusBar extends SystemUI implements DemoMode, }, afterKeyguardGone); } + private void removeNotification(StatusBarNotification notification) { + // We have to post it to the UI thread for synchronization + mHandler.post(() -> { + Runnable removeRunnable = + () -> mEntryManager.performRemoveNotification(notification); + if (isCollapsing()) { + // To avoid lags we're only performing the remove + // after the shade was collapsed + addPostCollapseAction(removeRunnable); + } else { + removeRunnable.run(); + } + }); + } + protected NotificationListener mNotificationListener; protected void notifyUserAboutHiddenNotifications() {