From 73ec1ab52956c658654a40c42f4c59806713b15e Mon Sep 17 00:00:00 2001 From: zachh Date: Tue, 9 Jan 2018 17:44:36 -0800 Subject: Changed behavior of failures in DialerFutures#firstMatching. DialerFutures#firstMatching now fails if one of its provided futures fails before a match is found. This is to accomodate the case where no source returns true for isDirty, but one or more fail; we want to be notified of the failure in that case and not silently treat that case as not dirty. Also fixed a bug in NewCallLogFragment where the failed future wasn't causing the application to crash. Also improved some related logging in RefreshAnnotatedCallLogWorker and Cp2PhoneLookup, and fixed a bug where empty numbers were not being handled correctly. Bug: 71504246 Test: unit PiperOrigin-RevId: 181401710 Change-Id: I23e207ac334ff80ac95b08a8f4f775a528a8c511 --- .../com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'java/com/android/dialer/phonelookup') diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java index 5ae0fb68a..dd440708c 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java @@ -211,6 +211,7 @@ public final class Cp2PhoneLookup implements PhoneLookup { anyContactsDeletedFuture, anyContactsDeleted -> { if (anyContactsDeleted) { + LogUtil.v("Cp2PhoneLookup.isDirty", "returning true because contacts deleted"); return Futures.immediateFuture(true); } // Hopefully the most common case is there are no contacts updated; we can detect @@ -221,6 +222,9 @@ public final class Cp2PhoneLookup implements PhoneLookup { noContactsModifiedSinceFuture, noContactsModifiedSince -> { if (noContactsModifiedSince) { + LogUtil.v( + "Cp2PhoneLookup.isDirty", + "returning false because no contacts modified since last run"); return Futures.immediateFuture(false); } // This method is more expensive but is probably the most likely scenario; we @@ -236,6 +240,9 @@ public final class Cp2PhoneLookup implements PhoneLookup { contactsUpdatedFuture, contactsUpdated -> { if (contactsUpdated) { + LogUtil.v( + "Cp2PhoneLookup.isDirty", + "returning true because a previously called contact was updated"); return Futures.immediateFuture(true); } // This is the most expensive method so do it last; the scenario is that @@ -357,13 +364,14 @@ public final class Cp2PhoneLookup implements PhoneLookup { private ListenableFuture> queryPhoneLookupTableForContactIdsBasedOnRawNumber( String rawNumber) { + if (TextUtils.isEmpty(rawNumber)) { + return Futures.immediateFuture(new ArraySet<>()); + } return backgroundExecutorService.submit( () -> { Set contactIds = new ArraySet<>(); try (Cursor cursor = - queryPhoneLookup( - new String[] {android.provider.ContactsContract.PhoneLookup.CONTACT_ID}, - rawNumber)) { + queryPhoneLookup(new String[] {ContactsContract.PhoneLookup.CONTACT_ID}, rawNumber)) { if (cursor == null) { LogUtil.w( "Cp2PhoneLookup.queryPhoneLookupTableForContactIdsBasedOnRawNumber", -- cgit v1.2.3