diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-03-22 20:20:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-22 20:20:35 +0000 |
commit | 2aea5b1df52c9f15e551006a46743e792b71cb51 (patch) | |
tree | 10a2be8052ba1ecf4b8ac94d31898dec7df2ada5 /java/com/android/dialer/calllog | |
parent | 6c64810275484ecc554e1e7ab0e0759c01640fe0 (diff) | |
parent | deb440005181e1d18785e2474192142cf1681d54 (diff) |
Merge changes I31e744f3,Ie64d2c6f
* changes:
Use SwitchPreferenceWithClickableSummary instead of SwitchPreference for VM Donation
Removed appContext from CallLogDataSource and PhoneLookup.
Diffstat (limited to 'java/com/android/dialer/calllog')
6 files changed, 56 insertions, 45 deletions
diff --git a/java/com/android/dialer/calllog/CallLogFramework.java b/java/com/android/dialer/calllog/CallLogFramework.java index 365e4d7c0..936f2bbf6 100644 --- a/java/com/android/dialer/calllog/CallLogFramework.java +++ b/java/com/android/dialer/calllog/CallLogFramework.java @@ -63,7 +63,7 @@ public final class CallLogFramework { // TODO(zachh): Find a way to access Main#isNewUiEnabled without creating a circular dependency. if (ConfigProviderBindings.get(appContext).getBoolean("is_nui_shortcut_enabled", false)) { for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { - dataSource.registerContentObservers(appContext); + dataSource.registerContentObservers(); } } else { LogUtil.i("CallLogFramework.registerContentObservers", "not registering content observers"); @@ -80,7 +80,7 @@ public final class CallLogFramework { } for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { - dataSource.unregisterContentObservers(appContext); + dataSource.unregisterContentObservers(); } // Clear data only after all content observers have been disabled. diff --git a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java index c399b05ea..32c278838 100644 --- a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java +++ b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java @@ -154,7 +154,7 @@ public class RefreshAnnotatedCallLogWorker { private ListenableFuture<Boolean> isDirty() { List<ListenableFuture<Boolean>> isDirtyFutures = new ArrayList<>(); for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { - ListenableFuture<Boolean> dataSourceDirty = dataSource.isDirty(appContext); + ListenableFuture<Boolean> dataSourceDirty = dataSource.isDirty(); isDirtyFutures.add(dataSourceDirty); String eventName = String.format(Metrics.IS_DIRTY_TEMPLATE, dataSource.getClass().getSimpleName()); @@ -172,7 +172,7 @@ public class RefreshAnnotatedCallLogWorker { // Start by filling the data sources--the system call log data source must go first! CallLogDataSource systemCallLogDataSource = dataSources.getSystemCallLogDataSource(); - ListenableFuture<Void> fillFuture = systemCallLogDataSource.fill(appContext, mutations); + ListenableFuture<Void> fillFuture = systemCallLogDataSource.fill(mutations); String systemEventName = eventNameForFill(systemCallLogDataSource, isBuilt); futureTimer.applyTiming(fillFuture, systemEventName); @@ -184,7 +184,7 @@ public class RefreshAnnotatedCallLogWorker { Futures.transformAsync( fillFuture, unused -> { - ListenableFuture<Void> dataSourceFuture = dataSource.fill(appContext, mutations); + ListenableFuture<Void> dataSourceFuture = dataSource.fill(mutations); String eventName = eventNameForFill(dataSource, isBuilt); futureTimer.applyTiming(dataSourceFuture, eventName); return dataSourceFuture; @@ -215,7 +215,7 @@ public class RefreshAnnotatedCallLogWorker { List<ListenableFuture<Void>> onSuccessfulFillFutures = new ArrayList<>(); for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { - ListenableFuture<Void> dataSourceFuture = dataSource.onSuccessfulFill(appContext); + ListenableFuture<Void> dataSourceFuture = dataSource.onSuccessfulFill(); onSuccessfulFillFutures.add(dataSourceFuture); String eventName = eventNameForOnSuccessfulFill(dataSource, isBuilt); futureTimer.applyTiming(dataSourceFuture, eventName); diff --git a/java/com/android/dialer/calllog/datasources/CallLogDataSource.java b/java/com/android/dialer/calllog/datasources/CallLogDataSource.java index fa3b6a9df..f6796c767 100644 --- a/java/com/android/dialer/calllog/datasources/CallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/CallLogDataSource.java @@ -17,7 +17,6 @@ package com.android.dialer.calllog.datasources; import android.content.ContentValues; -import android.content.Context; import android.support.annotation.MainThread; import android.support.annotation.WorkerThread; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract; @@ -32,18 +31,17 @@ import java.util.List; * always invoked. * * <ol> - * <li>{@link #isDirty(Context)}: Invoked only if the framework doesn't yet know if a rebuild is + * <li>{@link #isDirty()}: Invoked only if the framework doesn't yet know if a rebuild is * necessary. - * <li>{@link #fill(Context, CallLogMutations)}: Invoked only if the framework determined a - * rebuild is necessary. - * <li>{@link #onSuccessfulFill(Context)}: Invoked if and only if fill was previously called and - * the mutations provided by the previous fill operation succeeded in being applied. + * <li>{@link #fill(CallLogMutations)}: Invoked only if the framework determined a rebuild is + * necessary. + * <li>{@link #onSuccessfulFill()}: Invoked if and only if fill was previously called and the + * mutations provided by the previous fill operation succeeded in being applied. * </ol> * - * <p>Because {@link #isDirty(Context)} is not always invoked, {@link #fill(Context, - * CallLogMutations)} shouldn't rely on any state saved during {@link #isDirty(Context)}. It - * <em>is</em> safe to assume that {@link #onSuccessfulFill(Context)} refers to the previous fill - * operation. + * <p>Because {@link #isDirty()} is not always invoked, {@link #fill(CallLogMutations)} shouldn't + * rely on any state saved during {@link #isDirty()}. It <em>is</em> safe to assume that {@link + * #onSuccessfulFill()} refers to the previous fill operation. * * <p>The same data source objects may be reused across multiple checkDirtyAndRebuild cycles, so * implementors should take care to clear any internal state at the start of a new cycle. @@ -65,7 +63,7 @@ public interface CallLogDataSource { * * @see CallLogDataSource class doc for complete lifecyle information */ - ListenableFuture<Boolean> isDirty(Context appContext); + ListenableFuture<Boolean> isDirty(); /** * Computes the set of mutations necessary to update the annotated call log with respect to this @@ -76,7 +74,7 @@ public interface CallLogDataSource { * contain inserts from the system call log, and these inserts should be modified by each data * source. */ - ListenableFuture<Void> fill(Context appContext, CallLogMutations mutations); + ListenableFuture<Void> fill(CallLogMutations mutations); /** * Called after database mutations have been applied to all data sources. This is useful for @@ -85,7 +83,7 @@ public interface CallLogDataSource { * * @see CallLogDataSource class doc for complete lifecyle information */ - ListenableFuture<Void> onSuccessfulFill(Context appContext); + ListenableFuture<Void> onSuccessfulFill(); /** * Combines raw annotated call log rows into a single coalesced row. @@ -104,10 +102,10 @@ public interface CallLogDataSource { ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc); @MainThread - void registerContentObservers(Context appContext); + void registerContentObservers(); @MainThread - void unregisterContentObservers(Context appContext); + void unregisterContentObservers(); /** * Clear any data written by this data source. This is called when the new call log framework has 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). * - * <p>This is state saved between the {@link #fill(Context, CallLogMutations)} and {@link - * #onSuccessfulFill(Context)} operations. + * <p>This is state saved between the {@link CallLogDataSource#fill(CallLogMutations)} and {@link + * CallLogDataSource#onSuccessfulFill()} operations. */ private final Map<String, PhoneLookupInfo> 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. * - * <p>This is state saved between the {@link #fill(Context, CallLogMutations)} and {@link - * #onSuccessfulFill(Context)} operations. + * <p>This is state saved between the {@link CallLogDataSource#fill(CallLogMutations)} and {@link + * CallLogDataSource#onSuccessfulFill()} operations. */ private final Set<String> 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<Boolean> isDirty(Context appContext) { + public ListenableFuture<Boolean> isDirty() { ListenableFuture<ImmutableSet<DialerPhoneNumber>> phoneNumbers = backgroundExecutorService.submit( () -> queryDistinctDialerPhoneNumbersFromAnnotatedCallLog(appContext)); @@ -139,7 +143,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * </ul> */ @Override - public ListenableFuture<Void> fill(Context appContext, CallLogMutations mutations) { + public ListenableFuture<Void> 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<Void> onSuccessfulFill(Context appContext) { + public ListenableFuture<Void> onSuccessfulFill() { // First update and/or delete the appropriate rows in PhoneLookupHistory. ListenableFuture<Void> 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 diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java index e07996177..6fd19dd17 100644 --- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java @@ -52,6 +52,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.compat.android.provider.VoicemailCompat; +import com.android.dialer.inject.ApplicationContext; import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil; import com.android.dialer.storage.Unencrypted; import com.android.dialer.telecom.TelecomUtil; @@ -79,6 +80,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { @VisibleForTesting static final String PREF_LAST_TIMESTAMP_PROCESSED = "systemCallLogLastTimestampProcessed"; + private final Context appContext; private final ListeningExecutorService backgroundExecutorService; private final MarkDirtyObserver markDirtyObserver; private final SharedPreferences sharedPreferences; @@ -88,10 +90,12 @@ public class SystemCallLogDataSource implements CallLogDataSource { @Inject SystemCallLogDataSource( + @ApplicationContext Context appContext, @BackgroundExecutor ListeningExecutorService backgroundExecutorService, MarkDirtyObserver markDirtyObserver, @Unencrypted SharedPreferences sharedPreferences, AnnotatedCallLogDatabaseHelper annotatedCallLogDatabaseHelper) { + this.appContext = appContext; this.backgroundExecutorService = backgroundExecutorService; this.markDirtyObserver = markDirtyObserver; this.sharedPreferences = sharedPreferences; @@ -100,7 +104,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { @MainThread @Override - public void registerContentObservers(Context appContext) { + public void registerContentObservers() { Assert.isMainThread(); LogUtil.enterBlock("SystemCallLogDataSource.registerContentObservers"); @@ -130,7 +134,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { } @Override - public void unregisterContentObservers(Context appContext) { + public void unregisterContentObservers() { appContext.getContentResolver().unregisterContentObserver(markDirtyObserver); } @@ -151,17 +155,17 @@ public class SystemCallLogDataSource implements CallLogDataSource { } @Override - public ListenableFuture<Boolean> isDirty(Context appContext) { + public ListenableFuture<Boolean> isDirty() { return backgroundExecutorService.submit(this::isDirtyInternal); } @Override - public ListenableFuture<Void> fill(Context appContext, CallLogMutations mutations) { - return backgroundExecutorService.submit(() -> fillInternal(appContext, mutations)); + public ListenableFuture<Void> fill(CallLogMutations mutations) { + return backgroundExecutorService.submit(() -> fillInternal(mutations)); } @Override - public ListenableFuture<Void> onSuccessfulFill(Context appContext) { + public ListenableFuture<Void> onSuccessfulFill() { return backgroundExecutorService.submit(this::onSuccessfulFillInternal); } @@ -181,7 +185,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { } @WorkerThread - private Void fillInternal(Context appContext, CallLogMutations mutations) { + private Void fillInternal(CallLogMutations mutations) { Assert.isWorkerThread(); lastTimestampProcessed = null; diff --git a/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java b/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java index 75c05139d..ab9288a1e 100644 --- a/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java +++ b/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java @@ -28,6 +28,7 @@ import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.compat.telephony.TelephonyManagerCompat; +import com.android.dialer.inject.ApplicationContext; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.PermissionsUtil; import com.google.common.util.concurrent.Futures; @@ -41,15 +42,19 @@ import javax.inject.Inject; /** Provide information for whether the call is a call to the voicemail inbox. */ public class VoicemailDataSource implements CallLogDataSource { + private final Context appContext; private final ListeningExecutorService backgroundExecutor; @Inject - VoicemailDataSource(@BackgroundExecutor ListeningExecutorService backgroundExecutor) { + VoicemailDataSource( + @ApplicationContext Context appContext, + @BackgroundExecutor ListeningExecutorService backgroundExecutor) { + this.appContext = appContext; this.backgroundExecutor = backgroundExecutor; } @Override - public ListenableFuture<Boolean> isDirty(Context appContext) { + public ListenableFuture<Boolean> isDirty() { // The isVoicemail status is immutable and permanent. The call will always show as "Voicemail" // even if the SIM is swapped. Dialing the row will result in some unexpected number after a SIM // swap but this is deemed acceptable. @@ -58,7 +63,7 @@ public class VoicemailDataSource implements CallLogDataSource { @Override @SuppressWarnings("missingPermission") - public ListenableFuture<Void> fill(Context appContext, CallLogMutations mutations) { + public ListenableFuture<Void> fill(CallLogMutations mutations) { if (!PermissionsUtil.hasReadPhoneStatePermissions(appContext)) { return Futures.immediateFuture(null); } @@ -94,7 +99,7 @@ public class VoicemailDataSource implements CallLogDataSource { } @Override - public ListenableFuture<Void> onSuccessfulFill(Context appContext) { + public ListenableFuture<Void> onSuccessfulFill() { return Futures.immediateFuture(null); } @@ -107,10 +112,10 @@ public class VoicemailDataSource implements CallLogDataSource { } @Override - public void registerContentObservers(Context appContext) {} + public void registerContentObservers() {} @Override - public void unregisterContentObservers(Context appContext) {} + public void unregisterContentObservers() {} @Override public ListenableFuture<Void> clearData() { |