Updating PrimaryInfo value class to use AutoValue with builder pattern.

Bug: 34502119
Test: BottomRowTest,CallCardPresenterTest,PrimaryInfoTest,TopRowTest
PiperOrigin-RevId: 186460178
Change-Id: Ifb90019b6a5568788d51f4a55a07f7693c803eaf
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index da5d1a8..b945b08 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -690,7 +690,7 @@
 
     if (primary == null) {
       // Clear the primary display info.
-      inCallScreen.setPrimary(PrimaryInfo.createEmptyPrimaryInfo());
+      inCallScreen.setPrimary(PrimaryInfo.empty());
       return;
     }
 
@@ -713,26 +713,22 @@
           "update primary display info for conference call.");
 
       inCallScreen.setPrimary(
-          new PrimaryInfo(
-              null /* number */,
-              CallerInfoUtils.getConferenceString(
-                  context, primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)),
-              false /* nameIsNumber */,
-              null /* location */,
-              null /* label */,
-              null /* photo */,
-              ContactPhotoType.DEFAULT_PLACEHOLDER,
-              false /* isSipCall */,
-              showContactPhoto,
-              hasWorkCallProperty,
-              false /* isSpam */,
-              false /* isLocalContact */,
-              false /* answeringDisconnectsOngoingCall */,
-              shouldShowLocation(),
-              null /* contactInfoLookupKey */,
-              null /* enrichedCallMultimediaData */,
-              true /* showInCallButtonGrid */,
-              primary.getNumberPresentation()));
+          PrimaryInfo.builder()
+              .setName(
+                  CallerInfoUtils.getConferenceString(
+                      context, primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)))
+              .setNameIsNumber(false)
+              .setPhotoType(ContactPhotoType.DEFAULT_PLACEHOLDER)
+              .setIsSipCall(false)
+              .setIsContactPhotoShown(showContactPhoto)
+              .setIsWorkCall(hasWorkCallProperty)
+              .setIsSpam(false)
+              .setIsLocalContact(false)
+              .setAnsweringDisconnectsOngoingCall(false)
+              .setShouldShowLocation(shouldShowLocation())
+              .setShowInCallButtonGrid(true)
+              .setNumberPresentation(primary.getNumberPresentation())
+              .build());
     } else if (primaryContactInfo != null) {
       LogUtil.v(
           "CallCardPresenter.updatePrimaryDisplayInfo",
@@ -761,30 +757,33 @@
       // DialerCall with caller that is a work contact.
       boolean isWorkContact = (primaryContactInfo.userType == ContactsUtils.USER_TYPE_WORK);
       inCallScreen.setPrimary(
-          new PrimaryInfo(
-              number,
-              primary.updateNameIfRestricted(name),
-              nameIsNumber,
-              shouldShowLocationAsLabel(nameIsNumber, primaryContactInfo.shouldShowLocation)
-                  ? primaryContactInfo.location
-                  : null,
-              isChildNumberShown || isCallSubjectShown ? null : primaryContactInfo.label,
-              primaryContactInfo.photo,
-              primaryContactInfo.photoType,
-              primaryContactInfo.isSipCall,
-              showContactPhoto,
-              hasWorkCallProperty || isWorkContact,
-              primary.isSpam(),
-              primaryContactInfo.isLocalContact(),
-              primary.answeringDisconnectsForegroundVideoCall(),
-              shouldShowLocation(),
-              primaryContactInfo.lookupKey,
-              multimediaData,
-              true /* showInCallButtonGrid */,
-              primary.getNumberPresentation()));
+          PrimaryInfo.builder()
+              .setNumber(number)
+              .setName(primary.updateNameIfRestricted(name))
+              .setNameIsNumber(nameIsNumber)
+              .setLabel(
+                  shouldShowLocationAsLabel(nameIsNumber, primaryContactInfo.shouldShowLocation)
+                      ? primaryContactInfo.location
+                      : null)
+              .setLocation(
+                  isChildNumberShown || isCallSubjectShown ? null : primaryContactInfo.label)
+              .setPhoto(primaryContactInfo.photo)
+              .setPhotoType(primaryContactInfo.photoType)
+              .setIsSipCall(primaryContactInfo.isSipCall)
+              .setIsContactPhotoShown(showContactPhoto)
+              .setIsWorkCall(hasWorkCallProperty || isWorkContact)
+              .setIsSpam(primary.isSpam())
+              .setIsLocalContact(primaryContactInfo.isLocalContact())
+              .setAnsweringDisconnectsOngoingCall(primary.answeringDisconnectsForegroundVideoCall())
+              .setShouldShowLocation(shouldShowLocation())
+              .setContactInfoLookupKey(primaryContactInfo.lookupKey)
+              .setMultimediaData(multimediaData)
+              .setShowInCallButtonGrid(true)
+              .setNumberPresentation(primary.getNumberPresentation())
+              .build());
     } else {
       // Clear the primary display info.
-      inCallScreen.setPrimary(PrimaryInfo.createEmptyPrimaryInfo());
+      inCallScreen.setPrimary(PrimaryInfo.empty());
     }
 
     if (isInCallScreenReady) {
@@ -1192,6 +1191,7 @@
     return inCallScreen;
   }
 
+  /** Callback for contact lookup. */
   public static class ContactLookupCallback implements ContactInfoCacheCallback {
 
     private final WeakReference<CallCardPresenter> callCardPresenter;
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index 8626e6d..3439a3e 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -149,7 +149,7 @@
   private boolean buttonAcceptClicked;
   private boolean buttonRejectClicked;
   private boolean hasAnimatedEntry;
-  private PrimaryInfo primaryInfo = PrimaryInfo.createEmptyPrimaryInfo();
+  private PrimaryInfo primaryInfo = PrimaryInfo.empty();
   private PrimaryCallState primaryCallState;
   private ArrayList<CharSequence> textResponses;
   private SmsBottomSheetFragment textResponsesFragment;
@@ -523,13 +523,13 @@
       return;
     }
     contactGridManager.setPrimary(primaryInfo);
-    getAnswerMethod().setShowIncomingWillDisconnect(primaryInfo.answeringDisconnectsOngoingCall);
+    getAnswerMethod().setShowIncomingWillDisconnect(primaryInfo.answeringDisconnectsOngoingCall());
     getAnswerMethod()
         .setContactPhoto(
-            primaryInfo.photoType == ContactPhotoType.CONTACT ? primaryInfo.photo : null);
+            primaryInfo.photoType() == ContactPhotoType.CONTACT ? primaryInfo.photo() : null);
     updateDataFragment();
 
-    if (primaryInfo.shouldShowLocation) {
+    if (primaryInfo.shouldShowLocation()) {
       // Hide the avatar to make room for location
       contactGridManager.setAvatarHidden(true);
     }
@@ -562,8 +562,8 @@
             MultimediaFragment.newInstance(
                 multimediaData,
                 false /* isInteractive */,
-                !primaryInfo.isSpam /* showAvatar */,
-                primaryInfo.isSpam);
+                !primaryInfo.isSpam() /* showAvatar */,
+                primaryInfo.isSpam());
       }
     } else if (shouldShowAvatar()) {
       // Needs Avatar
@@ -1067,7 +1067,7 @@
       return;
     }
 
-    if (!getResources().getBoolean(R.bool.answer_important_call_allowed) || primaryInfo.isSpam) {
+    if (!getResources().getBoolean(R.bool.answer_important_call_allowed) || primaryInfo.isSpam()) {
       importanceBadge.setVisibility(View.GONE);
       return;
     }
@@ -1088,7 +1088,7 @@
     if (isVideoUpgradeRequest()) {
       return null;
     }
-    return primaryInfo.multimediaData;
+    return primaryInfo.multimediaData();
   }
 
   /** Shows the Avatar image if available. */
diff --git a/java/com/android/incallui/callpending/CallPendingActivity.java b/java/com/android/incallui/callpending/CallPendingActivity.java
index 47325d8..306eed8 100644
--- a/java/com/android/incallui/callpending/CallPendingActivity.java
+++ b/java/com/android/incallui/callpending/CallPendingActivity.java
@@ -177,25 +177,25 @@
     String number = getNumber();
 
     // DialerCall with caller that is a work contact.
