From 0fab10eb28ab1e246f572302ad0e12508a196b34 Mon Sep 17 00:00:00 2001 From: zachh Date: Wed, 20 Dec 2017 10:57:38 -0800 Subject: Added copySubMessage method to PhoneLookup interface. The existing way that protos are merged in CompositePhoneLookup is not correct because foo_submessage from BarDataSource may incorrectly contribute old information to the merged message. The new copySubMessage method makes it so that each PhoneLookup is responsible for defining which submessage it is responsible for and prevents the problem. Test: unit PiperOrigin-RevId: 179707015 Change-Id: I566305cf64c46c698f14812d9241d166ac75a6d3 --- java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'java/com/android/dialer/phonelookup/cp2') diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java index b31d0e72e..4261b763a 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java @@ -131,6 +131,7 @@ public final class Cp2PhoneLookup implements PhoneLookup { private boolean isDirtyInternal(ImmutableSet phoneNumbers) { long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L); + // TODO(zachh): If a number got disassociated with a contact; the contactIds will be empty. return contactsUpdated(queryPhoneTableForContactIds(phoneNumbers), lastModified) || contactsDeleted(lastModified); } @@ -253,6 +254,11 @@ public final class Cp2PhoneLookup implements PhoneLookup { () -> getMostRecentPhoneLookupInfoInternal(existingInfoMap)); } + @Override + public void copySubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source) { + destination.setCp2Info(source.getCp2Info()); + } + private ImmutableMap getMostRecentPhoneLookupInfoInternal( ImmutableMap existingInfoMap) { currentLastTimestampProcessed = null; -- cgit v1.2.3