From 55733814f213809baaa8eaa8984ff026bdb08b4e Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Tue, 30 Sep 2014 15:55:31 -0700 Subject: Fix HTTP request to a report bad caller ID entry in the call log (1/2) A few things needed to change to fix this bug. 1. Add object ID to ContactInfo and make sure that it is persisted 2. Adding a new row means migration from older versions of DBs 3. Fix logic that determines if we can report a given call log entry since the strategy of using isExternal() is not valid. UI impact. 4. Fix the HTTP request that is generated to include a valid object ID intead of using the source ID. Bug: 17692726 Change-Id: If541fea963837118b7466b6c59f453103cdbdc4a --- src/com/android/dialer/calllog/CallLogAdapter.java | 8 ++++++-- src/com/android/dialer/calllog/CallLogListItemViews.java | 5 +++-- src/com/android/dialer/calllog/ContactInfo.java | 4 +++- src/com/android/dialer/calllog/ContactInfoHelper.java | 15 +++++++++------ .../android/dialer/service/CachedNumberLookupService.java | 3 +-- 5 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index b585b89c1..dcd2de3c0 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -758,7 +758,11 @@ public class CallLogAdapter extends GroupingListAdapter final PhoneCallDetails details; views.reported = info.isBadData; - views.isExternal = mContactInfoHelper.isExternal(info.sourceType); + + // The entry can only be reported as invalid if it has a valid ID and the source of the + // entry supports marking entries as invalid. + views.canBeReportedAsInvalid = mContactInfoHelper.canReportAsInvalid(info.sourceType, + info.objectId); // Restore expansion state of the row on rebind. Inflate the actions ViewStub if required, // and set its visibility state accordingly. @@ -1023,7 +1027,7 @@ public class CallLogAdapter extends GroupingListAdapter views.rowId, views.callIds, null) ); - if (views.isExternal && !views.reported) { + if (views.canBeReportedAsInvalid && !views.reported) { views.reportButtonView.setVisibility(View.VISIBLE); } else { views.reportButtonView.setVisibility(View.GONE); diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index dde4c91be..0ccdf00a1 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -108,9 +108,10 @@ public final class CallLogListItemViews { public boolean reported; /** - * Whether or not the contact info came from a source other than the android contacts provider. + * Whether or not the contact info can be marked as invalid from the source where + * it was obtained. */ - public boolean isExternal; + public boolean canBeReportedAsInvalid; private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, PhoneCallDetailsViews phoneCallDetailsViews, View callLogEntryView, diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index cf29c5c83..7b6014dd1 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -39,6 +39,7 @@ public class ContactInfo { /** The high-res photo for the contact, if available. */ public Uri photoUri; public boolean isBadData; + public String objectId; public static ContactInfo EMPTY = new ContactInfo(); @@ -73,6 +74,7 @@ public class ContactInfo { if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; if (photoId != other.photoId) return false; if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; + if (!TextUtils.equals(objectId, other.objectId)) return false; return true; } @@ -81,6 +83,6 @@ public class ContactInfo { return Objects.toStringHelper(this).add("lookupUri", lookupUri).add("name", name).add( "type", type).add("label", label).add("number", number).add("formattedNumber", formattedNumber).add("normalizedNumber", normalizedNumber).add("photoId", photoId) - .add("photoUri", photoUri).toString(); + .add("photoUri", photoUri).add("objectId", objectId).toString(); } } diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 1f99a8820..01749fc22 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -294,14 +294,17 @@ public class ContactInfoHelper { } /** - * Given a contact's sourceType, return true if the contact came from an - * external source. + * This function looks at a contact's source and determines if the user can + * mark caller ids from this source as invalid. * - * @param sourceType sourceType of the contact. This is usually populated by - * {@link #mCachedNumberLookupService}. + * @param sourceType The source type to be checked + * @param objectId The ID of the Contact object. + * @return true if contacts from this source can be marked with an invalid caller id */ - public boolean isExternal(int sourceType) { + public boolean canReportAsInvalid(int sourceType, String objectId) { return mCachedNumberLookupService != null - && mCachedNumberLookupService.isExternal(sourceType); + && mCachedNumberLookupService.canReportAsInvalid(sourceType, objectId); } + + } diff --git a/src/com/android/dialer/service/CachedNumberLookupService.java b/src/com/android/dialer/service/CachedNumberLookupService.java index 2fec45cd6..a3782f162 100644 --- a/src/com/android/dialer/service/CachedNumberLookupService.java +++ b/src/com/android/dialer/service/CachedNumberLookupService.java @@ -34,8 +34,7 @@ public interface CachedNumberLookupService { public boolean isCacheUri(String uri); public boolean isBusiness(int sourceType); - - public boolean isExternal(int sourceType); + public boolean canReportAsInvalid(int sourceType, String objectId); public boolean addPhoto(Context context, String number, byte[] photo); -- cgit v1.2.3