summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/phonelookup
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-05-14 18:33:31 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-15 11:17:34 -0700
commit7e7fb6f4f2b8a17d8d8a9b8805600f150d6cb899 (patch)
treecef88faec89abccdcf1321079ff33b89964b6b46 /java/com/android/dialer/phonelookup
parentd1a269ba4e9649cb1a0941433a3684d9e39a2fe6 (diff)
Implement PhoneNumberCacheLookup
PhoneNumberCacheLookup migrates lookup result from the old call log. TEST=TAP Bug: 72119926 Test: TAP PiperOrigin-RevId: 196601622 Change-Id: I7df0ece770532c410747ceb310abb307fce80465
Diffstat (limited to 'java/com/android/dialer/phonelookup')
-rw-r--r--java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java49
-rw-r--r--java/com/android/dialer/phonelookup/phone_lookup_info.proto17
2 files changed, 61 insertions, 5 deletions
diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
index 29a0de56b..efd7ae6f1 100644
--- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
+++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
@@ -47,7 +47,8 @@ public final class PhoneLookupInfoConsolidator {
NameSource.CP2_EXTENDED_DIRECTORY,
NameSource.PEOPLE_API,
NameSource.CEQUINT,
- NameSource.CNAP
+ NameSource.CNAP,
+ NameSource.PHONE_NUMBER_CACHE
})
@interface NameSource {
int NONE = 0; // used when none of the other sources can provide the name
@@ -56,6 +57,7 @@ public final class PhoneLookupInfoConsolidator {
int PEOPLE_API = 3;
int CEQUINT = 4;
int CNAP = 5;
+ int PHONE_NUMBER_CACHE = 6;
}
/**
@@ -81,7 +83,8 @@ public final class PhoneLookupInfoConsolidator {
NameSource.CP2_EXTENDED_DIRECTORY,
NameSource.PEOPLE_API,
NameSource.CEQUINT,
- NameSource.CNAP);
+ NameSource.CNAP,
+ NameSource.PHONE_NUMBER_CACHE);
private final @NameSource int nameSource;
private final PhoneLookupInfo phoneLookupInfo;
@@ -113,6 +116,13 @@ public final class PhoneLookupInfoConsolidator {
return ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID;
case NameSource.CNAP:
return ContactSource.Type.SOURCE_TYPE_CNAP;
+ case NameSource.PHONE_NUMBER_CACHE:
+ ContactSource.Type sourceType =
+ ContactSource.Type.forNumber(phoneLookupInfo.getMigratedInfo().getSourceType());
+ if (sourceType == null) {
+ sourceType = ContactSource.Type.UNKNOWN_SOURCE_TYPE;
+ }
+ return sourceType;
case NameSource.NONE:
return ContactSource.Type.UNKNOWN_SOURCE_TYPE;
default:
@@ -155,6 +165,8 @@ public final class PhoneLookupInfoConsolidator {
return phoneLookupInfo.getCequintInfo().getName();
case NameSource.CNAP:
return phoneLookupInfo.getCnapInfo().getName();
+ case NameSource.PHONE_NUMBER_CACHE:
+ return phoneLookupInfo.getMigratedInfo().getName();
case NameSource.NONE:
return "";
default:
@@ -176,6 +188,8 @@ public final class PhoneLookupInfoConsolidator {
return Assert.isNotNull(firstDefaultCp2Contact).getPhotoThumbnailUri();
case NameSource.CP2_EXTENDED_DIRECTORY:
return Assert.isNotNull(firstExtendedCp2Contact).getPhotoThumbnailUri();
+ case NameSource.PHONE_NUMBER_CACHE:
+ return phoneLookupInfo.getMigratedInfo().getPhotoUri();
case NameSource.PEOPLE_API:
case NameSource.CEQUINT:
case NameSource.CNAP:
@@ -202,6 +216,8 @@ public final class PhoneLookupInfoConsolidator {
return Assert.isNotNull(firstExtendedCp2Contact).getPhotoUri();
case NameSource.CEQUINT:
return phoneLookupInfo.getCequintInfo().getPhotoUri();
+ case NameSource.PHONE_NUMBER_CACHE:
+ return phoneLookupInfo.getMigratedInfo().getPhotoUri();
case NameSource.PEOPLE_API:
case NameSource.CNAP:
case NameSource.NONE:
@@ -222,6 +238,7 @@ public final class PhoneLookupInfoConsolidator {
return Math.max(Assert.isNotNull(firstDefaultCp2Contact).getPhotoId(), 0);
case NameSource.CP2_EXTENDED_DIRECTORY:
return Math.max(Assert.isNotNull(firstExtendedCp2Contact).getPhotoId(), 0);
+ case NameSource.PHONE_NUMBER_CACHE:
case NameSource.PEOPLE_API:
case NameSource.CEQUINT:
case NameSource.CNAP:
@@ -246,6 +263,7 @@ public final class PhoneLookupInfoConsolidator {
return Assert.isNotNull(firstExtendedCp2Contact).getLookupUri();
case NameSource.PEOPLE_API:
return Assert.isNotNull(phoneLookupInfo.getPeopleApiInfo().getLookupUri());
+ case NameSource.PHONE_NUMBER_CACHE:
case NameSource.CEQUINT:
case NameSource.CNAP:
case NameSource.NONE:
@@ -270,6 +288,8 @@ public final class PhoneLookupInfoConsolidator {
return Assert.isNotNull(firstDefaultCp2Contact).getLabel();
case NameSource.CP2_EXTENDED_DIRECTORY:
return Assert.isNotNull(firstExtendedCp2Contact).getLabel();
+ case NameSource.PHONE_NUMBER_CACHE:
+ return phoneLookupInfo.getMigratedInfo().getLabel();
case NameSource.PEOPLE_API:
case NameSource.CEQUINT:
case NameSource.CNAP:
@@ -296,6 +316,7 @@ public final class PhoneLookupInfoConsolidator {
case NameSource.CP2_EXTENDED_DIRECTORY:
case NameSource.PEOPLE_API:
case NameSource.CNAP:
+ case NameSource.PHONE_NUMBER_CACHE:
case NameSource.NONE:
return "";
default:
@@ -309,8 +330,21 @@ public final class PhoneLookupInfoConsolidator {
* returns whether the number belongs to a business place.
*/
public boolean isBusiness() {
- return phoneLookupInfo.hasPeopleApiInfo()
- && phoneLookupInfo.getPeopleApiInfo().getInfoType() == InfoType.NEARBY_BUSINESS;
+ switch (nameSource) {
+ case NameSource.PEOPLE_API:
+ return phoneLookupInfo.getPeopleApiInfo().getInfoType() == InfoType.NEARBY_BUSINESS;
+ case NameSource.PHONE_NUMBER_CACHE:
+ return phoneLookupInfo.getMigratedInfo().getIsBusiness();
+ case NameSource.CP2_DEFAULT_DIRECTORY:
+ case NameSource.CP2_EXTENDED_DIRECTORY:
+ case NameSource.CEQUINT:
+ case NameSource.CNAP:
+ case NameSource.NONE:
+ return false;
+ default:
+ throw Assert.createUnsupportedOperationFailException(
+ String.format("Unsupported name source: %s", nameSource));
+ }
}
/**
@@ -366,6 +400,7 @@ public final class PhoneLookupInfoConsolidator {
case NameSource.CP2_EXTENDED_DIRECTORY:
case NameSource.CEQUINT:
case NameSource.CNAP:
+ case NameSource.PHONE_NUMBER_CACHE:
case NameSource.NONE:
return false;
case NameSource.PEOPLE_API:
@@ -390,6 +425,7 @@ public final class PhoneLookupInfoConsolidator {
case NameSource.PEOPLE_API:
case NameSource.CEQUINT:
case NameSource.CNAP:
+ case NameSource.PHONE_NUMBER_CACHE:
case NameSource.NONE:
return false;
default:
@@ -452,6 +488,11 @@ public final class PhoneLookupInfoConsolidator {
return NameSource.CNAP;
}
break;
+ case NameSource.PHONE_NUMBER_CACHE:
+ if (!phoneLookupInfo.getMigratedInfo().getName().isEmpty()) {
+ return NameSource.PHONE_NUMBER_CACHE;
+ }
+ break;
default:
throw Assert.createUnsupportedOperationFailException(
String.format("Unsupported name source: %s", nameSource));
diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
index 9e9dfa918..f5ab5f0a9 100644
--- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto
+++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
@@ -14,7 +14,7 @@ package com.android.dialer.phonelookup;
// "cp2_info_in_default_directory" corresponds to class
// Cp2DefaultDirectoryPhoneLookup, and class Cp2DefaultDirectoryPhoneLookup
// alone is responsible for populating it.
-// Next ID: 10
+// Next ID: 11
message PhoneLookupInfo {
// Information about a PhoneNumber retrieved from CP2.
message Cp2Info {
@@ -182,4 +182,19 @@ message PhoneLookupInfo {
optional bool is_emergency_number = 1;
}
optional EmergencyInfo emergency_info = 9;
+
+ // Information cached in the old calllog
+ message MigratedInfo {
+ // The display name
+ optional string name = 1;
+ // Display label, i.e. "Home", "Mobile"
+ optional string label = 2;
+
+ optional string photo_uri = 3;
+
+ optional bool is_business = 4;
+ // ContactSource.Type
+ optional int32 source_type = 5;
+ }
+ optional MigratedInfo migrated_info = 10;
} \ No newline at end of file