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

Commit 69a644f7 authored by Smriti Gupta's avatar Smriti Gupta Committed by Linux Build Service Account
Browse files

PBAP: Apply list start offset properly

Apply list start offset properly to return the
correct number of entries.

CRs-Fixed: 748292
Change-Id: I1381d9e379e95525797d81fa606f4e2a3c447733
parent dd7a3f88
Loading
Loading
Loading
Loading
+23 −13
Original line number Diff line number Diff line
@@ -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
@@ -683,15 +684,20 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
                        if (currentValue.contains(","))
                            currentValue = currentValue.substring(0, currentValue.lastIndexOf(','));
                        selectedNameList.add(currentValue);
                        savedPosList.add(pos);
                    }
                }
            }

            for (int j = listStartOffset; j< selectedNameList.size()&&
                itemsFound < requestSize; j++) {
                itemsFound++;
                                writeVCardEntry(pos, selectedNameList.get(j),result);
                            }
                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);
                        savedPosList.add(pos);
                    }
                }
            }

            for (int i = listStartOffset; i < selectedNameList.size()&&
                        itemsFound < requestSize; i++) {
                itemsFound++;
                            writeVCardEntry(pos, selectedNameList.get(i),result);
                        }
                    }
                writeVCardEntry(savedPosList.get(i), selectedNameList.get(i),result);
            }

            selectedNameList.clear();
            }
            savedPosList.clear();
        }
        return itemsFound;
    }