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

Commit aebe4204 authored by Kihong Seong's avatar Kihong Seong
Browse files

Fix AtPhonebookTest breakage

Bug: 255833353
Test: atest AtPhonebookTest
Change-Id: I60e5689e097512a3d218f52c4cf60689fea5346c
(cherry picked from commit 0fd11214)
parent 3a1d7f97
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public class AtPhonebook {
    private static final String INCOMING_CALL_WHERE = Calls.TYPE + "=" + Calls.INCOMING_TYPE;
    private static final String MISSED_CALL_WHERE = Calls.TYPE + "=" + Calls.MISSED_TYPE;

    private class PhonebookResult {
    @VisibleForTesting
    class PhonebookResult {
        public Cursor cursor; // result set of last query
        public int numberColumn;
        public int numberPresentationColumn;
@@ -388,7 +389,8 @@ public class AtPhonebook {
     *  If force then re-query that phonebook
     *  Returns null if the cursor is not ready
     */
    private synchronized PhonebookResult getPhonebookResult(String pb, boolean force) {
    @VisibleForTesting
    synchronized PhonebookResult getPhonebookResult(String pb, boolean force) {
        if (pb == null) {
            return null;
        }
@@ -470,7 +472,8 @@ public class AtPhonebook {
        mCheckingAccessPermission = false;
    }

    private synchronized int getMaxPhoneBookSize(int currSize) {
    @VisibleForTesting
    synchronized int getMaxPhoneBookSize(int currSize) {
        // some car kits ignore the current size and request max phone book
        // size entries. Thus, it takes a long time to transfer all the
        // entries. Use a heuristic to calculate the max phone book size
+8 −2
Original line number Diff line number Diff line
@@ -111,8 +111,10 @@ public class AtPhonebookTest {
    @Test
    public void handleCpbsCommand() {
        mAtPhonebook.handleCpbsCommand(INVALID_COMMAND, AtPhonebook.TYPE_READ, mTestDevice);
        int size = mAtPhonebook.getPhonebookResult("ME", true).cursor.getCount();
        int maxSize = mAtPhonebook.getMaxPhoneBookSize(size);
        verify(mNativeInterface).atResponseString(mTestDevice,
                "+CPBS: \"" + "ME" + "\"," + 0 + "," + 256);
                "+CPBS: \"" + "ME" + "\"," + size + "," + maxSize);

        mAtPhonebook.handleCpbsCommand(INVALID_COMMAND, AtPhonebook.TYPE_TEST, mTestDevice);
        verify(mNativeInterface).atResponseString(mTestDevice,
@@ -138,7 +140,11 @@ public class AtPhonebookTest {
    @Test
    public void handleCpbrCommand() {
        mAtPhonebook.handleCpbrCommand(INVALID_COMMAND, AtPhonebook.TYPE_TEST, mTestDevice);
        verify(mNativeInterface).atResponseString(mTestDevice, "+CPBR: (1-" + 1 + "),30,30");
        int size = mAtPhonebook.getPhonebookResult("ME", true).cursor.getCount();
        if (size == 0) {
            size = 1;
        }
        verify(mNativeInterface).atResponseString(mTestDevice, "+CPBR: (1-" + size + "),30,30");
        verify(mNativeInterface).atResponseCode(mTestDevice, HeadsetHalConstants.AT_RESPONSE_OK,
                -1);