From 4e815f9cb92f868e173017dcc9a1783324d27886 Mon Sep 17 00:00:00 2001 From: zachh Date: Mon, 4 Dec 2017 17:08:04 -0800 Subject: Removed timestamps from PhoneLookup APIs. Also added onSuccessfulBulkUpdate method. It is safer for each PhoneLookup to keep track of its own last processed time via shared prefs where the value saved is the actual last processed timestamp from the underlying data. This is because it is difficult or impossible to select a single time that spans lookups due to queries being run and processed at different times. The onSuccessfulBulkUpdate method is provided as a hook for PhoneLookups to persist their shared pref once they know the result of bulkUpdate have been successfully saved. Finally, removed usage of the lastModified timestamp from PhoneLookupHistory in PhoneLookupDataSource since I believe the cases it was originally intended to cover are now handled by populateInserts(). Bug: 34672501 Test: unit PiperOrigin-RevId: 177891586 Change-Id: I072409fc217e4d7e36816548862e8b358aebf165 --- .../phonelookup/composite/CompositePhoneLookup.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'java/com/android/dialer/phonelookup/composite') diff --git a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java index 59a845774..520c46f9e 100644 --- a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java +++ b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java @@ -70,11 +70,10 @@ public final class CompositePhoneLookup implements PhoneLookup { } @Override - public ListenableFuture isDirty( - ImmutableSet phoneNumbers, long lastModified) { + public ListenableFuture isDirty(ImmutableSet phoneNumbers) { List> futures = new ArrayList<>(); for (PhoneLookup phoneLookup : phoneLookups) { - futures.add(phoneLookup.isDirty(phoneNumbers, lastModified)); + futures.add(phoneLookup.isDirty(phoneNumbers)); } // Executes all child lookups (possibly in parallel), completing when the first composite lookup // which returns "true" completes, and cancels the others. @@ -90,11 +89,11 @@ public final class CompositePhoneLookup implements PhoneLookup { */ @Override public ListenableFuture> bulkUpdate( - ImmutableMap existingInfoMap, long lastModified) { + ImmutableMap existingInfoMap) { List>> futures = new ArrayList<>(); for (PhoneLookup phoneLookup : phoneLookups) { - futures.add(phoneLookup.bulkUpdate(existingInfoMap, lastModified)); + futures.add(phoneLookup.bulkUpdate(existingInfoMap)); } return Futures.transform( Futures.allAsList(futures), @@ -118,4 +117,14 @@ public final class CompositePhoneLookup implements PhoneLookup { }, MoreExecutors.directExecutor()); } + + @Override + public ListenableFuture onSuccessfulBulkUpdate() { + List> futures = new ArrayList<>(); + for (PhoneLookup phoneLookup : phoneLookups) { + futures.add(phoneLookup.onSuccessfulBulkUpdate()); + } + return Futures.transform( + Futures.allAsList(futures), unused -> null, MoreExecutors.directExecutor()); + } } -- cgit v1.2.3