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

Commit 92072fa3 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

PBAP: Check for spurious entries of searched contacts

This patch adds the check to limit the search if we already
have got the contact name by number so that same contact
will not be getting searched more than one number of time.

Change-Id: If4a26433e28cad90394833b51cc3ff0d0bcf7e36
parent c0e9887e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -608,7 +608,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
                        itemsFound < requestSize; pos++) {
                    currentValue = nameList.get(pos);
                    if (D) Log.d(TAG, "currentValue=" + currentValue);
                    if (currentValue.startsWith(compareValue)) {
                    if (currentValue.equals(compareValue)) {
                        itemsFound++;
                        if (currentValue.contains(","))
                           currentValue = currentValue.substring(0, currentValue.lastIndexOf(','));
+9 −1
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ public class BluetoothPbapVcardManager {

    public final ArrayList<String> getContactNamesByNumber(final String phoneNumber) {
        ArrayList<String> nameList = new ArrayList<String>();
        ArrayList<String> tempNameList = new ArrayList<String>();

        Cursor contactCursor = null;
        Uri uri = null;
@@ -318,7 +319,7 @@ public class BluetoothPbapVcardManager {
                        name = mContext.getString(android.R.string.unknownName);
                    }
                    if (V) Log.v(TAG, "got name " + name + " by number " + phoneNumber + " @" + id);
                    nameList.add(name + "," + id);
                    tempNameList.add(name + "," + id);
                }
            }
        } catch (CursorWindowAllocationException e) {
@@ -329,6 +330,13 @@ public class BluetoothPbapVcardManager {
                contactCursor = null;
            }
        }
        int tempListSize = tempNameList.size();
        for (int index = 0; index < tempListSize; index++) {
            String object = tempNameList.get(index);
            if (!nameList.contains(object))
                nameList.add(object);
        }

        return nameList;
    }