Show Cequint info in the new call log.

Bug: 70989584
Test: PhoneLookupInfoConsolidatorTest
PiperOrigin-RevId: 194494486
Change-Id: I706802c000da953f962786bd07ca5da2fd59dc8a
diff --git a/java/com/android/dialer/calllog/database/contract/number_attributes.proto b/java/com/android/dialer/calllog/database/contract/number_attributes.proto
index f99693d..f42974d 100644
--- a/java/com/android/dialer/calllog/database/contract/number_attributes.proto
+++ b/java/com/android/dialer/calllog/database/contract/number_attributes.proto
@@ -24,7 +24,7 @@
 import "java/com/android/dialer/logging/contact_source.proto";
 
 // Information related to the phone number of the call.
-// Next ID: 13
+// Next ID: 14
 message NumberAttributes {
   // The name (which may be a person's name or business name, but not a number)
   // formatted exactly as it should appear to the user. If the user's locale or
@@ -70,4 +70,8 @@
 
   // Whether the number can be reached via a carrier video call.
   optional bool can_support_carrier_video_call = 12;
+
+  // Description of the number's geolocation (e.g., "Mountain View, CA").
+  // This string is for display purpose only.
+  optional string geolocation = 13;
 }
\ No newline at end of file
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java
index e346de0..a1a2a3b 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryText.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java
@@ -214,7 +214,12 @@
     // (1) there is no number type label, and
     // (2) the number is not spam.
     if (TextUtils.isEmpty(numberTypeLabel) && !row.getNumberAttributes().getIsSpam()) {
-      String location = row.getGeocodedLocation();
+      // If number attributes contain a location (obtained from a PhoneLookup), use it instead
+      // of the one from the annotated call log.
+      String location =
+          !TextUtils.isEmpty(row.getNumberAttributes().getGeolocation())
+              ? row.getNumberAttributes().getGeolocation()
+              : row.getGeocodedLocation();
       if (!TextUtils.isEmpty(location)) {
         if (secondaryText.length() > 0) {
           secondaryText.append(", ");
diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
index f4fab84..9f07fda 100644
--- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
+++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
@@ -56,6 +56,7 @@
         .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber())
         .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete())
         .setContactSource(phoneLookupInfoConsolidator.getContactSource())
-        .setCanSupportCarrierVideoCall(phoneLookupInfoConsolidator.canSupportCarrierVideoCall());
+        .setCanSupportCarrierVideoCall(phoneLookupInfoConsolidator.canSupportCarrierVideoCall())
+        .setGeolocation(phoneLookupInfoConsolidator.getGeolocation());
   }
 }
diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
index 07aea74..23ecc83 100644
--- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
+++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
@@ -46,6 +46,7 @@
     NameSource.CP2_DEFAULT_DIRECTORY,
     NameSource.CP2_EXTENDED_DIRECTORY,
     NameSource.PEOPLE_API,
