Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java 100644 → 100755 +31 −16 Original line number Diff line number Diff line Loading @@ -817,50 +817,65 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } if (type.equals("number")) { ArrayList<Integer> savedPosList = new ArrayList<>(); ArrayList<String> selectedNameList = new ArrayList<String>(); // query the number, to get the names ArrayList<String> names = mVcardManager.getContactNamesByNumber(appParamValue.searchValue); if (mOrderBy == ORDER_BY_ALPHABETICAL) Collections.sort(names); for (int i = 0; i < names.size(); i++) { compareValue = names.get(i).trim(); if (D) { Log.d(TAG, "compareValue=" + compareValue); } for (int pos = appParamValue.listStartOffset; pos < listSize && itemsFound < requestSize; pos++) { if (D) Log.d(TAG, "compareValue=" + compareValue); for (int pos = 0; pos < listSize; pos++) { currentValue = nameList.get(pos); if (V) { Log.d(TAG, "currentValue=" + currentValue); } if (currentValue.equals(compareValue)) { itemsFound++; if (currentValue.contains(",")) { currentValue = currentValue.substring(0, currentValue.lastIndexOf(',')); } writeVCardEntry(pos, currentValue, result); selectedNameList.add(currentValue); savedPosList.add(pos); } } if (itemsFound >= requestSize) { break; } for (int j = appParamValue.listStartOffset; j < selectedNameList.size() && itemsFound < requestSize; j++) { itemsFound++; writeVCardEntry(savedPosList.get(j), selectedNameList.get(j), result); } } else { ArrayList<Integer> savedPosList = new ArrayList<>(); ArrayList<String> selectedNameList = new ArrayList<String>(); if (appParamValue.searchValue != null) { compareValue = appParamValue.searchValue.trim().toLowerCase(); } for (int pos = appParamValue.listStartOffset; pos < listSize && itemsFound < requestSize; pos++) { for (int pos = 0; pos < listSize; pos++) { currentValue = nameList.get(pos); if (currentValue.contains(",")) { currentValue = currentValue.substring(0, currentValue.lastIndexOf(',')); } if (appParamValue.searchValue.isEmpty() || ((currentValue.toLowerCase()).startsWith( compareValue))) { itemsFound++; writeVCardEntry(pos, currentValue, result); if (appParamValue.searchValue != null) { if (appParamValue.searchValue.isEmpty() || ((currentValue.toLowerCase()) .startsWith(compareValue.toLowerCase()))) { selectedNameList.add(currentValue); savedPosList.add(pos); } } } for (int i = appParamValue.listStartOffset; i < selectedNameList.size() && itemsFound < requestSize; i++) { itemsFound++; writeVCardEntry(savedPosList.get(i), selectedNameList.get(i), result); } } return itemsFound; } Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java 100644 → 100755 +8 −1 Original line number Diff line number Diff line Loading @@ -332,12 +332,18 @@ public class BluetoothPbapVcardManager { contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, null, null, Phone.CONTACT_ID); ArrayList<String> contactNameIdList = new ArrayList<String>(); appendDistinctNameIdList(contactNameIdList, mContext.getString(android.R.string.unknownName), contactCursor); if (contactCursor != null) { if (!composer.initWithCallback(contactCursor, new EnterpriseRawContactEntitlesInfoCallback())) { return nameList; } int i = 0; contactCursor.moveToFirst(); while (!composer.isAfterLast()) { String vcard = composer.createOneEntry(); if (vcard == null) { Loading @@ -362,8 +368,9 @@ public class BluetoothPbapVcardManager { if (TextUtils.isEmpty(name)) { name = mContext.getString(android.R.string.unknownName); } nameList.add(name); nameList.add(contactNameIdList.get(i)); } i++; } if (orderByWhat == BluetoothPbapObexServer.ORDER_BY_INDEXED) { if (V) { Loading Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java 100644 → 100755 +31 −16 Original line number Diff line number Diff line Loading @@ -817,50 +817,65 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } if (type.equals("number")) { ArrayList<Integer> savedPosList = new ArrayList<>(); ArrayList<String> selectedNameList = new ArrayList<String>(); // query the number, to get the names ArrayList<String> names = mVcardManager.getContactNamesByNumber(appParamValue.searchValue); if (mOrderBy == ORDER_BY_ALPHABETICAL) Collections.sort(names); for (int i = 0; i < names.size(); i++) { compareValue = names.get(i).trim(); if (D) { Log.d(TAG, "compareValue=" + compareValue); } for (int pos = appParamValue.listStartOffset; pos < listSize && itemsFound < requestSize; pos++) { if (D) Log.d(TAG, "compareValue=" + compareValue); for (int pos = 0; pos < listSize; pos++) { currentValue = nameList.get(pos); if (V) { Log.d(TAG, "currentValue=" + currentValue); } if (currentValue.equals(compareValue)) { itemsFound++; if (currentValue.contains(",")) { currentValue = currentValue.substring(0, currentValue.lastIndexOf(',')); } writeVCardEntry(pos, currentValue, result); selectedNameList.add(currentValue); savedPosList.add(pos); } } if (itemsFound >= requestSize) { break; } for (int j = appParamValue.listStartOffset; j < selectedNameList.size() && itemsFound < requestSize; j++) { itemsFound++; writeVCardEntry(savedPosList.get(j), selectedNameList.get(j), result); } } else { ArrayList<Integer> savedPosList = new ArrayList<>(); ArrayList<String> selectedNameList = new ArrayList<String>(); if (appParamValue.searchValue != null) { compareValue = appParamValue.searchValue.trim().toLowerCase(); } for (int pos = appParamValue.listStartOffset; pos < listSize && itemsFound < requestSize; pos++) { for (int pos = 0; pos < listSize; pos++) { currentValue = nameList.get(pos); if (currentValue.contains(",")) { currentValue = currentValue.substring(0, currentValue.lastIndexOf(',')); } if (appParamValue.searchValue.isEmpty() || ((currentValue.toLowerCase()).startsWith( compareValue))) { itemsFound++; writeVCardEntry(pos, currentValue, result); if (appParamValue.searchValue != null) { if (appParamValue.searchValue.isEmpty() || ((currentValue.toLowerCase()) .startsWith(compareValue.toLowerCase()))) { selectedNameList.add(currentValue); savedPosList.add(pos); } } } for (int i = appParamValue.listStartOffset; i < selectedNameList.size() && itemsFound < requestSize; i++) { itemsFound++; writeVCardEntry(savedPosList.get(i), selectedNameList.get(i), result); } } return itemsFound; } Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java 100644 → 100755 +8 −1 Original line number Diff line number Diff line Loading @@ -332,12 +332,18 @@ public class BluetoothPbapVcardManager { contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, null, null, Phone.CONTACT_ID); ArrayList<String> contactNameIdList = new ArrayList<String>(); appendDistinctNameIdList(contactNameIdList, mContext.getString(android.R.string.unknownName), contactCursor); if (contactCursor != null) { if (!composer.initWithCallback(contactCursor, new EnterpriseRawContactEntitlesInfoCallback())) { return nameList; } int i = 0; contactCursor.moveToFirst(); while (!composer.isAfterLast()) { String vcard = composer.createOneEntry(); if (vcard == null) { Loading @@ -362,8 +368,9 @@ public class BluetoothPbapVcardManager { if (TextUtils.isEmpty(name)) { name = mContext.getString(android.R.string.unknownName); } nameList.add(name); nameList.add(contactNameIdList.get(i)); } i++; } if (orderByWhat == BluetoothPbapObexServer.ORDER_BY_INDEXED) { if (V) { Loading