diff options
| author | 2010-10-07 08:34:01 -0700 | |
|---|---|---|
| committer | 2010-10-07 08:34:01 -0700 | |
| commit | bbc80d3436ee52f28bd26f1f0cb01dc4dd183ccc (patch) | |
| tree | 686e67cff4e950fac231063d545c95ee0b456f91 | |
| parent | 29332971ddbace4ae3d645a67f28f717df8b1dbd (diff) | |
| parent | 2e27a0be78bd9510785789caa14baa029051ca20 (diff) | |
Merge "Changed handling of onQueryCompelete to not use mimeType." into gingerbread
| -rw-r--r-- | telephony/java/com/android/internal/telephony/CallerInfo.java | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java index cf89848d54c0..360d35e358b4 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfo.java +++ b/telephony/java/com/android/internal/telephony/CallerInfo.java @@ -26,9 +26,9 @@ import static android.provider.ContactsContract.RawContacts; import android.text.TextUtils; import android.telephony.TelephonyManager; import android.telephony.PhoneNumberUtils; -import android.util.Config; import android.util.Log; + /** * Looks up caller information for the given phone number. * @@ -36,6 +36,7 @@ import android.util.Log; */ public class CallerInfo { private static final String TAG = "CallerInfo"; + private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE); public static final String UNKNOWN_NUMBER = "-1"; public static final String PRIVATE_NUMBER = "-2"; @@ -128,7 +129,7 @@ public class CallerInfo { info.isCachedPhotoCurrent = false; info.contactExists = false; - if (Config.LOGV) Log.v(TAG, "construct callerInfo from cursor"); + if (VDBG) Log.v(TAG, "construct callerInfo from cursor"); if (cursor != null) { if (cursor.moveToFirst()) { @@ -166,31 +167,30 @@ public class CallerInfo { // Look for the person ID. // TODO: This is pretty ugly now, see bug 2269240 for - // more details. With tel: URI the contact id is in - // col "_id" while when we use a - // content://contacts/data/phones URI, the contact id - // is col "contact_id". As a work around we use the - // type of the contact url to figure out which column - // we should look at to get the contact_id. - - final String mimeType = context.getContentResolver().getType(contactRef); + // more details. The column to use depends upon the type of URL, + // for content://com.android.contacts/data/phones the "contact_id" + // column is used. For content/com.andriod.contacts/phone_lookup" + // the "_ID" column is used. If it is neither we leave columnIndex + // at -1 and no person ID will be available. columnIndex = -1; - if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)) { - // content://com.android.contacts/data/phones URL + String url = contactRef.toString(); + if (url.startsWith("content://com.android.contacts/data/phones")) { + if (VDBG) Log.v(TAG, + "URL path starts with 'data/phones' using RawContacts.CONTACT_ID"); columnIndex = cursor.getColumnIndex(RawContacts.CONTACT_ID); - } else { - // content://com.android.contacts/phone_lookup URL - // TODO: mime type is null here so we cannot test - // if we have the right url type. phone_lookup URL - // should resolve to a mime type. + } else if (url.startsWith("content://com.android.contacts/phone_lookup")) { + if (VDBG) Log.v(TAG, + "URL path starts with 'phone_lookup' using PhoneLookup._ID"); columnIndex = cursor.getColumnIndex(PhoneLookup._ID); + } else { + Log.e(TAG, "Bad contact URL '" + url + "'"); } if (columnIndex != -1) { info.person_id = cursor.getLong(columnIndex); } else { - Log.e(TAG, "Column missing for " + contactRef); + Log.e(TAG, "person_id column missing for " + contactRef); } // look for the custom ringtone, create from the string stored |