From e1ec439563705d47f699a565c35eff4bc0dcbf61 Mon Sep 17 00:00:00 2001 From: zachh Date: Fri, 22 Dec 2017 16:59:32 -0800 Subject: Parameterized PhoneLookup with submessage type. This allows indvidual PhoneLookups to define and deal mostly with their own submessage type (with the exception of trivial setter and getter methods for converting from/to PhoneLookupInfo). This also simplifies the FakePhoneLookup and tests which use it a bit, I think. Bug: 34672501 Test: unit PiperOrigin-RevId: 179976215 Change-Id: I2db1fc85771621be2f2afcd6af114d82680e30d0 --- .../android/dialer/phonelookup/PhoneLookup.java | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'java/com/android/dialer/phonelookup/PhoneLookup.java') diff --git a/java/com/android/dialer/phonelookup/PhoneLookup.java b/java/com/android/dialer/phonelookup/PhoneLookup.java index bb14c1ff6..859085e7b 100644 --- a/java/com/android/dialer/phonelookup/PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/PhoneLookup.java @@ -27,19 +27,19 @@ 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 #getMostRecentPhoneLookupInfo(ImmutableMap)}, - * and {@link #onSuccessfulBulkUpdate()} are generally intended to be used by the call log. + * for example {@link #isDirty(ImmutableSet)}, {@link #getMostRecentInfo(ImmutableMap)}, and {@link + * #onSuccessfulBulkUpdate()} are generally intended to be used by the call log. */ -public interface PhoneLookup { +public interface PhoneLookup { /** - * Returns a future containing a new {@link PhoneLookupInfo} for the provided call. + * Returns a future containing a new info for the provided call. * *

The returned message should contain populated data for the sub-message corresponding to this - * {@link PhoneLookup}. For example, the CP2 implementation returns a {@link PhoneLookupInfo} with - * the {@link PhoneLookupInfo.Cp2Info} sub-message populated. + * {@link PhoneLookup}. For example, the CP2 implementation returns a {@link + * PhoneLookupInfo.Cp2Info} sub-message. */ - ListenableFuture lookup(@NonNull Call call); + ListenableFuture lookup(@NonNull Call call); /** * Returns a future which returns true if the information for any of the provided phone numbers @@ -56,24 +56,30 @@ public interface PhoneLookup { * {@code existingInfoMap}. * *

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. + * deleted) the returned map should contain an empty info for that number. */ - ListenableFuture> getMostRecentPhoneLookupInfo( - ImmutableMap existingInfoMap); + ListenableFuture> getMostRecentInfo( + ImmutableMap existingInfoMap); /** - * Populates the sub-message that this {@link PhoneLookup} is responsible for by copying the - * sub-message value from {@code source} to {@code destination} + * Populates the sub-message that this {@link PhoneLookup} is responsible for by copying {@code + * subMessage} into the provided {@code phoneLookupInfo} builder. */ - void copySubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source); + void setSubMessage(PhoneLookupInfo.Builder phoneLookupInfo, T subMessage); /** - * Called when the results of the {@link #getMostRecentPhoneLookupInfo(ImmutableMap)} have been - * applied by the caller. + * Gets the sub-message that this {@link PhoneLookup} is responsible for from the provided {@code + * phoneLookupInfo}. + */ + T getSubMessage(PhoneLookupInfo phoneLookupInfo); + + /** + * Called when the results of the {@link #getMostRecentInfo(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 - * #getMostRecentPhoneLookupInfo(ImmutableMap)} can be efficiently implemented. + * invocations of {@link #isDirty(ImmutableSet)} and {@link #getMostRecentInfo(ImmutableMap)} can + * be efficiently implemented. */ ListenableFuture onSuccessfulBulkUpdate(); } -- cgit v1.2.3