diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-22 16:57:14 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-22 16:57:14 +0000 |
commit | 9877f59d3c4af34bedbbd27e45d00efa0ccb0b6a (patch) | |
tree | c56952ad6393f04424eda90b4a85cb26a1f54f8e | |
parent | ecacd03b1dc86afadecdf99ef3a11a09e4a38888 (diff) | |
parent | fd75e4c3b3c1a8f5a6ee5d3ce6a8503cf83ea424 (diff) |
Updating logic for isBlockedNumber
am: fd75e4c
* commit 'fd75e4c3b3c1a8f5a6ee5d3ce6a8503cf83ea424':
Updating logic for isBlockedNumber
-rw-r--r-- | src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java | 8 | ||||
-rw-r--r-- | tests/src/com/android/dialer/database/FilteredNumberAsyncQueryHandlerTest.java | 21 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java index 7af1a1339..52ef49ac0 100644 --- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java +++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java @@ -158,7 +158,13 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { new Listener() { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { - if (cursor == null || cursor.getCount() != 1) { + /* + * In the frameworking blocking, numbers can be blocked in both e164 format + * and not, resulting in multiple rows being returned for this query. For + * example, both '16502530000' and '6502530000' can exist at the same time + * and will be returned by this query. + */ + if (cursor == null || cursor.getCount() == 0) { listener.onCheckComplete(null); return; } diff --git a/tests/src/com/android/dialer/database/FilteredNumberAsyncQueryHandlerTest.java b/tests/src/com/android/dialer/database/FilteredNumberAsyncQueryHandlerTest.java index 28fdda0dc..625f3fdb5 100644 --- a/tests/src/com/android/dialer/database/FilteredNumberAsyncQueryHandlerTest.java +++ b/tests/src/com/android/dialer/database/FilteredNumberAsyncQueryHandlerTest.java @@ -47,6 +47,7 @@ public class FilteredNumberAsyncQueryHandlerTest extends InstrumentationTestCase private static final String NUMBER = "6502530000"; private static final String COUNTRY_ISO = "US"; private static final Integer ID = 1; + private static final Integer ID2 = 2; private static final Uri BLOCKED_NUMBER_URI_N = CompatUtils.isNCompatible() ? Uri.withAppendedPath(BlockedNumberContract.AUTHORITY_URI, "blocked") : null; private static final Uri BLOCKED_NUMBER_URI_M = @@ -177,6 +178,26 @@ public class FilteredNumberAsyncQueryHandlerTest extends InstrumentationTestCase mContentProvider.verify(); } + public void testIsBlockedNumber_MultipleResults() throws Throwable { + if (CompatUtils.isNCompatible()) { + newIsBlockedNumberExpectedQuery().returnRow(ID).returnRow(ID2); + } else { + newIsBlockedNumberExpectedQuery().returnRow(ID, FilteredNumberTypes.BLOCKED_NUMBER) + .returnRow(ID2, FilteredNumberTypes.BLOCKED_NUMBER); + } + final CheckBlockedListener listener = new CheckBlockedListener(); + runTestOnUiThread(new Runnable() { + @Override + public void run() { + new FilteredNumberAsyncQueryHandler(mContentResolver) + .isBlockedNumber(listener, NUMBER, COUNTRY_ISO); + } + }); + // When there are multiple matches, the first is returned + assertEquals(ID, listener.waitForCallback()); + mContentProvider.verify(); + } + public void testBlockNumber_Disabled() throws Throwable { if (!CompatUtils.isNCompatible()) { return; |