}
public boolean shouldKeepForRemoteInputHistory(NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
if (!FORCE_REMOTE_INPUT_HISTORY) {
return false;
}
}
public boolean shouldKeepForSmartReplyHistory(NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
if (!FORCE_REMOTE_INPUT_HISTORY) {
return false;
}
protected class RemoteInputActiveExtender extends RemoteInputExtender {
@Override
public boolean shouldExtendLifetime(@NonNull NotificationEntry entry) {
- if (entry.isDismissed()) {
- return false;
- }
return mRemoteInputController.isRemoteInputActive(entry);
}
}
public void performRemoveNotification(StatusBarNotification n) {
- final int rank = mNotificationData.getRank(n.getKey());
- final int count = mNotificationData.getActiveNotifications().size();
- NotificationVisibility.NotificationLocation location =
- NotificationLogger.getNotificationLocation(getNotificationData().get(n.getKey()));
- final NotificationVisibility nv = NotificationVisibility.obtain(n.getKey(), rank, count,
- true, location);
+ final NotificationVisibility nv = obtainVisibility(n.getKey());
removeNotificationInternal(
n.getKey(), null, nv, false /* forceRemove */, true /* removedByUser */);
}
+ private NotificationVisibility obtainVisibility(String key) {
+ final int rank = mNotificationData.getRank(key);
+ final int count = mNotificationData.getActiveNotifications().size();
+ NotificationVisibility.NotificationLocation location =
+ NotificationLogger.getNotificationLocation(getNotificationData().get(key));
+ return NotificationVisibility.obtain(key, rank, count, true, location);
+ }
+
private void abortExistingInflation(String key) {
if (mPendingNotifications.containsKey(key)) {
NotificationEntry entry = mPendingNotifications.get(key);
@Override
public void removeNotification(String key, NotificationListenerService.RankingMap ranking) {
- removeNotificationInternal(
- key, ranking, null, false /* forceRemove */, false /* removedByUser */);
+ removeNotificationInternal(key, ranking, obtainVisibility(key), false /* forceRemove */,
+ false /* removedByUser */);
}
private void removeNotificationInternal(
if (entry != null) {
// If a manager needs to keep the notification around for whatever reason, we
// keep the notification
- if (!forceRemove) {
+ boolean entryDismissed = entry.isRowDismissed();
+ if (!forceRemove && !entryDismissed) {
for (NotificationLifetimeExtender extender : mNotificationLifetimeExtenders) {
if (extender.shouldExtendLifetime(entry)) {
mLatestRankingMap = ranking;
mNotificationData.remove(key, ranking);
updateNotifications();
Dependency.get(LeakDetector.class).trackGarbage(entry);
+ removedByUser |= entryDismissed;
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onEntryRemoved(entry, visibility, removedByUser);
verify(mPresenter).updateNotificationViews();
verify(mEntryListener).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false) /* removedByUser */);
verify(mRow).setRemoved();
assertNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
mEntryManager.removeNotification("not_a_real_key", mRankingMap);
verify(mEntryListener, never()).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false) /* removedByUser */);
}
@Test
mEntryManager.removeNotification(mSbn.getKey(), mRankingMap);
verify(mEntryListener, never()).onEntryRemoved(
- mEntry, null, false /* removedByUser */);
+ eq(mEntry), any(), eq(false /* removedByUser */));
}
@Test
verify(extender).setShouldManageLifetime(mEntry, true);
// THEN the notification is retained
assertNotNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
- verify(mEntryListener, never()).onEntryRemoved(mEntry, null, false);
+ verify(mEntryListener, never()).onEntryRemoved(eq(mEntry), any(), eq(false));
}
@Test
// THEN the notification is removed
assertNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
- verify(mEntryListener).onEntryRemoved(mEntry, null, false);
+ verify(mEntryListener).onEntryRemoved(eq(mEntry), any(), eq(false));
}
@Test