Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e0e2cbe authored by Anna Zappone's avatar Anna Zappone
Browse files

Fill Status data in ConversationChannel

For People Tiles to access the statuses associated with the
conversation.

Bug: 178792356
Test: DataManagerTest
Change-Id: I10763861f6ec4bf010be27b7aa0baa1038a0f087
parent 8e79f01a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -264,7 +264,8 @@ public class DataManager {
        return new ConversationChannel(shortcutInfo, uid, parentChannel,
                parentChannelGroup,
                conversationInfo.getLastEventTimestamp(),
                hasActiveNotifications(packageName, userId, shortcutId));
                hasActiveNotifications(packageName, userId, shortcutId), false,
                getStatuses(conversationInfo));
    }

    /** Returns the cached non-customized recent conversations. */
@@ -404,6 +405,10 @@ public class DataManager {
            String conversationId) {
        ConversationStore cs = getConversationStoreOrThrow(packageName, userId);
        ConversationInfo conversationInfo = getConversationInfoOrThrow(cs, conversationId);
        return getStatuses(conversationInfo);
    }

    private @NonNull List<ConversationStatus> getStatuses(ConversationInfo conversationInfo) {
        Collection<ConversationStatus> statuses = conversationInfo.getStatuses();
        if (statuses != null) {
            final ArrayList<ConversationStatus> list = new ArrayList<>(statuses.size());
+10 −3
Original line number Diff line number Diff line
@@ -535,8 +535,11 @@ public final class DataManagerTest {
        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)).isNotNull();
        ConversationChannel result = mDataManager.getConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
                TEST_SHORTCUT_ID);
        assertThat(result).isNotNull();
        assertThat(result.hasBirthdayToday()).isFalse();
        assertThat(result.getStatuses()).isEmpty();
    }

    @Test
@@ -557,6 +560,8 @@ public final class DataManagerTest {
        NotificationListenerService listenerService =
                mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY);
        listenerService.onNotificationPosted(mStatusBarNotification);
        ConversationStatus cs = new ConversationStatus.Builder("id", ACTIVITY_ANNIVERSARY).build();
        mDataManager.addOrUpdateStatus(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID, cs);

        ConversationChannel result = mDataManager.getConversation(TEST_PKG_NAME, USER_ID_PRIMARY,
                TEST_SHORTCUT_ID);
@@ -568,6 +573,8 @@ public final class DataManagerTest {
                result.getParentNotificationChannel().getId());
        assertEquals(mStatusBarNotification.getPostTime(), result.getLastEventTimestamp());
        assertTrue(result.hasActiveNotifications());
        assertFalse(result.hasBirthdayToday());
        assertThat(result.getStatuses()).containsExactly(cs);
    }

    @Test