From d28981d41c3691fc9fa5204e1d02fa4f2d818b43 Mon Sep 17 00:00:00 2001 From: zachh Date: Wed, 6 Dec 2017 19:25:22 -0800 Subject: Renamed PhoneLookup#bulkUpdate to #getMostRecentPhoneLookupInfo. This is just to more clearly convey what the method does. Bug: 34672501 Test: existing PiperOrigin-RevId: 178188575 Change-Id: Id02f34b1d79346ecd8ca9eebc043fe9b3063264b --- .../phonelookup/PhoneLookupDataSource.java | 20 +++++++------------- java/com/android/dialer/phonelookup/PhoneLookup.java | 20 ++++++++++---------- .../phonelookup/composite/CompositePhoneLookup.java | 7 ++++--- .../dialer/phonelookup/cp2/Cp2PhoneLookup.java | 5 +++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 9b90ad5cc..9606b8e77 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -83,18 +83,10 @@ public final class PhoneLookupDataSource implements CallLogDataSource { } @WorkerThread - private boolean isDirtyInternal(Context appContext) { + private boolean isDirtyInternal(Context appContext) throws Exception { ImmutableSet uniqueDialerPhoneNumbers = queryDistinctDialerPhoneNumbersFromAnnotatedCallLog(appContext); - - try { - // TODO(zachh): Would be good to rework call log architecture to properly use futures. - // TODO(zachh): Consider how individual lookups should behave wrt timeouts/exceptions and - // handle appropriately here. - return phoneLookup.isDirty(uniqueDialerPhoneNumbers).get(); - } catch (InterruptedException | ExecutionException e) { - throw new IllegalStateException(e); - } + return phoneLookup.isDirty(uniqueDialerPhoneNumbers).get(); } /** @@ -113,8 +105,9 @@ public final class PhoneLookupDataSource implements CallLogDataSource { *
  • For inserts, uses the contents of PhoneLookupHistory to populate the fields of the * provided mutations. (Note that at this point, data may not be fully up-to-date, but the * next steps will take care of that.) - *
  • Uses all of the numbers from AnnotatedCallLog to invoke CompositePhoneLookup:bulkUpdate - *
  • Looks through the results of bulkUpdate + *
  • Uses all of the numbers from AnnotatedCallLog to invoke (composite) {@link + * PhoneLookup#getMostRecentPhoneLookupInfo(ImmutableMap)} + *
  • Looks through the results of getMostRecentPhoneLookupInfo *
      *
    • For each number, checks if the original PhoneLookupInfo differs from the new one *
    • If so, it applies the update to the mutations and (in onSuccessfulFill) writes the @@ -142,7 +135,8 @@ public final class PhoneLookupDataSource implements CallLogDataSource { ImmutableMap updatedInfoMap; try { - updatedInfoMap = phoneLookup.bulkUpdate(originalPhoneLookupInfosByNumber).get(); + updatedInfoMap = + phoneLookup.getMostRecentPhoneLookupInfo(originalPhoneLookupInfosByNumber).get(); } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException(e); } diff --git a/java/com/android/dialer/phonelookup/PhoneLookup.java b/java/com/android/dialer/phonelookup/PhoneLookup.java index 183277569..eeab4dadd 100644 --- a/java/com/android/dialer/phonelookup/PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/PhoneLookup.java @@ -27,8 +27,8 @@ import com.google.common.util.concurrent.ListenableFuture; * Provides operations related to retrieving information about phone numbers. * *

      Some operations defined by this interface are generally targeted towards specific use cases; - * for example {@link #isDirty(ImmutableSet)}, {@link #bulkUpdate(ImmutableMap)}, and {@link - * #onSuccessfulBulkUpdate()} are generally intended to be used by the call log. + * for example {@link #isDirty(ImmutableSet)}, {@link #getMostRecentPhoneLookupInfo(ImmutableMap)}, + * and {@link #onSuccessfulBulkUpdate()} are generally intended to be used by the call log. */ public interface PhoneLookup { @@ -48,9 +48,9 @@ public interface PhoneLookup { ListenableFuture isDirty(ImmutableSet phoneNumbers); /** - * Performs a bulk update of this {@link PhoneLookup}. The returned map must contain the exact - * same keys as the provided map. Most implementations will rely on last modified timestamps to - * efficiently only update the data which needs to be updated. + * Get the most recent phone lookup information for this {@link PhoneLookup}. The returned map + * must contain the exact same keys as the provided map. Most implementations will rely on last + * modified timestamps to efficiently only update the data which needs to be updated. * *

      If there are no changes required, it is valid for this method to simply return the provided * {@code existingInfoMap}. @@ -58,16 +58,16 @@ public interface PhoneLookup { *

      If there is no longer information associated with a number (for example, a local contact was * deleted) the returned map should contain an empty {@link PhoneLookupInfo} for that number. */ - ListenableFuture> bulkUpdate( + ListenableFuture> getMostRecentPhoneLookupInfo( ImmutableMap existingInfoMap); /** - * Called when the results of the {@link #bulkUpdate(ImmutableMap)} have been applied by the - * caller. + * Called when the results of the {@link #getMostRecentPhoneLookupInfo(ImmutableMap)} have been + * applied by the caller. * *

      Typically implementations will use this to store a "last processed" timestamp so that future - * invocations of {@link #isDirty(ImmutableSet)} and {@link #bulkUpdate(ImmutableMap)} can be - * efficiently implemented. + * invocations of {@link #isDirty(ImmutableSet)} and {@link + * #getMostRecentPhoneLookupInfo(ImmutableMap)} can be efficiently implemented. */ ListenableFuture onSuccessfulBulkUpdate(); } diff --git a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java index abc0c74fd..ee2244615 100644 --- a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java +++ b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java @@ -97,12 +97,13 @@ public final class CompositePhoneLookup implements PhoneLookup { * the dependent lookups does not complete, the returned future will also not complete. */ @Override - public ListenableFuture> bulkUpdate( - ImmutableMap existingInfoMap) { + public ListenableFuture> + getMostRecentPhoneLookupInfo( + ImmutableMap existingInfoMap) { List>> futures = new ArrayList<>(); for (PhoneLookup phoneLookup : phoneLookups) { - futures.add(phoneLookup.bulkUpdate(existingInfoMap)); + futures.add(phoneLookup.getMostRecentPhoneLookupInfo(existingInfoMap)); } return Futures.transform( Futures.allAsList(futures), diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java index cd645a447..03e05b563 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java @@ -188,8 +188,9 @@ public final class Cp2PhoneLookup implements PhoneLookup { } @Override - public ListenableFuture> bulkUpdate( - ImmutableMap existingInfoMap) { + public ListenableFuture> + getMostRecentPhoneLookupInfo( + ImmutableMap existingInfoMap) { return backgroundExecutorService.submit(() -> bulkUpdateInternal(existingInfoMap)); } -- cgit v1.2.3