-    return new PrimaryInfo(
-        number,
-        name,
-        name != null && name.equals(number),
-        null /* location */,
-        getPhoneLabel(),
-        photo,
-        ContactPhotoType.CONTACT,
-        false /* isSipCall */,
-        true /* isContactPhotoShown */,
-        false /* isWorkCall */,
-        false /* isSpam */,
-        true /* isLocalContact */,
-        false /* answeringDisconnectsOngoingCall */,
-        false /* shouldShowLocation */,
-        getLookupKey(),
-        multimediaData,
-        false /*showInCallButtonGrid */,
-        TelecomManager.PRESENTATION_ALLOWED);
+    return PrimaryInfo.builder()
+        .setNumber(number)
+        .setName(name)
+        .setNameIsNumber(name != null && name.equals(number))
+        .setLabel(getPhoneLabel())
+        .setPhoto(photo)
+        .setPhotoType(ContactPhotoType.CONTACT)
+        .setIsSipCall(false)
+        .setIsContactPhotoShown(true)
+        .setIsWorkCall(false)
+        .setIsSpam(false)
+        .setIsLocalContact(true)
+        .setAnsweringDisconnectsOngoingCall(false)
+        .setShouldShowLocation(false)
+        .setContactInfoLookupKey(getLookupKey())
+        .setMultimediaData(multimediaData)
+        .setShowInCallButtonGrid(false)
+        .setNumberPresentation(TelecomManager.PRESENTATION_ALLOWED)
+        .build();
   }
 
   @Override
diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java
index f9fc870..610eeca 100644
--- a/java/com/android/incallui/contactgrid/BottomRow.java
+++ b/java/com/android/incallui/contactgrid/BottomRow.java
@@ -82,7 +82,7 @@
     boolean isSpamIconVisible = false;
     boolean shouldPopulateAccessibilityEvent = true;
 