+    NameSource.CEQUINT,
     NameSource.CNAP
   })
   @interface NameSource {
@@ -53,7 +54,8 @@
     int CP2_DEFAULT_DIRECTORY = 1;
     int CP2_EXTENDED_DIRECTORY = 2;
     int PEOPLE_API = 3;
-    int CNAP = 4;
+    int CEQUINT = 4;
+    int CNAP = 5;
   }
 
   /**
@@ -78,6 +80,7 @@
           NameSource.CP2_DEFAULT_DIRECTORY,
           NameSource.CP2_EXTENDED_DIRECTORY,
           NameSource.PEOPLE_API,
+          NameSource.CEQUINT,
           NameSource.CNAP);
 
   private final @NameSource int nameSource;
@@ -106,6 +109,8 @@
         return ContactSource.Type.SOURCE_TYPE_EXTENDED;
       case NameSource.PEOPLE_API:
         return getRefinedPeopleApiSource();
+      case NameSource.CEQUINT:
+        return ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID;
       case NameSource.CNAP:
         return ContactSource.Type.SOURCE_TYPE_CNAP;
       case NameSource.NONE:
@@ -146,6 +151,8 @@
         return Assert.isNotNull(firstExtendedCp2Contact).getName();
       case NameSource.PEOPLE_API:
         return phoneLookupInfo.getPeopleApiInfo().getDisplayName();
+      case NameSource.CEQUINT:
+        return phoneLookupInfo.getCequintInfo().getName();
       case NameSource.CNAP:
         return phoneLookupInfo.getCnapInfo().getName();
       case NameSource.NONE:
@@ -170,6 +177,7 @@
       case NameSource.CP2_EXTENDED_DIRECTORY:
         return Assert.isNotNull(firstExtendedCp2Contact).getPhotoThumbnailUri();
       case NameSource.PEOPLE_API:
+      case NameSource.CEQUINT:
       case NameSource.CNAP:
       case NameSource.NONE:
         return "";
@@ -192,6 +200,8 @@
         return Assert.isNotNull(firstDefaultCp2Contact).getPhotoUri();
       case NameSource.CP2_EXTENDED_DIRECTORY:
         return Assert.isNotNull(firstExtendedCp2Contact).getPhotoUri();
+      case NameSource.CEQUINT:
+        return phoneLookupInfo.getCequintInfo().getPhotoUri();
       case NameSource.PEOPLE_API:
       case NameSource.CNAP:
       case NameSource.NONE:
@@ -213,6 +223,7 @@
       case NameSource.CP2_EXTENDED_DIRECTORY:
         return Math.max(Assert.isNotNull(firstExtendedCp2Contact).getPhotoId(), 0);
       case NameSource.PEOPLE_API:
+      case NameSource.CEQUINT:
       case NameSource.CNAP:
       case NameSource.NONE:
         return 0;
@@ -235,6 +246,7 @@
         return Assert.isNotNull(firstExtendedCp2Contact).getLookupUri();
       case NameSource.PEOPLE_API:
         return Assert.isNotNull(phoneLookupInfo.getPeopleApiInfo().getLookupUri());
+      case NameSource.CEQUINT:
       case NameSource.CNAP:
       case NameSource.NONE:
         return "";
@@ -259,6 +271,30 @@
       case NameSource.CP2_EXTENDED_DIRECTORY:
         return Assert.isNotNull(firstExtendedCp2Contact).getLabel();
       case NameSource.PEOPLE_API:
+      case NameSource.CEQUINT:
+      case NameSource.CNAP:
+      case NameSource.NONE:
+        return "";
+      default:
+        throw Assert.createUnsupportedOperationFailException(
+            String.format("Unsupported name source: %s", nameSource));
+    }
+  }
+
+  /**
+   * The {@link PhoneLookupInfo} passed to the constructor is associated with a number. This method
+   * returns the number's geolocation (which is for display purpose only).
+   *
+   * <p>If no geolocation can be obtained from the {@link PhoneLookupInfo}, an empty string will be
+   * returned.
+   */
+  public String getGeolocation() {
+    switch (nameSource) {
+      case NameSource.CEQUINT:
+        return phoneLookupInfo.getCequintInfo().getGeolocation();
+      case NameSource.CP2_DEFAULT_DIRECTORY:
+      case NameSource.CP2_EXTENDED_DIRECTORY:
+      case NameSource.PEOPLE_API:
       case NameSource.CNAP:
       case NameSource.NONE:
         return "";
@@ -320,6 +356,7 @@
     switch (nameSource) {
       case NameSource.CP2_DEFAULT_DIRECTORY:
       case NameSource.CP2_EXTENDED_DIRECTORY:
+      case NameSource.CEQUINT:
       case NameSource.CNAP:
       case NameSource.NONE:
         return false;
@@ -343,6 +380,7 @@
         return Assert.isNotNull(firstDefaultCp2Contact).getCanSupportCarrierVideoCall();
       case NameSource.CP2_EXTENDED_DIRECTORY:
       case NameSource.PEOPLE_API:
+      case NameSource.CEQUINT:
       case NameSource.CNAP:
       case NameSource.NONE:
         return false;
@@ -396,6 +434,11 @@
             return NameSource.PEOPLE_API;
           }
           break;
+        case NameSource.CEQUINT:
+          if (!phoneLookupInfo.getCequintInfo().getName().isEmpty()) {
+            return NameSource.CEQUINT;
+          }
+          break;
         case NameSource.CNAP:
           if (!phoneLookupInfo.getCnapInfo().getName().isEmpty()) {
             return NameSource.CNAP;