summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmriti Gupta <smritig@codeaurora.org>2014-10-30 17:34:13 +0530
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:26:39 -0700
commit69a644f7d21227438899383a4d7a9494eb34b7a1 (patch)
tree4aa01a3a7060c85d8d26841456e93ece238757ba
parentdd7a3f88c4e5d134f6fb235b86f9ac30c6de7ae9 (diff)
downloadandroid_packages_apps_Bluetooth-staging/cm-12.0-caf.tar.gz
android_packages_apps_Bluetooth-staging/cm-12.0-caf.tar.bz2
android_packages_apps_Bluetooth-staging/cm-12.0-caf.zip
PBAP: Apply list start offset properlystaging/cm-12.0-caf
Apply list start offset properly to return the correct number of entries. CRs-Fixed: 748292 Change-Id: I1381d9e379e95525797d81fa606f4e2a3c447733
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
index 79e11d288..0cf01aa02 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
@@ -650,6 +650,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
private int createList(final int maxListCount, final int listStartOffset,
final String searchValue, StringBuilder result, String type, boolean SIM) {
int itemsFound = 0, pos = 0;
+ ArrayList<Integer> savedPosList = new ArrayList<>();
ArrayList<String> nameList = null;
ArrayList<String> selectedNameList = new ArrayList<String>();
//check if current request is for SIM
@@ -682,16 +683,21 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
if (currentValue.equals(compareValue)) {
if (currentValue.contains(","))
currentValue = currentValue.substring(0, currentValue.lastIndexOf(','));
- selectedNameList.add(currentValue);
- for (int j = listStartOffset; j< selectedNameList.size()&&
- itemsFound < requestSize; j++) {
- itemsFound++;
- writeVCardEntry(pos, selectedNameList.get(j),result);
- }
+ selectedNameList.add(currentValue);
+ savedPosList.add(pos);
}
- selectedNameList.clear();
}
}
+
+ for (int j = listStartOffset; j< selectedNameList.size()&&
+ itemsFound < requestSize; j++) {
+ itemsFound++;
+ writeVCardEntry(savedPosList.get(j), selectedNameList.get(j),result);
+ }
+
+ selectedNameList.clear();
+ savedPosList.clear();
+
} else {
if (searchValue != null) {
compareValue = searchValue.trim();
@@ -706,15 +712,19 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
if (searchValue != null) {
if (searchValue.isEmpty() || ((currentValue.toLowerCase()).equals(compareValue.toLowerCase()))) {
selectedNameList.add(currentValue);
- for (int i = listStartOffset; i < selectedNameList.size()&&
- itemsFound < requestSize; i++) {
- itemsFound++;
- writeVCardEntry(pos, selectedNameList.get(i),result);
- }
+ savedPosList.add(pos);
}
}
- selectedNameList.clear();
}
+
+ for (int i = listStartOffset; i < selectedNameList.size()&&
+ itemsFound < requestSize; i++) {
+ itemsFound++;
+ writeVCardEntry(savedPosList.get(i), selectedNameList.get(i),result);
+ }
+
+ selectedNameList.clear();
+ savedPosList.clear();
}
return itemsFound;
}