From 636578906c1ae45a5514059afd8279277c106b9b Mon Sep 17 00:00:00 2001 From: zachh Date: Wed, 21 Mar 2018 15:03:30 -0700 Subject: Removed appContext from CallLogDataSource and PhoneLookup. Impls can access appContext via dagger. Test: existing PiperOrigin-RevId: 189974157 Change-Id: Ie64d2c6f9ba08fc914d3c31f7e014c2beef3ab00 --- .../phonelookup/PhoneLookupDataSource.java | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java') diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 615a457e3..0de987308 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -37,6 +37,7 @@ 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.composite.CompositePhoneLookup; @@ -66,6 +67,7 @@ import javax.inject.Inject; */ public final class PhoneLookupDataSource implements CallLogDataSource { + private final Context appContext; private final CompositePhoneLookup compositePhoneLookup; private final ListeningExecutorService backgroundExecutorService; private final ListeningExecutorService lightweightExecutorService; @@ -73,8 +75,8 @@ public final class PhoneLookupDataSource implements CallLogDataSource { /** * Keyed by normalized number (the primary key for PhoneLookupHistory). * - *

This is state saved between the {@link #fill(Context, CallLogMutations)} and {@link - * #onSuccessfulFill(Context)} operations. + *

This is state saved between the {@link CallLogDataSource#fill(CallLogMutations)} and {@link + * CallLogDataSource#onSuccessfulFill()} operations. */ private final Map phoneLookupHistoryRowsToUpdate = new ArrayMap<>(); @@ -82,8 +84,8 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * Normalized numbers (the primary key for PhoneLookupHistory) which should be deleted from * PhoneLookupHistory. * - *

This is state saved between the {@link #fill(Context, CallLogMutations)} and {@link - * #onSuccessfulFill(Context)} operations. + *

This is state saved between the {@link CallLogDataSource#fill(CallLogMutations)} and {@link + * CallLogDataSource#onSuccessfulFill()} operations. */ private final Set phoneLookupHistoryRowsToDelete = new ArraySet<>(); @@ -91,10 +93,12 @@ public final class PhoneLookupDataSource implements CallLogDataSource { @Inject PhoneLookupDataSource( + @ApplicationContext Context appContext, CompositePhoneLookup compositePhoneLookup, @BackgroundExecutor ListeningExecutorService backgroundExecutorService, @LightweightExecutor ListeningExecutorService lightweightExecutorService, PhoneLookupHistoryDatabaseHelper phoneLookupHistoryDatabaseHelper) { + this.appContext = appContext; this.compositePhoneLookup = compositePhoneLookup; this.backgroundExecutorService = backgroundExecutorService; this.lightweightExecutorService = lightweightExecutorService; @@ -102,7 +106,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { } @Override - public ListenableFuture isDirty(Context appContext) { + public ListenableFuture isDirty() { ListenableFuture> phoneNumbers = backgroundExecutorService.submit( () -> queryDistinctDialerPhoneNumbersFromAnnotatedCallLog(appContext)); @@ -139,7 +143,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * */ @Override - public ListenableFuture fill(Context appContext, CallLogMutations mutations) { + public ListenableFuture fill(CallLogMutations mutations) { LogUtil.v( "PhoneLookupDataSource.fill", "processing mutations (inserts: %d, updates: %d, deletes: %d)", @@ -243,7 +247,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { } @Override - public ListenableFuture onSuccessfulFill(Context appContext) { + public ListenableFuture onSuccessfulFill() { // First update and/or delete the appropriate rows in PhoneLookupHistory. ListenableFuture writePhoneLookupHistory = backgroundExecutorService.submit(() -> writePhoneLookupHistory(appContext)); @@ -296,13 +300,13 @@ public final class PhoneLookupDataSource implements CallLogDataSource { @MainThread @Override - public void registerContentObservers(Context appContext) { - compositePhoneLookup.registerContentObservers(appContext); + public void registerContentObservers() { + compositePhoneLookup.registerContentObservers(); } @Override - public void unregisterContentObservers(Context appContext) { - compositePhoneLookup.unregisterContentObservers(appContext); + public void unregisterContentObservers() { + compositePhoneLookup.unregisterContentObservers(); } @Override -- cgit v1.2.3