diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-06-25 12:31:13 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-06-28 11:12:33 -0700 |
commit | f468591cafb797a494d09bb0dd6adfcc439e7b8c (patch) | |
tree | b4fcb152eb09731ce211ea8cc78f7218e68c47ea /core/java/android/provider/CallLog.java | |
parent | 84e297238f53f83c9e7de499e711b997d09514e0 (diff) | |
download | frameworks_base-f468591cafb797a494d09bb0dd6adfcc439e7b8c.zip frameworks_base-f468591cafb797a494d09bb0dd6adfcc439e7b8c.tar.gz frameworks_base-f468591cafb797a494d09bb0dd6adfcc439e7b8c.tar.bz2 |
Use new usage feedback API in phone app / strequent
Basiaclly two changes included:
- Let CallLog use new data usage feedback API, so that
ContactsProvider2 is able to figure out what type of contact
method is used when a person is contacted.
- introduce phone_only parameter for strequent uri, which enables
Contacts app to obtain a contact list for recently phone-called
contacts.
markAsContacted() isn't used anymore, as nhe new API takes care of
old counters (TIMES_CONTACTED/LAST_TIME_CONTACTED) too.
Bug: 4371572
Change-Id: Ie193bb91ee49b18f4a546a1f52be780bb514301d
Diffstat (limited to 'core/java/android/provider/CallLog.java')
-rw-r--r-- | core/java/android/provider/CallLog.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 02faf49..0933193 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -24,6 +24,8 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.DataUsageFeedback; import android.text.TextUtils; /** @@ -204,7 +206,44 @@ public class CallLog { } if ((ci != null) && (ci.person_id > 0)) { - ContactsContract.Contacts.markAsContacted(resolver, ci.person_id); + // Update usage information for the number associated with the contact ID. + // We need to use both the number and the ID for obtaining a data ID since other + // contacts may have the same number. + + final Cursor cursor; + + // We should prefer normalized one (probably coming from + // Phone.NORMALIZED_NUMBER column) first. If it isn't available try others. + if (ci.normalizedNumber != null) { + final String normalizedPhoneNumber = ci.normalizedNumber; + cursor = resolver.query(Phone.CONTENT_URI, + new String[] { Phone._ID }, + Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?", + new String[] { String.valueOf(ci.person_id), normalizedPhoneNumber}, + null); + } else { + final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number; + cursor = resolver.query(Phone.CONTENT_URI, + new String[] { Phone._ID }, + Phone.CONTACT_ID + " =? AND " + Phone.NUMBER + " =?", + new String[] { String.valueOf(ci.person_id), phoneNumber}, + null); + } + + if (cursor != null) { + try { + if (cursor.getCount() > 0 && cursor.moveToFirst()) { + final Uri feedbackUri = DataUsageFeedback.FEEDBACK_URI.buildUpon() + .appendPath(cursor.getString(0)) + .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, + DataUsageFeedback.USAGE_TYPE_CALL) + .build(); + resolver.update(feedbackUri, new ContentValues(), null, null); + } + } finally { + cursor.close(); + } + } } Uri result = resolver.insert(CONTENT_URI, values); |