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.ON;
     22 import static com.android.tv.common.feature.FeatureUtils.OR;
     23 
     24 import android.content.Context;
     25 import android.os.Build;
     26 import android.support.annotation.VisibleForTesting;
     27 import android.support.v4.os.BuildCompat;
     28 
     29 import com.android.tv.common.feature.Feature;
     30 import com.android.tv.common.feature.GServiceFeature;
     31 import com.android.tv.common.feature.PackageVersionFeature;
     32 import com.android.tv.common.feature.PropertyFeature;
     33 import com.android.tv.util.PermissionUtils;
     34 
     35 /**
     36  * List of {@link Feature} for the Live TV App.
     37  *
     38  * <p>Remove the {@code Feature} once it is launched.
     39  */
     40 public final class Features {
     41     /**
     42      * UI for opting in to analytics.
     43      *
     44      * <p>Do not turn this on until the splash screen asking existing users to opt-in is launched.
     45      * See <a href="http://b/20228119">b/20228119</a>
     46      */
     47     public static final Feature ANALYTICS_OPT_IN = ENG_ONLY_FEATURE;
     48 
     49     /**
     50      * Analytics that include sensitive information such as channel or program identifiers.
     51      *
     52      * <p>See <a href="http://b/22062676">b/22062676</a>
     53      */
     54     public static final Feature ANALYTICS_V2 = AND(ON, ANALYTICS_OPT_IN);
     55 
     56     public static final Feature EPG_SEARCH =
     57             new PropertyFeature("feature_tv_use_epg_search", false);
     58 
     59     public static final Feature USB_TUNER = new Feature() {
     60 
     61         /**
     62          * This is special handling just for USB Tuner.
     63          * It does not require any N API's but relies on a improvements in N for AC3 support
     64          * After release, change class to this to just be
     65          * {@link BuildCompat#isAtLeastN()}.
     66          */
     67         @Override
     68         public boolean isEnabled(Context context) {
     69             return Build.VERSION.SDK_INT > Build.VERSION_CODES.M || BuildCompat.isAtLeastN();
     70         }
     71 
     72     };
     73 
     74     private static final String PLAY_STORE_PACKAGE_NAME = "com.android.vending";
     75     private static final int PLAY_STORE_ZIMA_VERSION_CODE = 80441186;
     76     private static final Feature PLAY_STORE_LINK =
     77             new PackageVersionFeature(PLAY_STORE_PACKAGE_NAME, PLAY_STORE_ZIMA_VERSION_CODE);
     78 
     79     public static final Feature ONBOARDING_PLAY_STORE = PLAY_STORE_LINK;
     80 
     81     /**
     82      * A flag which indicates that the on-boarding experience is used or not.
     83      *
     84      * <p>See <a href="http://b/24070322">b/24070322</a>
     85      */
     86     public static final Feature ONBOARDING_EXPERIENCE = ONBOARDING_PLAY_STORE;
     87 
     88     private static final String GSERVICE_KEY_UNHIDE = "live_channels_unhide";
     89     /**
     90      * A flag which indicates that LC app is unhidden even when there is no input.
     91      */
     92     public static final Feature UNHIDE = AND(ONBOARDING_EXPERIENCE,
     93             OR(new GServiceFeature(GSERVICE_KEY_UNHIDE, false), new Feature() {
     94                 @Override
     95                 public boolean isEnabled(Context context) {
     96                     // If LC app runs as non-system app, we unhide the app.
     97                     return !PermissionUtils.hasAccessAllEpg(context);
     98                 }
     99             }));
    100 
    101     @VisibleForTesting
    102     public static Feature TEST_FEATURE = new PropertyFeature("test_feature", false);
    103 
    104     public static final Feature FETCH_EPG = new PropertyFeature("live_channels_fetch_epg", false);
    105 
    106     private Features() {
    107     }
    108 }
    109