• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 package com.android.tv.modules;
17 
18 import android.content.Context;
19 import com.android.tv.MainActivity;
20 import com.android.tv.TvApplication;
21 import com.android.tv.common.concurrent.NamedThreadFactory;
22 import com.android.tv.common.dagger.ApplicationModule;
23 import com.android.tv.common.dagger.annotations.ApplicationContext;
24 import com.android.tv.onboarding.OnboardingActivity;
25 import com.android.tv.util.AsyncDbTask;
26 import com.android.tv.util.TvInputManagerHelper;
27 import dagger.Module;
28 import dagger.Provides;
29 import java.util.concurrent.Executor;
30 import java.util.concurrent.Executors;
31 import javax.inject.Singleton;
32 
33 /** Dagger module for {@link TvApplication}. */
34 @Module(
35         includes = {
36             ApplicationModule.class,
37             TvSingletonsModule.class,
38             MainActivity.Module.class,
39             OnboardingActivity.Module.class
40         })
41 public class TvApplicationModule {
42     private static final NamedThreadFactory THREAD_FACTORY = new NamedThreadFactory("tv-app-db");
43 
44     @Provides
45     @AsyncDbTask.DbExecutor
46     @Singleton
providesDbExecutor()47     Executor providesDbExecutor() {
48         return Executors.newSingleThreadExecutor(THREAD_FACTORY);
49     }
50 
51     @Provides
52     @Singleton
providesTvInputManagerHelper(@pplicationContext Context context)53     TvInputManagerHelper providesTvInputManagerHelper(@ApplicationContext Context context) {
54         TvInputManagerHelper tvInputManagerHelper = new TvInputManagerHelper(context);
55         tvInputManagerHelper.start();
56         return tvInputManagerHelper;
57     }
58 }
59