diff options
Diffstat (limited to 'java')
7 files changed, 109 insertions, 83 deletions
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index 3898d1f24..794b759f2 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -197,6 +197,7 @@ public class PhoneCallDetailsHelper views.voicemailTranscriptionView.setText(transcript); if (showRatingPrompt) { views.voicemailTranscriptionBrandingView.setVisibility(View.GONE); + views.voicemailTranscriptionBrandingView.setText(branding); View ratingView = views.voicemailTranscriptionRatingView; ratingView.setVisibility(View.VISIBLE); diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 042ff30a2..56e909e84 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -65,7 +65,7 @@ import javax.inject.Inject; */ public final class PhoneLookupDataSource implements CallLogDataSource { - private final PhoneLookup phoneLookup; + private final PhoneLookup<PhoneLookupInfo> phoneLookup; private final ListeningExecutorService backgroundExecutorService; private final ListeningExecutorService lightweightExecutorService; @@ -88,7 +88,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { @Inject PhoneLookupDataSource( - PhoneLookup phoneLookup, + PhoneLookup<PhoneLookupInfo> phoneLookup, @BackgroundExecutor ListeningExecutorService backgroundExecutorService, @LightweightExecutor ListeningExecutorService lightweightExecutorService) { this.phoneLookup = phoneLookup; @@ -123,8 +123,8 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * provided mutations. (Note that at this point, data may not be fully up-to-date, but the * next steps will take care of that.) * <li>Uses all of the numbers from AnnotatedCallLog to invoke (composite) {@link - * PhoneLookup#getMostRecentPhoneLookupInfo(ImmutableMap)} - * <li>Looks through the results of getMostRecentPhoneLookupInfo + * PhoneLookup#getMostRecentInfo(ImmutableMap)} + * <li>Looks through the results of getMostRecentInfo * <ul> * <li>For each number, checks if the original PhoneLookupInfo differs from the new one * <li>If so, it applies the update to the mutations and (in onSuccessfulFill) writes the @@ -155,9 +155,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { // Use the original info map to generate the updated info map by delegating to phoneLookup. ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> updatedInfoMapFuture = Futures.transformAsync( - originalInfoMapFuture, - phoneLookup::getMostRecentPhoneLookupInfo, - lightweightExecutorService); + originalInfoMapFuture, phoneLookup::getMostRecentInfo, lightweightExecutorService); // This is the computation that will use the result of all of the above. Callable<ImmutableMap<Long, PhoneLookupInfo>> computeRowsToUpdate = 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. * * <p>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<T> { /** - * Returns a future containing a new {@link PhoneLookupInfo} for the provided call. + * Returns a future containing a new info for the provided call. * * <p>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<PhoneLookupInfo> lookup(@NonNull Call call); + ListenableFuture<T> 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}. * * <p>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<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> getMostRecentPhoneLookupInfo( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap); + ListenableFuture<ImmutableMap<DialerPhoneNumber, T>> getMostRecentInfo( + ImmutableMap<DialerPhoneNumber, T> 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. * * <p>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<Void> onSuccessfulBulkUpdate(); } diff --git a/java/com/android/dialer/phonelookup/PhoneLookupComponent.java b/java/com/android/dialer/phonelookup/PhoneLookupComponent.java index 6d1f9a2fc..f59886bcd 100644 --- a/java/com/android/dialer/phonelookup/PhoneLookupComponent.java +++ b/java/com/android/dialer/phonelookup/PhoneLookupComponent.java @@ -23,7 +23,7 @@ import dagger.Subcomponent; @Subcomponent public abstract class PhoneLookupComponent { - public abstract PhoneLookup phoneLookup(); + public abstract PhoneLookup<PhoneLookupInfo> phoneLookup(); public static PhoneLookupComponent get(Context context) { return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) diff --git a/java/com/android/dialer/phonelookup/PhoneLookupModule.java b/java/com/android/dialer/phonelookup/PhoneLookupModule.java index 39b0a5083..8a590052d 100644 --- a/java/com/android/dialer/phonelookup/PhoneLookupModule.java +++ b/java/com/android/dialer/phonelookup/PhoneLookupModule.java @@ -32,7 +32,8 @@ public abstract class PhoneLookupModule { } @Provides - static PhoneLookup providePhoneLookup(CompositePhoneLookup compositePhoneLookup) { + static PhoneLookup<PhoneLookupInfo> providePhoneLookup( + CompositePhoneLookup compositePhoneLookup) { return compositePhoneLookup; } } diff --git a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java index bb7856fff..da4378bb7 100644 --- a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java +++ b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java @@ -28,18 +28,20 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import java.util.ArrayList; import java.util.List; +import java.util.Map; import javax.inject.Inject; /** * {@link PhoneLookup} which delegates to a configured set of {@link PhoneLookup PhoneLookups}, * iterating, prioritizing, and coalescing data as necessary. */ -public final class CompositePhoneLookup implements PhoneLookup { +public final class CompositePhoneLookup implements PhoneLookup<PhoneLookupInfo> { private final ImmutableList<PhoneLookup> phoneLookups; private final ListeningExecutorService lightweightExecutorService; @@ -58,20 +60,22 @@ public final class CompositePhoneLookup implements PhoneLookup { * <p>Note: If any of the dependent lookups fails, the returned future will also fail. If any of * the dependent lookups does not complete, the returned future will also not complete. */ + @SuppressWarnings("unchecked") @Override public ListenableFuture<PhoneLookupInfo> lookup(@NonNull Call call) { // TODO(zachh): Add short-circuiting logic so that this call is not blocked on low-priority // lookups finishing when a higher-priority one has already finished. - List<ListenableFuture<PhoneLookupInfo>> futures = new ArrayList<>(); - for (PhoneLookup phoneLookup : phoneLookups) { + List<ListenableFuture<?>> futures = new ArrayList<>(); + for (PhoneLookup<?> phoneLookup : phoneLookups) { futures.add(phoneLookup.lookup(call)); } return Futures.transform( Futures.allAsList(futures), infos -> { PhoneLookupInfo.Builder mergedInfo = PhoneLookupInfo.newBuilder(); - for (PhoneLookupInfo info : infos) { - mergedInfo.mergeFrom(info); + for (int i = 0; i < infos.size(); i++) { + PhoneLookup phoneLookup = phoneLookups.get(i); + phoneLookup.setSubMessage(mergedInfo, infos.get(i)); } return mergedInfo.build(); }, @@ -81,7 +85,7 @@ public final class CompositePhoneLookup implements PhoneLookup { @Override public ListenableFuture<Boolean> isDirty(ImmutableSet<DialerPhoneNumber> phoneNumbers) { List<ListenableFuture<Boolean>> futures = new ArrayList<>(); - for (PhoneLookup phoneLookup : phoneLookups) { + for (PhoneLookup<?> phoneLookup : phoneLookups) { futures.add(phoneLookup.isDirty(phoneNumbers)); } // Executes all child lookups (possibly in parallel), completing when the first composite lookup @@ -96,14 +100,13 @@ public final class CompositePhoneLookup implements PhoneLookup { * <p>Note: If any of the dependent lookups fails, the returned future will also fail. If any of * the dependent lookups does not complete, the returned future will also not complete. */ + @SuppressWarnings("unchecked") @Override - public ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> - getMostRecentPhoneLookupInfo( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap) { - List<ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>>> futures = - new ArrayList<>(); + public ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> getMostRecentInfo( + ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap) { + List<ListenableFuture<ImmutableMap<DialerPhoneNumber, ?>>> futures = new ArrayList<>(); for (PhoneLookup phoneLookup : phoneLookups) { - futures.add(phoneLookup.getMostRecentPhoneLookupInfo(existingInfoMap)); + futures.add(buildSubmapAndGetMostRecentInfo(existingInfoMap, phoneLookup)); } return Futures.transform( Futures.allAsList(futures), @@ -113,14 +116,14 @@ public final class CompositePhoneLookup implements PhoneLookup { for (DialerPhoneNumber dialerPhoneNumber : existingInfoMap.keySet()) { PhoneLookupInfo.Builder combinedInfo = PhoneLookupInfo.newBuilder(); for (int i = 0; i < allMaps.size(); i++) { - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> map = allMaps.get(i); - PhoneLookupInfo subInfo = map.get(dialerPhoneNumber); + ImmutableMap<DialerPhoneNumber, ?> map = allMaps.get(i); + Object subInfo = map.get(dialerPhoneNumber); if (subInfo == null) { throw new IllegalStateException( "A sublookup didn't return an info for number: " + LogUtil.sanitizePhoneNumber(dialerPhoneNumber.getRawInput().getNumber())); } - phoneLookups.get(i).copySubMessage(combinedInfo, subInfo); + phoneLookups.get(i).setSubMessage(combinedInfo, subInfo); } combinedMap.put(dialerPhoneNumber, combinedInfo.build()); } @@ -129,15 +132,33 @@ public final class CompositePhoneLookup implements PhoneLookup { lightweightExecutorService); } + private <T> ListenableFuture<ImmutableMap<DialerPhoneNumber, T>> buildSubmapAndGetMostRecentInfo( + ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap, + PhoneLookup<T> phoneLookup) { + Map<DialerPhoneNumber, T> submap = + Maps.transformEntries( + existingInfoMap, + (dialerPhoneNumber, phoneLookupInfo) -> + phoneLookup.getSubMessage(existingInfoMap.get(dialerPhoneNumber))); + return phoneLookup.getMostRecentInfo(ImmutableMap.copyOf(submap)); + } + @Override - public void copySubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source) { - throw new UnsupportedOperationException(); + public void setSubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source) { + throw new UnsupportedOperationException( + "This method is only expected to be called by CompositePhoneLookup itself"); + } + + @Override + public PhoneLookupInfo getSubMessage(PhoneLookupInfo phoneLookupInfo) { + throw new UnsupportedOperationException( + "This method is only expected to be called by CompositePhoneLookup itself"); } @Override public ListenableFuture<Void> onSuccessfulBulkUpdate() { List<ListenableFuture<Void>> futures = new ArrayList<>(); - for (PhoneLookup phoneLookup : phoneLookups) { + for (PhoneLookup<?> phoneLookup : phoneLookups) { futures.add(phoneLookup.onSuccessfulBulkUpdate()); } return Futures.transform( diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java index a477e035c..60c934ace 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java @@ -53,7 +53,7 @@ import java.util.Set; import javax.inject.Inject; /** PhoneLookup implementation for local contacts. */ -public final class Cp2PhoneLookup implements PhoneLookup { +public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> { private static final String PREF_LAST_TIMESTAMP_PROCESSED = "cp2PhoneLookupLastTimestampProcessed"; @@ -98,14 +98,14 @@ public final class Cp2PhoneLookup implements PhoneLookup { } @Override - public ListenableFuture<PhoneLookupInfo> lookup(Call call) { + public ListenableFuture<Cp2Info> lookup(Call call) { return backgroundExecutorService.submit(() -> lookupInternal(call)); } - private PhoneLookupInfo lookupInternal(Call call) { + private Cp2Info lookupInternal(Call call) { String rawNumber = TelecomCallUtil.getNumber(call); if (TextUtils.isEmpty(rawNumber)) { - return PhoneLookupInfo.getDefaultInstance(); + return Cp2Info.getDefaultInstance(); } Optional<String> e164 = TelecomCallUtil.getE164Number(appContext, call); Set<Cp2ContactInfo> cp2ContactInfos = new ArraySet<>(); @@ -115,15 +115,13 @@ public final class Cp2PhoneLookup implements PhoneLookup { : queryPhoneTableBasedOnRawNumber(CP2_INFO_PROJECTION, ImmutableSet.of(rawNumber))) { if (cursor == null) { LogUtil.w("Cp2PhoneLookup.lookupInternal", "null cursor"); - return PhoneLookupInfo.getDefaultInstance(); + return Cp2Info.getDefaultInstance(); } while (cursor.moveToNext()) { cp2ContactInfos.add(buildCp2ContactInfoFromPhoneCursor(appContext, cursor)); } } - return PhoneLookupInfo.newBuilder() - .setCp2Info(Cp2Info.newBuilder().addAllCp2ContactInfo(cp2ContactInfos)) - .build(); + return Cp2Info.newBuilder().addAllCp2ContactInfo(cp2ContactInfos).build(); } @Override @@ -323,20 +321,23 @@ public final class Cp2PhoneLookup implements PhoneLookup { } @Override - public ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> - getMostRecentPhoneLookupInfo( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap) { - return backgroundExecutorService.submit( - () -> getMostRecentPhoneLookupInfoInternal(existingInfoMap)); + public ListenableFuture<ImmutableMap<DialerPhoneNumber, Cp2Info>> getMostRecentInfo( + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap) { + return backgroundExecutorService.submit(() -> getMostRecentInfoInternal(existingInfoMap)); + } + + @Override + public void setSubMessage(PhoneLookupInfo.Builder destination, Cp2Info subMessage) { + destination.setCp2Info(subMessage); } @Override - public void copySubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source) { - destination.setCp2Info(source.getCp2Info()); + public Cp2Info getSubMessage(PhoneLookupInfo phoneLookupInfo) { + return phoneLookupInfo.getCp2Info(); } - private ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> getMostRecentPhoneLookupInfoInternal( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap) { + private ImmutableMap<DialerPhoneNumber, Cp2Info> getMostRecentInfoInternal( + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap) { currentLastTimestampProcessed = null; long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L); @@ -352,25 +353,23 @@ public final class Cp2PhoneLookup implements PhoneLookup { buildMapForUpdatedOrAddedContacts(existingInfoMap, lastModified, deletedPhoneNumbers); // Start build a new map of updated info. This will replace existing info. - ImmutableMap.Builder<DialerPhoneNumber, PhoneLookupInfo> newInfoMapBuilder = - ImmutableMap.builder(); + ImmutableMap.Builder<DialerPhoneNumber, Cp2Info> newInfoMapBuilder = ImmutableMap.builder(); // For each DialerPhoneNumber in existing info... - for (Entry<DialerPhoneNumber, PhoneLookupInfo> entry : existingInfoMap.entrySet()) { + for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) { DialerPhoneNumber dialerPhoneNumber = entry.getKey(); - PhoneLookupInfo existingInfo = entry.getValue(); + Cp2Info existingInfo = entry.getValue(); // Build off the existing info - PhoneLookupInfo.Builder infoBuilder = PhoneLookupInfo.newBuilder(existingInfo); + Cp2Info.Builder infoBuilder = Cp2Info.newBuilder(existingInfo); // If the contact was updated, replace the Cp2ContactInfo list if (updatedContacts.containsKey(dialerPhoneNumber)) { - infoBuilder.setCp2Info( - Cp2Info.newBuilder().addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber))); + infoBuilder.clear().addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber)); // If it was deleted and not added to a new contact, clear all the CP2 information. } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { - infoBuilder.clearCp2Info(); + infoBuilder.clear(); } // If the DialerPhoneNumber didn't change, add the unchanged existing info. @@ -399,11 +398,11 @@ public final class Cp2PhoneLookup implements PhoneLookup { * the smallest set of dialer phone numbers to query cp2 against. 4. build and return the map of * dialerphonenumbers to their new Cp2ContactInfo * - * @return Map of {@link DialerPhoneNumber} to {@link PhoneLookupInfo} with updated {@link + * @return Map of {@link DialerPhoneNumber} to {@link Cp2Info} with updated {@link * Cp2ContactInfo}. */ private Map<DialerPhoneNumber, Set<Cp2ContactInfo>> buildMapForUpdatedOrAddedContacts( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap, + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, long lastModified, Set<DialerPhoneNumber> deletedPhoneNumbers) { @@ -411,9 +410,9 @@ public final class Cp2PhoneLookup implements PhoneLookup { Set<DialerPhoneNumber> updatedNumbers = new ArraySet<>(); Set<Long> contactIds = new ArraySet<>(); - for (Entry<DialerPhoneNumber, PhoneLookupInfo> entry : existingInfoMap.entrySet()) { + for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) { DialerPhoneNumber dialerPhoneNumber = entry.getKey(); - PhoneLookupInfo existingInfo = entry.getValue(); + Cp2Info existingInfo = entry.getValue(); // If the number was deleted, we need to check if it was added to a new contact. if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { @@ -423,13 +422,13 @@ public final class Cp2PhoneLookup implements PhoneLookup { /// When the PhoneLookupHistory contains no information for a number, because for example the // user just upgraded to the new UI, or cleared data, we need to check for updated info. - if (existingInfo.getCp2Info().getCp2ContactInfoCount() == 0) { + if (existingInfo.getCp2ContactInfoCount() == 0) { updatedNumbers.add(dialerPhoneNumber); } else { // For each Cp2ContactInfo for each existing DialerPhoneNumber... // Store the contact id if it exist, else automatically add the DialerPhoneNumber to our // set of DialerPhoneNumbers we want to update. - for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2Info().getCp2ContactInfoList()) { + for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2ContactInfoList()) { long existingContactId = cp2ContactInfo.getContactId(); if (existingContactId == 0) { // If the number doesn't have a contact id, for various reasons, we need to look up the @@ -609,7 +608,7 @@ public final class Cp2PhoneLookup implements PhoneLookup { /** Returns set of DialerPhoneNumbers that were associated with now deleted contacts. */ private Set<DialerPhoneNumber> getDeletedPhoneNumbers( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap, long lastModified) { + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, long lastModified) { // Build set of all contact IDs from our existing data. We're going to use this set to query // against the DeletedContacts table and see if any of them were deleted. Set<Long> contactIds = findContactIdsIn(existingInfoMap); @@ -621,10 +620,10 @@ public final class Cp2PhoneLookup implements PhoneLookup { } } - private Set<Long> findContactIdsIn(ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> map) { + private Set<Long> findContactIdsIn(ImmutableMap<DialerPhoneNumber, Cp2Info> map) { Set<Long> contactIds = new ArraySet<>(); - for (PhoneLookupInfo info : map.values()) { - for (Cp2ContactInfo cp2ContactInfo : info.getCp2Info().getCp2ContactInfoList()) { + for (Cp2Info info : map.values()) { + for (Cp2ContactInfo cp2ContactInfo : info.getCp2ContactInfoList()) { contactIds.add(cp2ContactInfo.getContactId()); } } @@ -659,7 +658,7 @@ public final class Cp2PhoneLookup implements PhoneLookup { /** Returns set of DialerPhoneNumbers that are associated with deleted contact IDs. */ private Set<DialerPhoneNumber> findDeletedPhoneNumbersIn( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap, Cursor cursor) { + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, Cursor cursor) { int contactIdIndex = cursor.getColumnIndexOrThrow(DeletedContacts.CONTACT_ID); int deletedTimeIndex = cursor.getColumnIndexOrThrow(DeletedContacts.CONTACT_DELETED_TIMESTAMP); Set<DialerPhoneNumber> deletedPhoneNumbers = new ArraySet<>(); @@ -678,10 +677,10 @@ public final class Cp2PhoneLookup implements PhoneLookup { } private static Set<DialerPhoneNumber> findDialerPhoneNumbersContainingContactId( - ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap, long contactId) { + ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, long contactId) { Set<DialerPhoneNumber> matches = new ArraySet<>(); - for (Entry<DialerPhoneNumber, PhoneLookupInfo> entry : existingInfoMap.entrySet()) { - for (Cp2ContactInfo cp2ContactInfo : entry.getValue().getCp2Info().getCp2ContactInfoList()) { + for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) { + for (Cp2ContactInfo cp2ContactInfo : entry.getValue().getCp2ContactInfoList()) { if (cp2ContactInfo.getContactId() == contactId) { matches.add(entry.getKey()); } |