Use callable-filter capability when updating call log

CallerInfo#phoneNumber has a formatted phone number even when contacts
database itself has an unformatted one, so just using Phone.CONTENT_URI
may not be enough to find the relevant contact.

Bug: 6291905
Change-Id: Ie6e40529eb1f9cf98de861601669dbccb718541c
This commit is contained in:
Daisuke Miyakawa
2012-05-06 16:54:25 -07:00
parent 139e5aa1da
commit e23362a54d

View File

@@ -25,6 +25,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Callable;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.DataUsageFeedback;
import android.text.TextUtils;
@@ -312,10 +313,12 @@ public class CallLog {
null);
} else {
final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number;
cursor = resolver.query(Phone.CONTENT_URI,
cursor = resolver.query(
Uri.withAppendedPath(Callable.CONTENT_FILTER_URI,
Uri.encode(phoneNumber)),
new String[] { Phone._ID },
Phone.CONTACT_ID + " =? AND " + Phone.NUMBER + " =?",
new String[] { String.valueOf(ci.person_id), phoneNumber},
Phone.CONTACT_ID + " =?",
new String[] { String.valueOf(ci.person_id) },
null);
}