Merge "Changed handling of onQueryCompelete to not use mimeType." into gingerbread
This commit is contained in:
@@ -26,9 +26,9 @@ import static android.provider.ContactsContract.RawContacts;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.util.Config;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up caller information for the given phone number.
|
* Looks up caller information for the given phone number.
|
||||||
*
|
*
|
||||||
@@ -36,6 +36,7 @@ import android.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class CallerInfo {
|
public class CallerInfo {
|
||||||
private static final String TAG = "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 UNKNOWN_NUMBER = "-1";
|
||||||
public static final String PRIVATE_NUMBER = "-2";
|
public static final String PRIVATE_NUMBER = "-2";
|
||||||
@@ -128,7 +129,7 @@ public class CallerInfo {
|
|||||||
info.isCachedPhotoCurrent = false;
|
info.isCachedPhotoCurrent = false;
|
||||||
info.contactExists = 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 != null) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
@@ -166,31 +167,30 @@ public class CallerInfo {
|
|||||||
// Look for the person ID.
|
// Look for the person ID.
|
||||||
|
|
||||||
// TODO: This is pretty ugly now, see bug 2269240 for
|
// TODO: This is pretty ugly now, see bug 2269240 for
|
||||||
// more details. With tel: URI the contact id is in
|
// more details. The column to use depends upon the type of URL,
|
||||||
// col "_id" while when we use a
|
// for content://com.android.contacts/data/phones the "contact_id"
|
||||||
// content://contacts/data/phones URI, the contact id
|
// column is used. For content/com.andriod.contacts/phone_lookup"
|
||||||
// is col "contact_id". As a work around we use the
|
// the "_ID" column is used. If it is neither we leave columnIndex
|
||||||
// type of the contact url to figure out which column
|
// at -1 and no person ID will be available.
|
||||||
// we should look at to get the contact_id.
|
|
||||||
|
|
||||||
final String mimeType = context.getContentResolver().getType(contactRef);
|
|
||||||
|
|
||||||
columnIndex = -1;
|
columnIndex = -1;
|
||||||
if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)) {
|
String url = contactRef.toString();
|
||||||
// content://com.android.contacts/data/phones URL
|
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);
|
columnIndex = cursor.getColumnIndex(RawContacts.CONTACT_ID);
|
||||||
} else {
|
} else if (url.startsWith("content://com.android.contacts/phone_lookup")) {
|
||||||
// content://com.android.contacts/phone_lookup URL
|
if (VDBG) Log.v(TAG,
|
||||||
// TODO: mime type is null here so we cannot test
|
"URL path starts with 'phone_lookup' using PhoneLookup._ID");
|
||||||
// if we have the right url type. phone_lookup URL
|
|
||||||
// should resolve to a mime type.
|
|
||||||
columnIndex = cursor.getColumnIndex(PhoneLookup._ID);
|
columnIndex = cursor.getColumnIndex(PhoneLookup._ID);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Bad contact URL '" + url + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndex != -1) {
|
if (columnIndex != -1) {
|
||||||
info.person_id = cursor.getLong(columnIndex);
|
info.person_id = cursor.getLong(columnIndex);
|
||||||
} else {
|
} 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
|
// look for the custom ringtone, create from the string stored
|
||||||
|
|||||||
Reference in New Issue
Block a user