From 4ee24a9492c7c83952f59ecc54071c31aa68fa86 Mon Sep 17 00:00:00 2001 From: zachh Date: Thu, 11 Jan 2018 14:05:10 -0800 Subject: Fixed bug in handling of empty numbers in new call log. Empty numbers were not being inserted into PhoneLookupHistory because the URI "content://.../PhoneLookupHistory/" is treated the same as "content://.../PhoneLookupHistory" (w/o the trailing slash). This caused the update (i.e. replace) operation to incorrectly update all rows in the table when it should have updated a single row. The fix for this was to switch to a query parameter, so the empty number URI now looks like "content://.../PhoneLookupHistory?number=" Also improved some logging while debugging this problem. Bug: 71866050 Test: unit and manual PiperOrigin-RevId: 181659081 Change-Id: Idec4fb77e74920cd5485620b0a997db03aa8ff9b --- .../datasources/phonelookup/PhoneLookupDataSource.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java') diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index dca992789..30461a4be 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -21,7 +21,6 @@ import android.content.ContentValues; import android.content.Context; import android.content.OperationApplicationException; import android.database.Cursor; -import android.net.Uri; import android.os.RemoteException; import android.support.annotation.MainThread; import android.support.annotation.WorkerThread; @@ -268,12 +267,16 @@ public final class PhoneLookupDataSource contentValues.put(PhoneLookupHistory.PHONE_LOOKUP_INFO, phoneLookupInfo.toByteArray()); contentValues.put(PhoneLookupHistory.LAST_MODIFIED, currentTimestamp); operations.add( - ContentProviderOperation.newUpdate(numberUri(normalizedNumber)) + ContentProviderOperation.newUpdate( + PhoneLookupHistory.contentUriForNumber(normalizedNumber)) .withValues(contentValues) .build()); } for (String normalizedNumber : phoneLookupHistoryRowsToDelete) { - operations.add(ContentProviderOperation.newDelete(numberUri(normalizedNumber)).build()); + operations.add( + ContentProviderOperation.newDelete( + PhoneLookupHistory.contentUriForNumber(normalizedNumber)) + .build()); } appContext.getContentResolver().applyBatch(PhoneLookupHistoryContract.AUTHORITY, operations); return null; @@ -596,8 +599,4 @@ public final class PhoneLookupDataSource contentValues.put( AnnotatedCallLog.CP2_INFO_INCOMPLETE, phoneLookupInfo.getCp2LocalInfo().getIsIncomplete()); } - - private static Uri numberUri(String number) { - return PhoneLookupHistory.CONTENT_URI.buildUpon().appendEncodedPath(number).build(); - } } -- cgit v1.2.3