diff options
author | linyuh <linyuh@google.com> | 2018-01-04 13:40:44 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-04 15:00:35 -0800 |
commit | 18e23785eb89a9adfaeb09b636b793921ecdabdd (patch) | |
tree | 6c9dc77f9a83c548d43b0c74a4550a86076b8ba6 /java/com/android/dialer/phonelookup/PhoneLookupSelector.java | |
parent | b2df8b308af8a5ccb1222f60f1ef57803153a084 (diff) |
Add column CAN_REPORT_AS_INVALID_NUMBER to the annotated call log.
This column is filled by PhoneLookupDataSource using PhoneLookupInfo#PeopleApiInfo.
Bug: 70218437
Test: AnnotatedCallLogDatabaseHelperTest, PhoneLookupDataSourceTest, RowCombinerTest, CoalescedAnnotatedCallLogCursorLoaderTest, PhoneLookupSelectorTest
PiperOrigin-RevId: 180839783
Change-Id: I8d5ddb940670724fd4bf6dd6a50dcf408f91da9d
Diffstat (limited to 'java/com/android/dialer/phonelookup/PhoneLookupSelector.java')
-rw-r--r-- | java/com/android/dialer/phonelookup/PhoneLookupSelector.java | 23 |
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"). |