Home | History | Annotate | Download | only in tv
      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 static com.android.tv.common.feature.EngOnlyFeature.ENG_ONLY_FEATURE;
     20 import static com.android.tv.common.feature.FeatureUtils.AND;
     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.OR;
     24 
     25 import android.content.Context;
     26 import android.content.pm.PackageManager;
     27 import android.os.Build;
     28 import android.support.annotation.VisibleForTesting;
     29 import com.android.tv.common.experiments.Experiments;
     30 import com.android.tv.common.feature.CommonFeatures;
     31 import com.android.tv.common.feature.ExperimentFeature;
     32 import com.android.tv.common.feature.Feature;
     33 import com.android.tv.common.feature.FeatureUtils;
     34 import com.android.tv.common.feature.GServiceFeature;
     35 import com.android.tv.common.feature.PropertyFeature;
     36 import com.android.tv.common.feature.Sdk;
     37 import com.android.tv.common.feature.TestableFeature;
     38 import com.android.tv.common.util.PermissionUtils;
     39 
     40 import com.google.android.tv.partner.support.PartnerCustomizations;
     41 
     42 /**
     43  * List of {@link Feature} for the Live TV App.
     44  *
     45  * <p>Remove the {@code Feature} once it is launched.
     46  */
     47 public final class TvFeatures extends CommonFeatures {
     48 
     49     /** When enabled use system setting for turning on analytics. */
     50     public static final Feature ANALYTICS_OPT_IN =
     51             ExperimentFeature.from(Experiments.ENABLE_ANALYTICS_VIA_CHECKBOX);
     52     /** When enabled shows a list of failed recordings */
     53     public static final Feature DVR_FAILED_LIST = ENG_ONLY_FEATURE;
     54     /**
     55      * Analytics that include sensitive information such as channel or program identifiers.
     56      *
     57      * <p>See <a href="http://b/22062676">b/22062676</a>
     58      */
     59     public static final Feature ANALYTICS_V2 = AND(ON, ANALYTICS_OPT_IN);
     60 
     61     public static final Feature EPG_SEARCH =
     62             PropertyFeature.create("feature_tv_use_epg_search", false);
     63 
     64     private static final String GSERVICE_KEY_UNHIDE = "live_channels_unhide";
     65     /** A flag which indicates that LC app is unhidden even when there is no input. */
     66     public static final Feature UNHIDE =
     67             OR(
     68                     new GServiceFeature(GSERVICE_KEY_UNHIDE, false),
     69                     new Feature() {
     70                         @Override
     71                         public boolean isEnabled(Context context) {
     72                             // If LC app runs as non-system app, we unhide the app.
     73                             return !PermissionUtils.hasAccessAllEpg(context);
     74                         }
     75                     });
     76 
     77     public static final Feature PICTURE_IN_PICTURE =
     78             new Feature() {
     79                 private Boolean mEnabled;
     80 
     81                 @Override
     82                 public boolean isEnabled(Context context) {
     83                     if (mEnabled == null) {
     84                         mEnabled =
     85                                 Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
     86                                         && context.getPackageManager()
     87                                                 .hasSystemFeature(
     88                                                         PackageManager.FEATURE_PICTURE_IN_PICTURE);
     89                     }
     90                     return mEnabled;
     91                 }
     92             };
     93 
     94     /** Enable a conflict dialog between currently watched channel and upcoming recording. */
     95     public static final Feature SHOW_UPCOMING_CONFLICT_DIALOG = OFF;
     96 
     97     /** Use input blacklist to disable partner's tuner input. */
     98     public static final Feature USE_PARTNER_INPUT_BLACKLIST = ON;
     99 
    100     @VisibleForTesting
    101     public static final Feature TEST_FEATURE = PropertyFeature.create("test_feature", false);
    102 
    103     private TvFeatures() {}
    104 }
    105