summaryrefslogtreecommitdiffstats
path: root/telephony/java/com/android/internal/telephony/CallerInfo.java
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-10-07 08:28:34 -0700
committerWink Saville <wink@google.com>2010-10-07 08:28:34 -0700
commit2e27a0be78bd9510785789caa14baa029051ca20 (patch)
tree6677e1935e9ac2edd8b039e8946c6a63b8fef637 /telephony/java/com/android/internal/telephony/CallerInfo.java
parent18c000896f9cc77e790b92f29d4ddc18b213e1fb (diff)
downloadframeworks_base-2e27a0be78bd9510785789caa14baa029051ca20.zip
frameworks_base-2e27a0be78bd9510785789caa14baa029051ca20.tar.gz
frameworks_base-2e27a0be78bd9510785789caa14baa029051ca20.tar.bz2
Changed handling of onQueryCompelete to not use mimeType.
Using mimeType causes an IPC request to contacts which can be slow. This can cause an ANR of the Phone app. This change parses the URL and to decide which column to use for the person_id and thus should not cause an ANR. bug: 3060704 Change-Id: I750c72746c7269e162f0338c0a3e00230a600519
Diffstat (limited to 'telephony/java/com/android/internal/telephony/CallerInfo.java')
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfo.java36
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 cf89848..360d35e 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