Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e99245e authored by Wink Saville's avatar Wink Saville Committed by Android Git Automerger
Browse files

am bbc80d34: Merge "Changed handling of onQueryCompelete to not use mimeType." into gingerbread

Merge commit 'bbc80d34' into gingerbread-plus-aosp

* commit 'bbc80d34':
  Changed handling of onQueryCompelete to not use mimeType.
parents 9df14085 bbc80d34
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -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