Merge "Ignore ongoing notifications in dreams." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1310957275
@@ -37,7 +37,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
/***
|
/***
|
||||||
* {@link DreamOverlayNotificationCountProvider} provides the current notification count to
|
* {@link DreamOverlayNotificationCountProvider} provides the current notification count to
|
||||||
* registered callbacks.
|
* registered callbacks. Ongoing notifications are not included in the count.
|
||||||
*/
|
*/
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
public class DreamOverlayNotificationCountProvider
|
public class DreamOverlayNotificationCountProvider
|
||||||
@@ -49,6 +49,10 @@ public class DreamOverlayNotificationCountProvider
|
|||||||
@Override
|
@Override
|
||||||
public void onNotificationPosted(
|
public void onNotificationPosted(
|
||||||
StatusBarNotification sbn, NotificationListenerService.RankingMap rankingMap) {
|
StatusBarNotification sbn, NotificationListenerService.RankingMap rankingMap) {
|
||||||
|
if (sbn.isOngoing()) {
|
||||||
|
// Don't count ongoing notifications.
|
||||||
|
return;
|
||||||
|
}
|
||||||
mNotificationKeys.add(sbn.getKey());
|
mNotificationKeys.add(sbn.getKey());
|
||||||
reportNotificationCountChanged();
|
reportNotificationCountChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.dreams;
|
package com.android.systemui.dreams;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -48,6 +49,8 @@ public class DreamOverlayNotificationCountProviderTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
StatusBarNotification mNotification2;
|
StatusBarNotification mNotification2;
|
||||||
@Mock
|
@Mock
|
||||||
|
StatusBarNotification mNotification3;
|
||||||
|
@Mock
|
||||||
NotificationListenerService.RankingMap mRankingMap;
|
NotificationListenerService.RankingMap mRankingMap;
|
||||||
|
|
||||||
private DreamOverlayNotificationCountProvider mProvider;
|
private DreamOverlayNotificationCountProvider mProvider;
|
||||||
@@ -58,6 +61,8 @@ public class DreamOverlayNotificationCountProviderTest extends SysuiTestCase {
|
|||||||
|
|
||||||
when(mNotification1.getKey()).thenReturn("key1");
|
when(mNotification1.getKey()).thenReturn("key1");
|
||||||
when(mNotification2.getKey()).thenReturn("key2");
|
when(mNotification2.getKey()).thenReturn("key2");
|
||||||
|
when(mNotification3.getKey()).thenReturn("key3");
|
||||||
|
when(mNotification3.isOngoing()).thenReturn(true);
|
||||||
|
|
||||||
final StatusBarNotification[] notifications = {mNotification1};
|
final StatusBarNotification[] notifications = {mNotification1};
|
||||||
when(mNotificationListener.getActiveNotifications()).thenReturn(notifications);
|
when(mNotificationListener.getActiveNotifications()).thenReturn(notifications);
|
||||||
@@ -83,4 +88,13 @@ public class DreamOverlayNotificationCountProviderTest extends SysuiTestCase {
|
|||||||
handlerArgumentCaptor.getValue().onNotificationRemoved(mNotification1, mRankingMap);
|
handlerArgumentCaptor.getValue().onNotificationRemoved(mNotification1, mRankingMap);
|
||||||
verify(mCallback).onNotificationCountChanged(0);
|
verify(mCallback).onNotificationCountChanged(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPostingOngoingNotificationDoesNotCallCallbackWithNotificationCount() {
|
||||||
|
final ArgumentCaptor<NotificationHandler> handlerArgumentCaptor =
|
||||||
|
ArgumentCaptor.forClass(NotificationHandler.class);
|
||||||
|
verify(mNotificationListener).addNotificationHandler(handlerArgumentCaptor.capture());
|
||||||
|
handlerArgumentCaptor.getValue().onNotificationPosted(mNotification3, mRankingMap);
|
||||||
|
verify(mCallback, never()).onNotificationCountChanged(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user