Merge "Hide demoted conversations from People service" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fa2a032dd8
@@ -264,7 +264,7 @@ public class DataManager {
|
||||
@Nullable
|
||||
private ConversationChannel getConversationChannel(ShortcutInfo shortcutInfo,
|
||||
ConversationInfo conversationInfo) {
|
||||
if (conversationInfo == null) {
|
||||
if (conversationInfo == null || conversationInfo.isDemoted()) {
|
||||
return null;
|
||||
}
|
||||
if (shortcutInfo == null) {
|
||||
|
||||
@@ -681,6 +681,29 @@ public final class DataManagerTest {
|
||||
assertThat(result.getStatuses()).containsExactly(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConversation_demoted() {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
assertThat(mDataManager.getConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
|
||||
TEST_SHORTCUT_ID)).isNull();
|
||||
|
||||
ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
|
||||
buildPerson());
|
||||
shortcut.setCached(ShortcutInfo.FLAG_PINNED);
|
||||
mDataManager.addOrUpdateConversationInfo(shortcut);
|
||||
assertThat(mDataManager.getConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
|
||||
TEST_SHORTCUT_ID)).isNotNull();
|
||||
|
||||
mNotificationChannel.setDemoted(true);
|
||||
NotificationListenerService listenerService =
|
||||
mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY);
|
||||
listenerService.onNotificationChannelModified(TEST_PKG_NAME, UserHandle.of(USER_ID_PRIMARY),
|
||||
mNotificationChannel, NOTIFICATION_CHANNEL_OR_GROUP_UPDATED);
|
||||
|
||||
assertThat(mDataManager.getConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
|
||||
TEST_SHORTCUT_ID)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConversationGetsPersonsData() {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
@@ -719,6 +742,27 @@ public final class DataManagerTest {
|
||||
TEST_SHORTCUT_ID + "1")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsConversation_demoted() {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
assertThat(mDataManager.isConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
|
||||
TEST_SHORTCUT_ID)).isFalse();
|
||||
|
||||
ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
|
||||
buildPerson());
|
||||
shortcut.setCached(ShortcutInfo.FLAG_PINNED);
|
||||
mDataManager.addOrUpdateConversationInfo(shortcut);
|
||||
|
||||
mNotificationChannel.setDemoted(true);
|
||||
NotificationListenerService listenerService =
|
||||
mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY);
|
||||
listenerService.onNotificationChannelModified(TEST_PKG_NAME, UserHandle.of(USER_ID_PRIMARY),
|
||||
mNotificationChannel, NOTIFICATION_CHANNEL_OR_GROUP_UPDATED);
|
||||
|
||||
assertThat(mDataManager.isConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
|
||||
TEST_SHORTCUT_ID)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationChannelCreated() {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
@@ -1371,13 +1415,20 @@ public final class DataManagerTest {
|
||||
NotificationListenerService listenerService =
|
||||
mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY);
|
||||
listenerService.onNotificationPosted(mStatusBarNotification);
|
||||
// posting updates the last interaction time, so delay before deletion
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long approxDeletionTime = System.currentTimeMillis();
|
||||
listenerService.onNotificationRemoved(mStatusBarNotification, null,
|
||||
NotificationListenerService.REASON_CANCEL);
|
||||
|
||||
ConversationInfo conversationInfo = mDataManager.getPackage(TEST_PKG_NAME, USER_ID_PRIMARY)
|
||||
.getConversationStore()
|
||||
.getConversation(TEST_SHORTCUT_ID);
|
||||
assertEquals(conversationInfo.getLastEventTimestamp(), System.currentTimeMillis());
|
||||
assertTrue(conversationInfo.getLastEventTimestamp() - approxDeletionTime < 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user