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

Commit 112dfb3f authored by Danning Chen's avatar Danning Chen Committed by Android (Google) Code Review
Browse files

Merge "Cache the shortcut if the user has changed the conversation's notification settings"

parents ffb2f120 1cc71978
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ public class ConversationInfo {
        return hasShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED);
    }

    /** Whether the shortcut for this conversation is cached in Shortcut Service. */
    public boolean isShortcutCached() {
        return hasShortcutFlags(ShortcutInfo.FLAG_CACHED);
    }

    /** Whether this conversation is marked as important by the user. */
    public boolean isImportant() {
        return hasConversationFlags(FLAG_IMPORTANT);
@@ -213,6 +218,9 @@ public class ConversationInfo {
        if (isShortcutLongLived()) {
            sb.append("Liv");
        }
        if (isShortcutCached()) {
            sb.append("Cac");
        }
        sb.append("]");
        sb.append(", conversationFlags=0x").append(Integer.toHexString(mConversationFlags));
        sb.append(" [");
+9 −1
Original line number Diff line number Diff line
@@ -696,7 +696,15 @@ public class DataManager {
                    break;
            }
            conversationStore.addOrUpdate(builder.build());
            // TODO: Cache the shortcut when a conversation's notification setting is changed.

            if (modificationType == NOTIFICATION_CHANNEL_OR_GROUP_UPDATED
                    && conversationInfo.isShortcutLongLived()
                    && !conversationInfo.isShortcutCached()) {
                mShortcutServiceInternal.cacheShortcuts(user.getIdentifier(),
                        mContext.getPackageName(), pkg,
                        Collections.singletonList(conversationInfo.getShortcutId()),
                        user.getIdentifier());
            }
        }
    }

+3 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public final class ConversationInfoTest {
                .setContactUri(CONTACT_URI)
                .setContactPhoneNumber(PHONE_NUMBER)
                .setNotificationChannelId(NOTIFICATION_CHANNEL_ID)
                .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED)
                .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED | ShortcutInfo.FLAG_CACHED)
                .setImportant(true)
                .setNotificationSilenced(true)
                .setBubbled(true)
@@ -62,6 +62,7 @@ public final class ConversationInfoTest {
        assertEquals(PHONE_NUMBER, conversationInfo.getContactPhoneNumber());
        assertEquals(NOTIFICATION_CHANNEL_ID, conversationInfo.getNotificationChannelId());
        assertTrue(conversationInfo.isShortcutLongLived());
        assertTrue(conversationInfo.isShortcutCached());
        assertTrue(conversationInfo.isImportant());
        assertTrue(conversationInfo.isNotificationSilenced());
        assertTrue(conversationInfo.isBubbled());
@@ -83,6 +84,7 @@ public final class ConversationInfoTest {
        assertNull(conversationInfo.getContactPhoneNumber());
        assertNull(conversationInfo.getNotificationChannelId());
        assertFalse(conversationInfo.isShortcutLongLived());
        assertFalse(conversationInfo.isShortcutCached());
        assertFalse(conversationInfo.isImportant());
        assertFalse(conversationInfo.isNotificationSilenced());
        assertFalse(conversationInfo.isBubbled());
+4 −0
Original line number Diff line number Diff line
@@ -416,6 +416,9 @@ public final class DataManagerTest {
        assertTrue(conversationInfo.isImportant());
        assertFalse(conversationInfo.isNotificationSilenced());
        assertFalse(conversationInfo.isDemoted());
        verify(mShortcutServiceInternal).cacheShortcuts(
                anyInt(), any(), eq(TEST_PKG_NAME),
                eq(Collections.singletonList(TEST_SHORTCUT_ID)), eq(USER_ID_PRIMARY));
    }

    @Test
@@ -612,6 +615,7 @@ public final class DataManagerTest {
        when(mockContext.getUser()).thenReturn(UserHandle.of(userId));
        ShortcutInfo.Builder builder = new ShortcutInfo.Builder(mockContext, id)
                .setShortLabel(id)
                .setLongLived(true)
                .setIntent(new Intent("TestIntent"));
        if (person != null) {
            builder.setPersons(new Person[] {person});