• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.dialer.calllog;
18 
19 import android.content.Context;
20 import com.android.dialer.calllog.datasources.CallLogDataSource;
21 import com.android.dialer.calllog.datasources.DataSources;
22 import com.android.dialer.common.LogUtil;
23 import com.android.dialer.configprovider.ConfigProviderBindings;
24 import javax.inject.Inject;
25 import javax.inject.Singleton;
26 
27 /**
28  * Coordinates work across {@link DataSources}.
29  *
30  * <p>All methods should be called on the main thread.
31  */
32 @Singleton
33 public final class CallLogFramework {
34 
35   private final DataSources dataSources;
36 
37   @Inject
CallLogFramework(DataSources dataSources)38   CallLogFramework(DataSources dataSources) {
39     this.dataSources = dataSources;
40   }
41 
42   /** Registers the content observers for all data sources. */
registerContentObservers(Context appContext)43   public void registerContentObservers(Context appContext) {
44     LogUtil.enterBlock("CallLogFramework.registerContentObservers");
45 
46     // This is the same condition used in MainImpl#isNewUiEnabled. It means that bugfood/debug
47     // users will have "new call log" content observers firing. These observers usually do simple
48     // things like writing shared preferences.
49     // TODO(zachh): Find a way to access Main#isNewUiEnabled without creating a circular dependency.
50     if (ConfigProviderBindings.get(appContext).getBoolean("is_nui_shortcut_enabled", false)) {
51       for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) {
52         dataSource.registerContentObservers(appContext);
53       }
54     } else {
55       LogUtil.i("CallLogFramework.registerContentObservers", "not registering content observers");
56     }
57   }
58 }
59