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

Commit 2624136f authored by Flavio Lerda's avatar Flavio Lerda Committed by Android (Google) Code Review
Browse files

Merge "Normalize the phone number before contact look up."

parents 768f6ea3 252fabfd
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -192,13 +192,25 @@ public class ContactInfoHelper {
    private ContactInfo queryContactInfoForPhoneNumber(String number, String countryIso) {
        final ContactInfo info;

        // "number" is a regular phone number, so use the
        String contactNumber = number;
        if (!TextUtils.isEmpty(countryIso)) {
            // Normalize the number: this is needed because the PhoneLookup query below does not
            // accept a country code as an input.
            String numberE164 = PhoneNumberUtils.formatNumberToE164(number, countryIso);
            if (!TextUtils.isEmpty(numberE164)) {
                // Only use it if the number could be formatted to E164.
                contactNumber = numberE164;
            }
        }

        // "contactNumber" is a regular phone number, so use the
        // PhoneLookup table:
        Cursor phonesCursor =
                mContext.getContentResolver().query(
                    Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
                            Uri.encode(number)),
                            Uri.encode(contactNumber)),
                            PhoneQuery._PROJECTION, null, null, null);

        if (phonesCursor != null) {
            if (phonesCursor.moveToFirst()) {
                info = new ContactInfo();