1 /*
2  * Copyright (C) 2015 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.tv;
18 
19 import android.content.Context;
20 
21 import com.android.tv.analytics.Analytics;
22 import com.android.tv.analytics.Tracker;
23 import com.android.tv.common.BaseApplication;
24 import com.android.tv.common.BaseSingletons;
25 import com.android.tv.common.flags.has.HasUiFlags;
26 import com.android.tv.data.ChannelDataManager;
27 import com.android.tv.data.PreviewDataManager;
28 import com.android.tv.data.ProgramDataManager;
29 import com.android.tv.data.epg.EpgReader;
30 import com.android.tv.dvr.DvrDataManager;
31 import com.android.tv.dvr.DvrManager;
32 import com.android.tv.dvr.DvrScheduleManager;
33 import com.android.tv.dvr.DvrWatchedPositionManager;
34 import com.android.tv.dvr.recorder.RecordingScheduler;
35 import com.android.tv.perf.PerformanceMonitor;
36 import com.android.tv.tunerinputcontroller.HasBuiltInTunerManager;
37 import com.android.tv.util.SetupUtils;
38 import com.android.tv.util.TvInputManagerHelper;
39 
40 import dagger.Lazy;
41 
42 import com.android.tv.common.flags.BackendKnobsFlags;
43 
44 import java.util.concurrent.Executor;
45 
46 /** Interface with getters for application scoped singletons. */
47 public interface TvSingletons extends BaseSingletons, HasBuiltInTunerManager, HasUiFlags {
48 
49     /*
50      * Do not add any new methods here.
51      *
52      * To move a getter to Injection.
53      *  1. Make a type injectable @Singleton.
54      *  2. Mark the getter here as deprecated.
55      *  3. Lazily inject the object in TvApplication.
56      *  4. Move easy usages of getters to injection instead.
57      *  5. Delete the method when all usages are migrated.
58      */
59 
60     /**
61      * Returns the @{@link TvSingletons} using the application context.
62      *
63      * @deprecated use injection instead.
64      */
65     @Deprecated
getSingletons(Context context)66     static TvSingletons getSingletons(Context context) {
67         return (TvSingletons) BaseApplication.getSingletons(context);
68     }
69 
getAnalytics()70     Analytics getAnalytics();
71 
handleInputCountChanged()72     void handleInputCountChanged();
73 
74     @Deprecated
getChannelDataManager()75     ChannelDataManager getChannelDataManager();
76 
77     /** @deprecated use injection instead. */
78     @Deprecated
getProgramDataManager()79     ProgramDataManager getProgramDataManager();
80 
getPreviewDataManager()81     PreviewDataManager getPreviewDataManager();
82 
83     /** @deprecated use injection instead. */
84     @Deprecated
getDvrDataManager()85     DvrDataManager getDvrDataManager();
86 
getDvrScheduleManager()87     DvrScheduleManager getDvrScheduleManager();
88 
getDvrManager()89     DvrManager getDvrManager();
90 
getRecordingScheduler()91     RecordingScheduler getRecordingScheduler();
92 
93     /** @deprecated use injection instead. */
94     @Deprecated
getDvrWatchedPositionManager()95     DvrWatchedPositionManager getDvrWatchedPositionManager();
96 
getInputSessionManager()97     InputSessionManager getInputSessionManager();
98 
getTracker()99     Tracker getTracker();
100 
getMainActivityWrapper()101     MainActivityWrapper getMainActivityWrapper();
102 
isRunningInMainProcess()103     boolean isRunningInMainProcess();
104 
105     /** @deprecated use injection instead. */
106     @Deprecated
getPerformanceMonitor()107     PerformanceMonitor getPerformanceMonitor();
108 
109     /** @deprecated use injection instead. */
110     @Deprecated
getTvInputManagerHelper()111     TvInputManagerHelper getTvInputManagerHelper();
112 
providesEpgReader()113     Lazy<EpgReader> providesEpgReader();
114 
115     /** @deprecated use injection instead. */
116     @Deprecated
getSetupUtils()117     SetupUtils getSetupUtils();
118 
119     /** @deprecated use injection instead. */
120     @Deprecated
getDbExecutor()121     Executor getDbExecutor();
122 
getBackendKnobs()123     BackendKnobsFlags getBackendKnobs();
124 }
125