From 999b5d5a7152c3b7608fe30630b983512e9e4e43 Mon Sep 17 00:00:00 2001 From: linyuh Date: Wed, 28 Feb 2018 16:47:17 -0800 Subject: Log contact source when reporting spam from the new UI. Bug: 73780748 Test: PhoneLookupInfoConsolidatorTest PiperOrigin-RevId: 187404074 Change-Id: I1db81304909fbf63aba00088c12e18922042c3b1 --- .../ShowBlockReportSpamDialogReceiver.java | 5 ++-- .../block_report_spam_dialog_info.proto | 6 +++- .../database/contract/number_attributes.proto | 7 ++++- .../android/dialer/calllog/ui/menu/Modules.java | 1 + .../calllogutils/NumberAttributesConverter.java | 3 +- .../consolidator/PhoneLookupInfoConsolidator.java | 34 ++++++++++++++++++++++ .../dialer/voicemail/listui/menu/Modules.java | 1 + 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java index 364736efd..f24bb1c06 100644 --- a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java +++ b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java @@ -26,7 +26,6 @@ import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnConfirmListen import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnSpamDialogClickListener; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.protos.ProtoParsers; @@ -109,7 +108,7 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { dialogInfo.getCountryIso(), dialogInfo.getCallType(), dialogInfo.getReportingLocation(), - ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + dialogInfo.getContactSource()); } // TODO(a bug): Block the number. @@ -154,7 +153,7 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { dialogInfo.getCountryIso(), dialogInfo.getCallType(), dialogInfo.getReportingLocation(), - ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + dialogInfo.getContactSource()); } }; diff --git a/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto b/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto index 3c5a61652..70872c7e0 100644 --- a/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto +++ b/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto @@ -7,11 +7,12 @@ option optimize_for = LITE_RUNTIME; package com.android.dialer.blockreportspam; +import "java/com/android/dialer/logging/contact_source.proto"; import "java/com/android/dialer/logging/reporting_location.proto"; // Contains information needed in dialogs that allow a user to block a number // and/or report it as spam/not spam. -// Next ID: 5 +// Next ID: 6 message BlockReportSpamDialogInfo { // A dialer-normalized version of the number used in the dialogs. // See DialerPhoneNumber#normalized_number. @@ -27,4 +28,7 @@ message BlockReportSpamDialogInfo { // The location where the number is reported. optional com.android.dialer.logging.ReportingLocation.Type reporting_location = 4; + + // The source where contact info is associated with the number. + optional com.android.dialer.logging.ContactSource.Type contact_source = 5; } \ No newline at end of file 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 594e6764c..e24f393f7 100644 --- a/java/com/android/dialer/calllog/database/contract/number_attributes.proto +++ b/java/com/android/dialer/calllog/database/contract/number_attributes.proto @@ -21,8 +21,10 @@ option optimize_for = LITE_RUNTIME; package com.android.dialer; +import "java/com/android/dialer/logging/contact_source.proto"; + // Information related to the phone number of the call. -// Next ID: 12 +// Next ID: 13 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 @@ -65,4 +67,7 @@ message NumberAttributes { // Whether the number is spam. optional bool is_spam = 11; + + // Source of the contact associated with the number. + optional com.android.dialer.logging.ContactSource.Type contact_source = 12; } \ No newline at end of file diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index 9df122331..184f7abf0 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -90,6 +90,7 @@ final class Modules { .setCountryIso(row.number().getCountryIso()) .setCallType(row.callType()) .setReportingLocation(ReportingLocation.Type.CALL_LOG_HISTORY) + .setContactSource(row.numberAttributes().getContactSource()) .build(); modules.addAll( SharedModules.createModulesHandlingBlockedOrSpamNumber( diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java index ceb8d57ce..a9376bb98 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 { .setIsBlocked(phoneLookupInfoConsolidator.isBlocked()) .setIsSpam(phoneLookupInfoConsolidator.isSpam()) .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) - .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete()); + .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete()) + .setContactSource(phoneLookupInfoConsolidator.getContactSource()); } } diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java index 3a48fd538..6e867560d 100644 --- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java +++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java @@ -18,6 +18,7 @@ package com.android.dialer.phonelookup.consolidator; import android.support.annotation.IntDef; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; +import com.android.dialer.logging.ContactSource; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; import com.android.dialer.phonelookup.PhoneLookupInfo.BlockedState; @@ -90,6 +91,39 @@ public final class PhoneLookupInfoConsolidator { this.nameSource = selectNameSource(); } + /** + * Returns a {@link com.android.dialer.logging.ContactSource.Type} representing the source from + * which info is used to display contact info in the UI. + */ + public ContactSource.Type getContactSource() { + switch (nameSource) { + case NameSource.CP2_DEFAULT_DIRECTORY: + return ContactSource.Type.SOURCE_TYPE_DIRECTORY; + case NameSource.CP2_EXTENDED_DIRECTORY: + return ContactSource.Type.SOURCE_TYPE_EXTENDED; + case NameSource.PEOPLE_API: + return getRefinedPeopleApiSource(); + case NameSource.NONE: + return ContactSource.Type.UNKNOWN_SOURCE_TYPE; + default: + throw Assert.createUnsupportedOperationFailException( + String.format("Unsupported name source: %s", nameSource)); + } + } + + private ContactSource.Type getRefinedPeopleApiSource() { + Assert.checkState(nameSource == NameSource.PEOPLE_API); + + switch (phoneLookupInfo.getPeopleApiInfo().getInfoType()) { + case CONTACT: + return ContactSource.Type.SOURCE_TYPE_PROFILE; + case NEARBY_BUSINESS: + return ContactSource.Type.SOURCE_TYPE_PLACES; + default: + return ContactSource.Type.SOURCE_TYPE_REMOTE_OTHER; + } + } + /** * The {@link PhoneLookupInfo} passed to the constructor is associated with a number. This method * returns the name associated with that number. diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java index cc7bcbe6d..c3c883ceb 100644 --- a/java/com/android/dialer/voicemail/listui/menu/Modules.java +++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java @@ -71,6 +71,7 @@ final class Modules { .setCountryIso(voicemailEntry.number().getCountryIso()) .setCallType(voicemailEntry.callType()) .setReportingLocation(ReportingLocation.Type.VOICEMAIL_HISTORY) + .setContactSource(voicemailEntry.numberAttributes().getContactSource()) .build(); modules.addAll( SharedModules.createModulesHandlingBlockedOrSpamNumber( -- cgit v1.2.3