• 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 package com.android.tv;
17 
18 import android.content.Context;
19 import android.util.Log;
20 
21 /** Initializes TvApplication. */
22 public interface Starter {
23 
24     /**
25      * Initializes TvApplication.
26      *
27      * <p>Note: it should be called at the beginning of any Service.onCreate, Activity.onCreate, or
28      * BroadcastReceiver.onCreate.
29      */
start(Context context)30     static void start(Context context) {
31         // TODO(b/63064354) TvApplication should not have to know if it is "the main process"
32         if (context.getApplicationContext() instanceof Starter) {
33             Starter starter = (Starter) context.getApplicationContext();
34             starter.start();
35         } else {
36             // Application context can be MockTvApplication.
37             Log.w("Start", "It is not a context of TvApplication");
38         }
39     }
40 
start()41     void start();
42 }
43