Commit 04040246 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by The Android Automerger
Browse files

Fix column ID for PBAP name lookup

When a phonebook lookup is performed to resolve a phone number into a
name, the wrong column ID is used to retrieve the value from the cursor,
causing an un-caught exception and a failed lookup.

Bug: 22953958
Change-Id: I1f826412916012382903fdf30d43d5cb3516432c
parent f4e5f7b8
......@@ -276,8 +276,8 @@ public class BluetoothPbapVcardManager {
Collections.sort(nameList);
}
}
} catch (CursorWindowAllocationException e) {
Log.e(TAG, "CursorWindowAllocationException while getting Phonebook name list");
} catch (Exception e) {
Log.e(TAG, "Exception while getting Phonebook name list", e);
} finally {
if (contactCursor != null) {
contactCursor.close();
......@@ -838,11 +838,12 @@ public class BluetoothPbapVcardManager {
*/
private static final int getDistinctContactIdSize(Cursor cursor) {
final int contactIdColumn = cursor.getColumnIndex(Data.CONTACT_ID);
final int idColumn = cursor.getColumnIndex(Data._ID);
long previousContactId = -1;
int count = 0;
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
final long contactId = cursor.getLong(contactIdColumn);
final long contactId = cursor.getLong(contactIdColumn != -1 ? contactIdColumn : idColumn);
if (previousContactId != contactId) {
count++;
previousContactId = contactId;
......@@ -861,11 +862,12 @@ public class BluetoothPbapVcardManager {
private static void appendDistinctNameIdList(ArrayList<String> resultList,
String defaultName, Cursor cursor) {
final int contactIdColumn = cursor.getColumnIndex(Data.CONTACT_ID);
final int idColumn = cursor.getColumnIndex(Data._ID);
final int nameColumn = cursor.getColumnIndex(Data.DISPLAY_NAME);
long previousContactId = -1;
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
final long contactId = cursor.getLong(contactIdColumn);
final long contactId = cursor.getLong(contactIdColumn != -1 ? contactIdColumn : idColumn);
String displayName = nameColumn != -1 ? cursor.getString(nameColumn) : defaultName;
if (TextUtils.isEmpty(displayName)) {
displayName = defaultName;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment