summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/phonelookup/PhoneLookupSelector.java')
-rw-r--r--java/com/android/dialer/phonelookup/PhoneLookupSelector.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
index 0fe989332..c933af728 100644
--- a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
+++ b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
@@ -18,6 +18,8 @@ package com.android.dialer.phonelookup;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.android.dialer.phonelookup.PhoneLookupInfo.Cp2Info.Cp2ContactInfo;
+import com.android.dialer.phonelookup.PhoneLookupInfo.PeopleApiInfo;
+import com.android.dialer.phonelookup.PhoneLookupInfo.PeopleApiInfo.InfoType;
/**
* Prioritizes information from a {@link PhoneLookupInfo}.
@@ -107,6 +109,27 @@ public final class PhoneLookupSelector {
}
/**
+ * Returns true if the number associated with the given {@link PhoneLookupInfo} can be reported as
+ * invalid.
+ *
+ * <p>As we currently report invalid numbers via the People API, only numbers from the People API
+ * can be reported as invalid.
+ */
+ public static boolean canReportAsInvalidNumber(PhoneLookupInfo phoneLookupInfo) {
+ // The presence of Cp2ContactInfo means the number associated with the given PhoneLookupInfo
+ // matches that of a Cp2 (local) contact, and PeopleApiInfo will not be used to display
+ // information like name, photo, etc. We should not allow the user to report the number in this
+ // case as the info displayed is not from the People API.
+ if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) {
+ return false;
+ }
+
+ PeopleApiInfo peopleApiInfo = phoneLookupInfo.getPeopleApiInfo();
+ return peopleApiInfo.getInfoType() != InfoType.UNKNOWN
+ && !peopleApiInfo.getPersonId().isEmpty();
+ }
+
+ /**
* Arbitrarily select the first contact. In the future, it may make sense to display contact
* information from all contacts with the same number (for example show the name as "Mom, Dad" or
* show a synthesized photo containing photos of both "Mom" and "Dad").