diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-17 20:26:48 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-17 20:26:48 +0000 |
commit | b68ae2c635fe039463499c03be5e71dc2d046b7d (patch) | |
tree | 9e7ee23475307895f1862b1c1fc5cbb9a5731a86 /java/com/android/dialer/calllog | |
parent | 81acc3f02a35648cf7843683beea4feaccc0cd24 (diff) | |
parent | 31e83f3eb7e6ce06c7fb93b621f6086e7d5cd8c2 (diff) |
Merge "Replace PhoneLookupSelector with PhoneLookupInfoConsolidator."
Diffstat (limited to 'java/com/android/dialer/calllog')
-rw-r--r-- | java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java | 30 | ||||
-rw-r--r-- | java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java | 33 |
2 files changed, 34 insertions, 29 deletions
diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index b73c169b9..1d4a35a6c 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -37,11 +37,12 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.common.concurrent.Annotations.LightweightExecutor; +import com.android.dialer.inject.ApplicationContext; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; +import com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract.PhoneLookupHistory; -import com.android.dialer.phonelookup.selector.PhoneLookupSelector; import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -67,8 +68,8 @@ import javax.inject.Inject; public final class PhoneLookupDataSource implements CallLogDataSource, PhoneLookup.ContentObserverCallbacks { + private final Context appContext; private final PhoneLookup<PhoneLookupInfo> phoneLookup; - private final PhoneLookupSelector phoneLookupSelector; private final ListeningExecutorService backgroundExecutorService; private final ListeningExecutorService lightweightExecutorService; @@ -94,11 +95,11 @@ public final class PhoneLookupDataSource @Inject PhoneLookupDataSource( PhoneLookup<PhoneLookupInfo> phoneLookup, - PhoneLookupSelector phoneLookupSelector, + @ApplicationContext Context appContext, @BackgroundExecutor ListeningExecutorService backgroundExecutorService, @LightweightExecutor ListeningExecutorService lightweightExecutorService) { this.phoneLookup = phoneLookup; - this.phoneLookupSelector = phoneLookupSelector; + this.appContext = appContext; this.backgroundExecutorService = backgroundExecutorService; this.lightweightExecutorService = lightweightExecutorService; } @@ -579,19 +580,20 @@ public final class PhoneLookupDataSource } private void updateContentValues(ContentValues contentValues, PhoneLookupInfo phoneLookupInfo) { + PhoneLookupInfoConsolidator phoneLookupInfoConsolidator = + new PhoneLookupInfoConsolidator(appContext, phoneLookupInfo); contentValues.put( AnnotatedCallLog.NUMBER_ATTRIBUTES, NumberAttributes.newBuilder() - .setName(phoneLookupSelector.selectName(phoneLookupInfo)) - .setPhotoUri(phoneLookupSelector.selectPhotoUri(phoneLookupInfo)) - .setPhotoId(phoneLookupSelector.selectPhotoId(phoneLookupInfo)) - .setLookupUri(phoneLookupSelector.selectLookupUri(phoneLookupInfo)) - .setNumberTypeLabel(phoneLookupSelector.selectNumberLabel(phoneLookupInfo)) - .setIsBusiness(phoneLookupSelector.selectIsBusiness(phoneLookupInfo)) - .setIsVoicemail(phoneLookupSelector.selectIsVoicemail(phoneLookupInfo)) - .setCanReportAsInvalidNumber( - phoneLookupSelector.canReportAsInvalidNumber(phoneLookupInfo)) - .setIsCp2InfoIncomplete(phoneLookupSelector.selectIsCp2InfoIncomplete(phoneLookupInfo)) + .setName(phoneLookupInfoConsolidator.getName()) + .setPhotoUri(phoneLookupInfoConsolidator.getPhotoUri()) + .setPhotoId(phoneLookupInfoConsolidator.getPhotoId()) + .setLookupUri(phoneLookupInfoConsolidator.getLookupUri()) + .setNumberTypeLabel(phoneLookupInfoConsolidator.getNumberLabel()) + .setIsBusiness(phoneLookupInfoConsolidator.isBusiness()) + .setIsVoicemail(phoneLookupInfoConsolidator.isVoicemail()) + .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) + .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isCp2LocalInfoIncomplete()) .build() .toByteArray()); } diff --git a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java index 393482ab0..6e214edc4 100644 --- a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java +++ b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog.ui; +import android.content.Context; import android.support.annotation.MainThread; import android.util.ArrayMap; import com.android.dialer.DialerPhoneNumber; @@ -23,10 +24,11 @@ import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.common.Assert; import com.android.dialer.common.concurrent.Annotations.Ui; +import com.android.dialer.inject.ApplicationContext; import com.android.dialer.phonelookup.PhoneLookupInfo; import com.android.dialer.phonelookup.PhoneLookupInfo.Cp2Info; +import com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator; import com.android.dialer.phonelookup.cp2.Cp2LocalPhoneLookup; -import com.android.dialer.phonelookup.selector.PhoneLookupSelector; import com.google.common.base.Optional; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -47,20 +49,20 @@ import javax.inject.Inject; */ public final class RealtimeRowProcessor { - private final ListeningExecutorService uiExecutor; + private final Context appContext; private final Cp2LocalPhoneLookup cp2LocalPhoneLookup; - private final PhoneLookupSelector phoneLookupSelector; + private final ListeningExecutorService uiExecutor; private final Map<DialerPhoneNumber, Cp2Info> cache = new ArrayMap<>(); @Inject RealtimeRowProcessor( + @ApplicationContext Context appContext, @Ui ListeningExecutorService uiExecutor, - Cp2LocalPhoneLookup cp2LocalPhoneLookup, - PhoneLookupSelector phoneLookupSelector) { + Cp2LocalPhoneLookup cp2LocalPhoneLookup) { + this.appContext = appContext; this.uiExecutor = uiExecutor; this.cp2LocalPhoneLookup = cp2LocalPhoneLookup; - this.phoneLookupSelector = phoneLookupSelector; } /** @@ -104,19 +106,20 @@ public final class RealtimeRowProcessor { private CoalescedRow applyCp2LocalInfoToRow(Cp2Info cp2Info, CoalescedRow row) { PhoneLookupInfo phoneLookupInfo = PhoneLookupInfo.newBuilder().setCp2LocalInfo(cp2Info).build(); + PhoneLookupInfoConsolidator phoneLookupInfoConsolidator = + new PhoneLookupInfoConsolidator(appContext, phoneLookupInfo); // It is safe to overwrite any existing data because CP2 always has highest priority. return row.toBuilder() .setNumberAttributes( NumberAttributes.newBuilder() - .setName(phoneLookupSelector.selectName(phoneLookupInfo)) - .setPhotoUri(phoneLookupSelector.selectPhotoUri(phoneLookupInfo)) - .setPhotoId(phoneLookupSelector.selectPhotoId(phoneLookupInfo)) - .setLookupUri(phoneLookupSelector.selectLookupUri(phoneLookupInfo)) - .setNumberTypeLabel(phoneLookupSelector.selectNumberLabel(phoneLookupInfo)) - .setIsBusiness(phoneLookupSelector.selectIsBusiness(phoneLookupInfo)) - .setIsVoicemail(phoneLookupSelector.selectIsVoicemail(phoneLookupInfo)) - .setCanReportAsInvalidNumber( - phoneLookupSelector.canReportAsInvalidNumber(phoneLookupInfo)) + .setName(phoneLookupInfoConsolidator.getName()) + .setPhotoUri(phoneLookupInfoConsolidator.getPhotoUri()) + .setPhotoId(phoneLookupInfoConsolidator.getPhotoId()) + .setLookupUri(phoneLookupInfoConsolidator.getLookupUri()) + .setNumberTypeLabel(phoneLookupInfoConsolidator.getNumberLabel()) + .setIsBusiness(phoneLookupInfoConsolidator.isBusiness()) + .setIsVoicemail(phoneLookupInfoConsolidator.isVoicemail()) + .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) .build()) .build(); } |