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

Commit c11e9710 authored by Ricky Wai's avatar Ricky Wai Committed by Android (Google) Code Review
Browse files

Merge "Support work contacts in HFP, PBAP, MAP"

parents d171da2a a9e55488
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.bluetooth.hfp;

import com.android.bluetooth.R;

import com.android.internal.telephony.GsmAlphabet;

import android.bluetooth.BluetoothDevice;
@@ -31,8 +30,8 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.PhoneLookup;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
import com.android.bluetooth.Utils;

import com.android.bluetooth.Utils;

import java.util.HashMap;

@@ -239,7 +238,7 @@ public class AtPhonebook {
                    atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_SUPPORTED;
                    break;
                }
                String pb = ((String)args[1]).trim();
                String pb = args[1].trim();
                while (pb.endsWith("\"")) pb = pb.substring(0, pb.length() - 1);
                while (pb.startsWith("\"")) pb = pb.substring(1, pb.length());
                if (getPhonebookResult(pb, false) == null && !"SM".equals(pb)) {
@@ -430,7 +429,7 @@ public class AtPhonebook {
            pbr.typeColumn = -1;
            pbr.nameColumn = -1;
        } else {
            pbr.cursor = mContentResolver.query(Phone.CONTENT_URI, PHONES_PROJECTION,
            pbr.cursor = mContentResolver.query(Phone.ENTERPRISE_CONTENT_URI, PHONES_PROJECTION,
                    where, null, Phone.NUMBER + " LIMIT " + MAX_PHONEBOOK_SIZE);
            if (pbr.cursor == null) return false;

@@ -517,10 +516,11 @@ public class AtPhonebook {
                // try caller id lookup
                // TODO: This code is horribly inefficient. I saw it
                // take 7 seconds to process 100 missed calls.
                Cursor c = mContentResolver.
                    query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, number),
                          new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE},
                          null, null, null);
                Cursor c = mContentResolver.query(
                        Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, number),
                        new String[] {
                                PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE
                        }, null, null, null);
                if (c != null) {
                    if (c.moveToFirst()) {
                        name = c.getString(0);
+5 −49
Original line number Diff line number Diff line
@@ -697,7 +697,7 @@ public class BluetoothMapContent {
    private String getContactNameFromPhone(String phone) {
        String name = null;

        Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
        Uri uri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
                Uri.encode(phone));

        String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME};
@@ -1025,52 +1025,6 @@ public class BluetoothMapContent {
        return where;
    }

    private String setWhereFilterPhones(String str) {
        String where = "";
        str = str.replace("*", "%");

        Cursor c = mResolver.query(ContactsContract.Contacts.CONTENT_URI, null,
            ContactsContract.Contacts.DISPLAY_NAME + " like ?",
            new String[]{str},
            ContactsContract.Contacts.DISPLAY_NAME + " ASC");

        try {
            while (c != null && c.moveToNext()) {
                String contactId = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));

                Cursor p = mResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
                    ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
                    new String[]{contactId},
                    null);

                try {
                    while (p != null && p.moveToNext()) {
                        String number = p.getString(
                            p.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

                        where += " address = " + "'" + number + "'";
                        if (!p.isLast()) where += " OR ";
                    }
                } finally {
                    close(p);
                }

                if (!c.isLast()) where += " OR ";
            }
        } finally {
            close(c);
        }

        if (str != null && str.length() > 0) {
            if (where.length() > 0) {
                where += " OR ";
            }
            where += " address like " + "'" + str + "'";
        }

        return where;
    }

    private String setWhereFilterOriginatorEmail(BluetoothMapAppParams ap) {
        String where = "";
        String orig = ap.getFilterOriginator();
@@ -1556,7 +1510,8 @@ public class BluetoothMapContent {
        String[] phoneNumbers = null;
        String[] emailAddresses = null;

        Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
        Uri uri = Uri
                .withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
                Uri.encode(phone));

        String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME};
@@ -1583,6 +1538,7 @@ public class BluetoothMapContent {

                // Fetch contact e-mail addresses
                close (p);
                // TODO: Fetch enterprise email
                p = mResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
                        ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
                        new String[]{contactId},
+290 −218

File changed.

Preview size limit exceeded, changes collapsed.