Loading android/app/src/com/android/bluetooth/hfp/AtPhonebook.java +8 −8 Original line number Original line Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.bluetooth.hfp; package com.android.bluetooth.hfp; import com.android.bluetooth.R; import com.android.bluetooth.R; import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.GsmAlphabet; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; Loading @@ -31,8 +30,8 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.util.Log; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.Utils; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -239,7 +238,7 @@ public class AtPhonebook { atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_SUPPORTED; atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_SUPPORTED; break; break; } } String pb = ((String)args[1]).trim(); String pb = args[1].trim(); while (pb.endsWith("\"")) pb = pb.substring(0, pb.length() - 1); while (pb.endsWith("\"")) pb = pb.substring(0, pb.length() - 1); while (pb.startsWith("\"")) pb = pb.substring(1, pb.length()); while (pb.startsWith("\"")) pb = pb.substring(1, pb.length()); if (getPhonebookResult(pb, false) == null && !"SM".equals(pb)) { if (getPhonebookResult(pb, false) == null && !"SM".equals(pb)) { Loading Loading @@ -430,7 +429,7 @@ public class AtPhonebook { pbr.typeColumn = -1; pbr.typeColumn = -1; pbr.nameColumn = -1; pbr.nameColumn = -1; } else { } 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); where, null, Phone.NUMBER + " LIMIT " + MAX_PHONEBOOK_SIZE); if (pbr.cursor == null) return false; if (pbr.cursor == null) return false; Loading Loading @@ -517,10 +516,11 @@ public class AtPhonebook { // try caller id lookup // try caller id lookup // TODO: This code is horribly inefficient. I saw it // TODO: This code is horribly inefficient. I saw it // take 7 seconds to process 100 missed calls. // take 7 seconds to process 100 missed calls. Cursor c = mContentResolver. Cursor c = mContentResolver.query( query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, number), Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, number), new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE}, new String[] { null, null, null); PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE }, null, null, null); if (c != null) { if (c != null) { if (c.moveToFirst()) { if (c.moveToFirst()) { name = c.getString(0); name = c.getString(0); Loading android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +5 −49 Original line number Original line Diff line number Diff line Loading @@ -697,7 +697,7 @@ public class BluetoothMapContent { private String getContactNameFromPhone(String phone) { private String getContactNameFromPhone(String phone) { String name = null; String name = null; Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri uri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(phone)); Uri.encode(phone)); String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; Loading Loading @@ -1025,52 +1025,6 @@ public class BluetoothMapContent { return where; 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) { private String setWhereFilterOriginatorEmail(BluetoothMapAppParams ap) { String where = ""; String where = ""; String orig = ap.getFilterOriginator(); String orig = ap.getFilterOriginator(); Loading Loading @@ -1556,7 +1510,8 @@ public class BluetoothMapContent { String[] phoneNumbers = null; String[] phoneNumbers = null; String[] emailAddresses = null; String[] emailAddresses = null; Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri uri = Uri .withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(phone)); Uri.encode(phone)); String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; Loading @@ -1583,6 +1538,7 @@ public class BluetoothMapContent { // Fetch contact e-mail addresses // Fetch contact e-mail addresses close (p); close (p); // TODO: Fetch enterprise email p = mResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, p = mResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{contactId}, new String[]{contactId}, Loading Loading
android/app/src/com/android/bluetooth/hfp/AtPhonebook.java +8 −8 Original line number Original line Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.bluetooth.hfp; package com.android.bluetooth.hfp; import com.android.bluetooth.R; import com.android.bluetooth.R; import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.GsmAlphabet; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; Loading @@ -31,8 +30,8 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.util.Log; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.Utils; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -239,7 +238,7 @@ public class AtPhonebook { atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_SUPPORTED; atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_SUPPORTED; break; break; } } String pb = ((String)args[1]).trim(); String pb = args[1].trim(); while (pb.endsWith("\"")) pb = pb.substring(0, pb.length() - 1); while (pb.endsWith("\"")) pb = pb.substring(0, pb.length() - 1); while (pb.startsWith("\"")) pb = pb.substring(1, pb.length()); while (pb.startsWith("\"")) pb = pb.substring(1, pb.length()); if (getPhonebookResult(pb, false) == null && !"SM".equals(pb)) { if (getPhonebookResult(pb, false) == null && !"SM".equals(pb)) { Loading Loading @@ -430,7 +429,7 @@ public class AtPhonebook { pbr.typeColumn = -1; pbr.typeColumn = -1; pbr.nameColumn = -1; pbr.nameColumn = -1; } else { } 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); where, null, Phone.NUMBER + " LIMIT " + MAX_PHONEBOOK_SIZE); if (pbr.cursor == null) return false; if (pbr.cursor == null) return false; Loading Loading @@ -517,10 +516,11 @@ public class AtPhonebook { // try caller id lookup // try caller id lookup // TODO: This code is horribly inefficient. I saw it // TODO: This code is horribly inefficient. I saw it // take 7 seconds to process 100 missed calls. // take 7 seconds to process 100 missed calls. Cursor c = mContentResolver. Cursor c = mContentResolver.query( query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, number), Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, number), new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE}, new String[] { null, null, null); PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE }, null, null, null); if (c != null) { if (c != null) { if (c.moveToFirst()) { if (c.moveToFirst()) { name = c.getString(0); name = c.getString(0); Loading
android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +5 −49 Original line number Original line Diff line number Diff line Loading @@ -697,7 +697,7 @@ public class BluetoothMapContent { private String getContactNameFromPhone(String phone) { private String getContactNameFromPhone(String phone) { String name = null; String name = null; Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri uri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(phone)); Uri.encode(phone)); String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; Loading Loading @@ -1025,52 +1025,6 @@ public class BluetoothMapContent { return where; 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) { private String setWhereFilterOriginatorEmail(BluetoothMapAppParams ap) { String where = ""; String where = ""; String orig = ap.getFilterOriginator(); String orig = ap.getFilterOriginator(); Loading Loading @@ -1556,7 +1510,8 @@ public class BluetoothMapContent { String[] phoneNumbers = null; String[] phoneNumbers = null; String[] emailAddresses = null; String[] emailAddresses = null; Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri uri = Uri .withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(phone)); Uri.encode(phone)); String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME}; Loading @@ -1583,6 +1538,7 @@ public class BluetoothMapContent { // Fetch contact e-mail addresses // Fetch contact e-mail addresses close (p); close (p); // TODO: Fetch enterprise email p = mResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, p = mResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{contactId}, new String[]{contactId}, Loading