Loading android/app/src/com/android/bluetooth/hfp/AtPhonebook.java +6 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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 Loading android/app/tests/unit/src/com/android/bluetooth/hfp/AtPhonebookTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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); Loading Loading
android/app/src/com/android/bluetooth/hfp/AtPhonebook.java +6 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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 Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/AtPhonebookTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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); Loading