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

Commit 07cb3692 authored by Jeff Nainaparampil's avatar Jeff Nainaparampil
Browse files

[People Service] Fix issue in AOSP people service where `setupUser` in the...

[People Service] Fix issue in AOSP people service where `setupUser` in the People DataManager is stuck

Due to a missing `break` statement, People DataManager `setupUser` gets stuck at `userData.loadUserData()`, which prevents important listeners from registering properly. Among other things, this prevents the conversation widget from showing recent conversations.

This CL fixes and adds tests for the proto conversion flow.

Bug: 246928516
Change-Id: I929e1989761c8234c252b935afbe63712e93e124
parent e076cf2d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -424,6 +424,7 @@ public class ConversationInfo {
                case (int) ConversationInfoProto.CREATION_TIMESTAMP:
                case (int) ConversationInfoProto.CREATION_TIMESTAMP:
                    builder.setCreationTimestamp(protoInputStream.readLong(
                    builder.setCreationTimestamp(protoInputStream.readLong(
                            ConversationInfoProto.CREATION_TIMESTAMP));
                            ConversationInfoProto.CREATION_TIMESTAMP));
                    break;
                case (int) ConversationInfoProto.SHORTCUT_FLAGS:
                case (int) ConversationInfoProto.SHORTCUT_FLAGS:
                    builder.setShortcutFlags(protoInputStream.readInt(
                    builder.setShortcutFlags(protoInputStream.readInt(
                            ConversationInfoProto.SHORTCUT_FLAGS));
                            ConversationInfoProto.SHORTCUT_FLAGS));
+56 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,8 @@ import android.app.people.ConversationStatus;
import android.content.LocusId;
import android.content.LocusId;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutInfo;
import android.net.Uri;
import android.net.Uri;
import android.util.proto.ProtoInputStream;
import android.util.proto.ProtoOutputStream;


import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
@@ -270,4 +272,58 @@ public final class ConversationInfoTest {
        assertTrue(conversationInfoFromBackup.isContactStarred());
        assertTrue(conversationInfoFromBackup.isContactStarred());
        // ConversationStatus is a transient object and not persisted
        // ConversationStatus is a transient object and not persisted
    }
    }

    @Test
    public void testBuildFromProtoPayload() throws Exception {
        ConversationStatus cs = new ConversationStatus.Builder("id", ACTIVITY_ANNIVERSARY).build();
        ConversationStatus cs2 = new ConversationStatus.Builder("id2", ACTIVITY_GAME).build();

        ConversationInfo conversationInfo = new ConversationInfo.Builder()
                .setShortcutId(SHORTCUT_ID)
                .setLocusId(LOCUS_ID)
                .setContactUri(CONTACT_URI)
                .setContactPhoneNumber(PHONE_NUMBER)
                .setNotificationChannelId(NOTIFICATION_CHANNEL_ID)
                .setParentNotificationChannelId(PARENT_NOTIFICATION_CHANNEL_ID)
                .setLastEventTimestamp(100L)
                .setCreationTimestamp(200L)
                .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED
                        | ShortcutInfo.FLAG_CACHED_NOTIFICATIONS)
                .setImportant(true)
                .setNotificationSilenced(true)
                .setBubbled(true)
                .setDemoted(true)
                .setPersonImportant(true)
                .setPersonBot(true)
                .setContactStarred(true)
                .addOrUpdateStatus(cs)
                .addOrUpdateStatus(cs2)
                .build();

        final ProtoOutputStream protoOutputStream = new ProtoOutputStream();
        conversationInfo.writeToProto(protoOutputStream);
        ConversationInfo conversationInfoFromBackup =
                ConversationInfo.readFromProto(new ProtoInputStream(protoOutputStream.getBytes()));

        assertEquals(SHORTCUT_ID, conversationInfoFromBackup.getShortcutId());
        assertEquals(LOCUS_ID, conversationInfoFromBackup.getLocusId());
        assertEquals(CONTACT_URI, conversationInfoFromBackup.getContactUri());
        assertEquals(PHONE_NUMBER, conversationInfoFromBackup.getContactPhoneNumber());
        assertEquals(
                NOTIFICATION_CHANNEL_ID, conversationInfoFromBackup.getNotificationChannelId());
        assertEquals(PARENT_NOTIFICATION_CHANNEL_ID,
                conversationInfoFromBackup.getParentNotificationChannelId());
        assertEquals(100L, conversationInfoFromBackup.getLastEventTimestamp());
        assertEquals(200L, conversationInfoFromBackup.getCreationTimestamp());
        assertTrue(conversationInfoFromBackup.isShortcutLongLived());
        assertTrue(conversationInfoFromBackup.isShortcutCachedForNotification());
        assertTrue(conversationInfoFromBackup.isImportant());
        assertTrue(conversationInfoFromBackup.isNotificationSilenced());
        assertTrue(conversationInfoFromBackup.isBubbled());
        assertTrue(conversationInfoFromBackup.isDemoted());
        assertTrue(conversationInfoFromBackup.isPersonImportant());
        assertTrue(conversationInfoFromBackup.isPersonBot());
        assertTrue(conversationInfoFromBackup.isContactStarred());
        // ConversationStatus is a transient object and not persisted
    }
}
}