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

Commit dd4146c3 authored by Satish Kodishala's avatar Satish Kodishala Committed by Andre Eisenbach
Browse files

HFP: Reset max index if greater than number of Phone Book entries

Use case:
1. Pair and connect to car kit supporting Phone book download
   using AT commands eg Skoda Octavia 1.6.
2. Sync call history from car kit UI.

Failure:
Some times, phone just sends OK to AT+CPBR command though
there are entries in the call history.

Root cause:
When car kit requests for more number of entries than actually
present in the phone, we just send OK and don't send any results.

Fix:
When max index in AT+CPBR command is greater than number of entries
in phone book, reset the max index to the number of entries and send
available entries.

Bug: 66358394
Change-Id: I5c106b67d2696108f165c37d543c84fad724852c
parent 59cb37dd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -490,6 +490,7 @@ public class AtPhonebook {
        // Check phonebook
        PhonebookResult pbr = getPhonebookResult(mCurrentPhonebook, true); //false);
        if (pbr == null) {
            Log.e(TAG, "pbr is null");
            atCommandErrorCode = BluetoothCmeError.OPERATION_NOT_ALLOWED;
            return atCommandResult;
        }
@@ -499,11 +500,17 @@ public class AtPhonebook {
        // When we send error, certain kits like BMW disconnect the
        // Handsfree connection.
        if (pbr.cursor.getCount() == 0 || mCpbrIndex1 <= 0 || mCpbrIndex2 < mCpbrIndex1  ||
            mCpbrIndex2 > pbr.cursor.getCount() || mCpbrIndex1 > pbr.cursor.getCount()) {
            mCpbrIndex1 > pbr.cursor.getCount()) {
            atCommandResult = HeadsetHalConstants.AT_RESPONSE_OK;
            Log.e(TAG, "Invalid request or no results, returning");
            return atCommandResult;
        }

        if (mCpbrIndex2 > pbr.cursor.getCount()) {
            Log.w(TAG, "max index requested is greater than number of records"
                        + " available, resetting it");
            mCpbrIndex2 = pbr.cursor.getCount();
        }
        // Process
        atCommandResult = HeadsetHalConstants.AT_RESPONSE_OK;
        int errorDetected = -1; // no error