-    if (isIncoming(state) && primaryInfo.isSpam) {
+    if (isIncoming(state) && primaryInfo.isSpam()) {
       label = context.getString(R.string.contact_grid_incoming_suspected_spam);
       isSpamIconVisible = true;
       isHdIconVisible = false;
@@ -99,7 +99,7 @@
       }
     } else {
       label = getLabelForPhoneNumber(primaryInfo);
-      shouldPopulateAccessibilityEvent = primaryInfo.nameIsNumber;
+      shouldPopulateAccessibilityEvent = primaryInfo.nameIsNumber();
     }
 
     return new Info(
@@ -114,15 +114,15 @@
   }
 
   private static CharSequence getLabelForPhoneNumber(PrimaryInfo primaryInfo) {
-    if (primaryInfo.location != null) {
-      return primaryInfo.location;
+    if (primaryInfo.location() != null) {
+      return primaryInfo.location();
     }
-    if (!primaryInfo.nameIsNumber && !TextUtils.isEmpty(primaryInfo.number)) {
-      CharSequence spannedNumber = spanDisplayNumber(primaryInfo.number);
-      if (primaryInfo.label == null) {
+    if (!primaryInfo.nameIsNumber() && !TextUtils.isEmpty(primaryInfo.number())) {
+      CharSequence spannedNumber = spanDisplayNumber(primaryInfo.number());
+      if (primaryInfo.label() == null) {
         return spannedNumber;
       } else {
-        return TextUtils.concat(primaryInfo.label, " ", spannedNumber);
+        return TextUtils.concat(primaryInfo.label(), " ", spannedNumber);
       }
     }
     return null;
diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java
index 58d3188..6dec764 100644
--- a/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -85,7 +85,7 @@
   private final TextView deviceNumberTextView;
   private final View deviceNumberDivider;
 
-  private PrimaryInfo primaryInfo = PrimaryInfo.createEmptyPrimaryInfo();
+  private PrimaryInfo primaryInfo = PrimaryInfo.empty();
   private PrimaryCallState primaryCallState = PrimaryCallState.createEmptyPrimaryCallState();
   private final LetterTileDrawable letterTile;
   private boolean isInMultiWindowMode;
@@ -213,7 +213,7 @@
     }
 
     boolean hasPhoto =
-        primaryInfo.photo != null && primaryInfo.photoType == ContactPhotoType.CONTACT;
+        primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT;
     if (!hasPhoto && !showAnonymousAvatar) {
       avatarImageView.setVisibility(View.GONE);
       return false;
@@ -271,17 +271,17 @@
    * </ul>
    */
   private void updatePrimaryNameAndPhoto() {
-    if (TextUtils.isEmpty(primaryInfo.name)) {
+    if (TextUtils.isEmpty(primaryInfo.name())) {
       contactNameTextView.setText(null);
     } else {
       contactNameTextView.setText(
-          primaryInfo.nameIsNumber
-              ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name)
-              : primaryInfo.name);
+          primaryInfo.nameIsNumber()
+              ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name())
+              : primaryInfo.name());
 
       // Set direction of the name field
       int nameDirection = View.TEXT_DIRECTION_INHERIT;
-      if (primaryInfo.nameIsNumber) {
+      if (primaryInfo.nameIsNumber()) {
         nameDirection = View.TEXT_DIRECTION_LTR;
       }
       contactNameTextView.setTextDirection(nameDirection);
@@ -292,23 +292,23 @@
         avatarImageView.setVisibility(View.GONE);
       } else if (avatarSize > 0 && updateAvatarVisibility()) {
         boolean hasPhoto =
-            primaryInfo.photo != null && primaryInfo.photoType == ContactPhotoType.CONTACT;
+            primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT;
         // Contact has a photo, don't render a letter tile.
         if (hasPhoto) {
           avatarImageView.setBackground(
               DrawableConverter.getRoundedDrawable(
-                  context, primaryInfo.photo, avatarSize, avatarSize));
+                  context, primaryInfo.photo(), avatarSize, avatarSize));
           // Contact has a name, that isn't a number.
         } else {
           letterTile.setCanonicalDialerLetterTileDetails(
-              primaryInfo.name,
-              primaryInfo.contactInfoLookupKey,
+              primaryInfo.name(),
+              primaryInfo.contactInfoLookupKey(),
               LetterTileDrawable.SHAPE_CIRCLE,
               LetterTileDrawable.getContactTypeFromPrimitives(
                   primaryCallState.isVoiceMailNumber,
-                  primaryInfo.isSpam,
+                  primaryInfo.isSpam(),
                   primaryCallState.isBusinessNumber,
-                  primaryInfo.numberPresentation,
+                  primaryInfo.numberPresentation(),
                   primaryCallState.isConference));
           // By invalidating the avatarImageView we force a redraw of the letter tile.
           // This is required to properly display the updated letter tile iconography based on the
@@ -413,7 +413,7 @@
     deviceNumberTextView.setText(
         context.getString(R.string.contact_grid_callback_number, primaryCallState.callbackNumber));
     deviceNumberTextView.setVisibility(View.VISIBLE);
-    if (primaryInfo.shouldShowLocation) {
+    if (primaryInfo.shouldShowLocation()) {
       deviceNumberDivider.setVisibility(View.VISIBLE);
     }
   }
diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java
index 556b11b..5eb38f9 100644
--- a/java/com/android/incallui/contactgrid/TopRow.java
+++ b/java/com/android/incallui/contactgrid/TopRow.java
@@ -81,7 +81,7 @@
         // Show phone number if it's not displayed in name (center row) or location field (bottom
         // row).
         if (shouldShowNumber(primaryInfo, true /* isIncoming */)) {
-          label = TextUtils.concat(label, " ", spanDisplayNumber(primaryInfo.number));
+          label = TextUtils.concat(label, " ", spanDisplayNumber(primaryInfo.number()));
         }
       }
     } else if (VideoUtils.hasSentVideoUpgradeRequest(state.sessionModificationState)
@@ -97,7 +97,7 @@
       label = context.getString(R.string.incall_remotely_held);
     } else if (state.state == State.ACTIVE
         && shouldShowNumber(primaryInfo, false /* isIncoming */)) {
-      label = spanDisplayNumber(primaryInfo.number);
+      label = spanDisplayNumber(primaryInfo.number());
     } else if (state.state == State.CALL_PENDING && !TextUtils.isEmpty(state.customLabel)) {
       label = state.customLabel;
     } else {
@@ -115,18 +115,18 @@
   }
 
   private static boolean shouldShowNumber(PrimaryInfo primaryInfo, boolean isIncoming) {
-    if (primaryInfo.nameIsNumber) {
+    if (primaryInfo.nameIsNumber()) {
       return false;
     }
     // Don't show number since it's already shown in bottom row of incoming screen if there is no
     // location info.
-    if (primaryInfo.location == null && isIncoming) {
+    if (primaryInfo.location() == null && isIncoming) {
       return false;
     }
-    if (primaryInfo.isLocalContact && !isIncoming) {
+    if (primaryInfo.isLocalContact() && !isIncoming) {
       return false;
     }
-    if (TextUtils.isEmpty(primaryInfo.number)) {
+    if (TextUtils.isEmpty(primaryInfo.number())) {
       return false;
     }
     return true;
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index a4dcd72..9a6d1c4 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -253,10 +253,10 @@
   @Override
   public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
     LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString());
-    setAdapterMedia(primaryInfo.multimediaData, primaryInfo.showInCallButtonGrid);
+    setAdapterMedia(primaryInfo.multimediaData(), primaryInfo.showInCallButtonGrid());
     contactGridManager.setPrimary(primaryInfo);
 
-    if (primaryInfo.shouldShowLocation) {
+    if (primaryInfo.shouldShowLocation()) {
       // Hide the avatar to make room for location
       contactGridManager.setAvatarHidden(true);
 
diff --git a/java/com/android/incallui/incall/protocol/PrimaryInfo.java b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
index f7457c3..63dc39e 100644
--- a/java/com/android/incallui/incall/protocol/PrimaryInfo.java
+++ b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
@@ -20,91 +20,116 @@
 import android.support.annotation.Nullable;
 import com.android.dialer.common.LogUtil;
 import com.android.dialer.multimedia.MultimediaData;
+import com.google.auto.value.AutoValue;
 import java.util.Locale;
 
 /** Information about the primary call. */
-public class PrimaryInfo {
-  @Nullable public final String number;
-  @Nullable public final String name;
-  public final boolean nameIsNumber;
-  // This is from contacts and shows the type of number. For example, "Mobile".
-  @Nullable public final String label;
-  @Nullable public final String location;
-  @Nullable public final Drawable photo;
-  @ContactPhotoType public final int photoType;
-  public final boolean isSipCall;
-  public final boolean isContactPhotoShown;
-  public final boolean isWorkCall;
-  public final boolean isSpam;
-  public final boolean isLocalContact;
-  public final boolean answeringDisconnectsOngoingCall;
-  public final boolean shouldShowLocation;
-  // Used for consistent LetterTile coloring.
-  @Nullable public final String contactInfoLookupKey;
-  @Nullable public final MultimediaData multimediaData;
-  public final boolean showInCallButtonGrid;
-  public final int numberPresentation;
+@AutoValue
+public abstract class PrimaryInfo {
+  @Nullable
+  public abstract String number();
 
-  // TODO: Convert to autovalue. a bug
-  public static PrimaryInfo createEmptyPrimaryInfo() {
-    return new PrimaryInfo(
-        null,
-        null,
-        false,
-        null,
-        null,
-        null,
-        ContactPhotoType.DEFAULT_PLACEHOLDER,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        null,
-        null,
-        true,
-        -1);
+  @Nullable
+  public abstract String name();
+
+  public abstract boolean nameIsNumber();
+  // This is from contacts and shows the type of number. For example, "Mobile".
+  @Nullable
+  public abstract String label();
+
+  @Nullable
+  public abstract String location();
+
+  @Nullable
+  public abstract Drawable photo();
+
+  @ContactPhotoType
+  public abstract int photoType();
+
+  public abstract boolean isSipCall();
+
+  public abstract boolean isContactPhotoShown();
+
+  public abstract boolean isWorkCall();
+
+  public abstract boolean isSpam();
+
+  public abstract boolean isLocalContact();
+
+  public abstract boolean answeringDisconnectsOngoingCall();
+
+  public abstract boolean shouldShowLocation();
+  // Used for consistent LetterTile coloring.
+  @Nullable
+  public abstract String contactInfoLookupKey();
+
+  @Nullable
+  public abstract MultimediaData multimediaData();
+
+  public abstract boolean showInCallButtonGrid();
+
+  public abstract int numberPresentation();
+
+  public static Builder builder() {
+    return new AutoValue_PrimaryInfo.Builder();
+  }
+  /** Builder class for primary call info. */
+  @AutoValue.Builder
+  public abstract static class Builder {
+    public abstract Builder setNumber(String number);
+
+    public abstract Builder setName(String name);
+
+    public abstract Builder setNameIsNumber(boolean nameIsNumber);
+
+    public abstract Builder setLabel(String label);
+
+    public abstract Builder setLocation(String location);
+
+    public abstract Builder setPhoto(Drawable photo);
+
+    public abstract Builder setPhotoType(@ContactPhotoType int photoType);
+
+    public abstract Builder setIsSipCall(boolean isSipCall);
+
+    public abstract Builder setIsContactPhotoShown(boolean isContactPhotoShown);
+
+    public abstract Builder setIsWorkCall(boolean isWorkCall);
+
+    public abstract Builder setIsSpam(boolean isSpam);
+
+    public abstract Builder setIsLocalContact(boolean isLocalContact);
+
+    public abstract Builder setAnsweringDisconnectsOngoingCall(
+        boolean answeringDisconnectsOngoingCall);
+
+    public abstract Builder setShouldShowLocation(boolean shouldShowLocation);
+
+    public abstract Builder setContactInfoLookupKey(String contactInfoLookupKey);
+
+    public abstract Builder setMultimediaData(MultimediaData multimediaData);
+
+    public abstract Builder setShowInCallButtonGrid(boolean showInCallButtonGrid);
+
+    public abstract Builder setNumberPresentation(int numberPresentation);
+
+    public abstract PrimaryInfo build();
   }
 
-  public PrimaryInfo(
-      @Nullable String number,
-      @Nullable String name,
-      boolean nameIsNumber,
-      @Nullable String location,
-      @Nullable String label,
-      @Nullable Drawable photo,
-      @ContactPhotoType int phototType,
-      boolean isSipCall,
-      boolean isContactPhotoShown,
-      boolean isWorkCall,
-      boolean isSpam,
-      boolean isLocalContact,
-      boolean answeringDisconnectsOngoingCall,
-      boolean shouldShowLocation,
-      @Nullable String contactInfoLookupKey,
-      @Nullable MultimediaData multimediaData,
-      boolean showInCallButtonGrid,
-      int numberPresentation) {
-    this.number = number;
-    this.name = name;
-    this.nameIsNumber = nameIsNumber;
-    this.location = location;
-    this.label = label;
-    this.photo = photo;
-    this.photoType = phototType;
-    this.isSipCall = isSipCall;
-    this.isContactPhotoShown = isContactPhotoShown;
-    this.isWorkCall = isWorkCall;
-    this.isSpam = isSpam;
-    this.isLocalContact = isLocalContact;
-    this.answeringDisconnectsOngoingCall = answeringDisconnectsOngoingCall;
-    this.shouldShowLocation = shouldShowLocation;
-    this.contactInfoLookupKey = contactInfoLookupKey;
-    this.multimediaData = multimediaData;
-    this.showInCallButtonGrid = showInCallButtonGrid;
-    this.numberPresentation = numberPresentation;
+  public static PrimaryInfo empty() {
+    return PrimaryInfo.builder()
+        .setNameIsNumber(false)
+        .setPhotoType(ContactPhotoType.DEFAULT_PLACEHOLDER)
+        .setIsSipCall(false)
+        .setIsContactPhotoShown(false)
+        .setIsWorkCall(false)
+        .setIsSpam(false)
+        .setIsLocalContact(false)
+        .setAnsweringDisconnectsOngoingCall(false)
+        .setShouldShowLocation(false)
+        .setShowInCallButtonGrid(true)
+        .setNumberPresentation(-1)
+        .build();
   }
 
   @Override
@@ -113,13 +138,13 @@
         Locale.US,
         "PrimaryInfo, number: %s, name: %s, location: %s, label: %s, "
             + "photo: %s, photoType: %d, isPhotoVisible: %b, MultimediaData: %s",
-        LogUtil.sanitizePhoneNumber(number),
-        LogUtil.sanitizePii(name),
-        LogUtil.sanitizePii(location),
-        label,
-        photo,
-        photoType,
-        isContactPhotoShown,
-        multimediaData);
+        LogUtil.sanitizePhoneNumber(number()),
+        LogUtil.sanitizePii(name()),
+        LogUtil.sanitizePii(location()),
+        label(),
+        photo(),
+        photoType(),
+        isContactPhotoShown(),
+        multimediaData());
   }
 }
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
index ba99b2b..a330295 100644
--- a/java/com/android/incallui/rtt/impl/RttChatFragment.java
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -277,7 +277,7 @@
   @Override
   public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
     LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString());
-    nameTextView.setText(primaryInfo.name);
+    nameTextView.setText(primaryInfo.name());
   }
 
   @Override