summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-04-26 20:35:31 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-26 20:39:41 -0700
commite7d83218d752f677c859a6c88181d24dc36a8c83 (patch)
tree78f3eaa9f7fcd5ff7cdd5cead74b651d3636e618 /java
parentfa3cd3bfb14f4b8ac65c0ee6757bc78b40a73573 (diff)
Show Cequint info in the new call log.
Bug: 70989584 Test: PhoneLookupInfoConsolidatorTest PiperOrigin-RevId: 194494486 Change-Id: I706802c000da953f962786bd07ca5da2fd59dc8a
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/calllog/database/contract/number_attributes.proto6
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryText.java7
-rw-r--r--java/com/android/dialer/calllogutils/NumberAttributesConverter.java3
-rw-r--r--java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java45
4 files changed, 57 insertions, 4 deletions
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 f99693d4e..f42974d36 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 @@ package com.android.dialer;
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 @@ message NumberAttributes {
// 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 e346de011..a1a2a3b48 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryText.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java
@@ -214,7 +214,12 @@ public final class CallLogEntryText {
// (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 f4fab8405..9f07fdac5 100644
--- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
+++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
@@ -56,6 +56,7 @@ public final class NumberAttributesConverter {
.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 07aea749d..23ecc8301 100644
--- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
+++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
@@ -46,6 +46,7 @@ public final class PhoneLookupInfoConsolidator {
NameSource.CP2_DEFAULT_DIRECTORY,
NameSource.CP2_EXTENDED_DIRECTORY,
NameSource.PEOPLE_API,
+ NameSource.CEQUINT,
NameSource.CNAP
})
@interface NameSource {
@@ -53,7 +54,8 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
NameSource.CP2_DEFAULT_DIRECTORY,
NameSource.CP2_EXTENDED_DIRECTORY,
NameSource.PEOPLE_API,
+ NameSource.CEQUINT,
NameSource.CNAP);
private final @NameSource int nameSource;
@@ -106,6 +109,8 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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 @@ public final class PhoneLookupInfoConsolidator {
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;