• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.features;
18 
19 import static com.android.tv.common.feature.BuildTypeFeature.ASOP_FEATURE;
20 import static com.android.tv.common.feature.BuildTypeFeature.ENG_ONLY_FEATURE;
21 import static com.android.tv.common.feature.FeatureUtils.OFF;
22 import static com.android.tv.common.feature.FeatureUtils.ON;
23 import static com.android.tv.common.feature.FeatureUtils.and;
24 import static com.android.tv.common.feature.FeatureUtils.not;
25 import static com.android.tv.common.feature.FeatureUtils.or;
26 
27 import android.content.Context;
28 import android.content.pm.PackageManager;
29 import android.os.Build;
30 import android.support.annotation.VisibleForTesting;
31 import com.android.tv.common.experiments.Experiments;
32 import com.android.tv.common.feature.CommonFeatures;
33 import com.android.tv.common.feature.ExperimentFeature;
34 import com.android.tv.common.feature.Feature;
35 import com.android.tv.common.feature.FeatureUtils;
36 import com.android.tv.common.feature.FlagFeature;
37 import com.android.tv.common.feature.PropertyFeature;
38 import com.android.tv.common.feature.Sdk;
39 import com.android.tv.common.feature.TestableFeature;
40 import com.android.tv.common.flags.has.HasUiFlags;
41 import com.android.tv.common.singletons.HasSingletons;
42 import com.android.tv.common.util.PermissionUtils;
43 
44 /**
45  * List of {@link Feature} for the Live TV App.
46  *
47  * <p>Remove the {@code Feature} once it is launched.
48  */
49 public final class TvFeatures extends CommonFeatures {
50 
51     /** When enabled store network affiliation information to TV provider */
52     public static final Feature STORE_NETWORK_AFFILIATION = ENG_ONLY_FEATURE;
53 
54     /** When enabled use system setting for turning on analytics. */
55     public static final Feature ANALYTICS_OPT_IN =
56             ExperimentFeature.from(Experiments.ENABLE_ANALYTICS_VIA_CHECKBOX);
57     /**
58      * Analytics that include sensitive information such as channel or program identifiers.
59      *
60      * <p>See <a href="http://b/22062676">b/22062676</a>
61      */
62     public static final Feature ANALYTICS_V2 = and(ON, ANALYTICS_OPT_IN);
63 
64     private static final Feature TV_PROVIDER_ALLOWS_INSERT_TO_PROGRAM_TABLE =
65             or(Sdk.AT_LEAST_O, PartnerFeatures.TVPROVIDER_ALLOWS_SYSTEM_INSERTS_TO_PROGRAM_TABLE);
66 
67     /**
68      * Enable cloud EPG for third parties.
69      *
70      * @see <a href="http://go/cloud-epg-3p-proposal">go/cloud-epg-3p-proposal</a>
71      */
72     // TODO verify customization for N
73     public static final TestableFeature CLOUD_EPG_FOR_3RD_PARTY =
74             TestableFeature.createTestableFeature(
75                     and(
76                             not(ASOP_FEATURE),
77                             // TODO(b/66696290): use newer version of robolectric.
78                             or(
79                                     TV_PROVIDER_ALLOWS_INSERT_TO_PROGRAM_TABLE,
80                                     FeatureUtils.ROBOLECTRIC)));
81 
82     // TODO(b/76149661): Fix EPG search or remove it
83     public static final Feature EPG_SEARCH = OFF;
84 
85     /** A flag which indicates that LC app is unhidden even when there is no input. */
86     public static final Feature UNHIDE =
87             or(
88                     FlagFeature.from(
89                             context -> HasSingletons.get(HasUiFlags.class, context),
90                             input -> input.getUiFlags().uhideLauncher()),
91                     // If LC app runs as non-system app, we unhide the app.
92                     not(PermissionUtils::hasAccessAllEpg));
93 
94     public static final Feature PICTURE_IN_PICTURE =
95             new Feature() {
96                 private Boolean mEnabled;
97 
98                 @Override
99                 public boolean isEnabled(Context context) {
100                     if (mEnabled == null) {
101                         mEnabled =
102                                 Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
103                                         && context.getPackageManager()
104                                                 .hasSystemFeature(
105                                                         PackageManager.FEATURE_PICTURE_IN_PICTURE);
106                     }
107                     return mEnabled;
108                 }
109             };
110 
111     /** Enable a conflict dialog between currently watched channel and upcoming recording. */
112     public static final Feature SHOW_UPCOMING_CONFLICT_DIALOG = OFF;
113 
114     /** Use input blacklist to disable partner's tuner input. */
115     public static final Feature USE_PARTNER_INPUT_BLACKLIST = ON;
116 
117     @VisibleForTesting
118     public static final Feature TEST_FEATURE = PropertyFeature.create("test_feature", false);
119 
TvFeatures()120     private TvFeatures() {}
121 }
122