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 31 import com.android.tv.R; 32 import com.android.tv.common.feature.CommonFeatures; 33 import com.android.tv.common.feature.Feature; 34 import com.android.tv.common.feature.FeatureUtils; 35 import com.android.tv.common.feature.FlagFeature; 36 import com.android.tv.common.feature.ResourceConfigFeature; 37 import com.android.tv.common.feature.Sdk; 38 import com.android.tv.common.feature.TestableFeature; 39 import com.android.tv.common.flags.has.HasUiFlags; 40 import com.android.tv.common.singletons.HasSingletons; 41 import com.android.tv.common.util.PermissionUtils; 42 43 /** 44 * List of {@link Feature} for the TV app. 45 * 46 * <p>Remove the {@code Feature} once it is launched. 47 */ 48 public final class TvFeatures extends CommonFeatures { 49 50 /** When enabled store network affiliation information to TV provider */ 51 public static final Feature STORE_NETWORK_AFFILIATION = ENG_ONLY_FEATURE; 52 53 private static final Feature TV_PROVIDER_ALLOWS_INSERT_TO_PROGRAM_TABLE = 54 or(Sdk.AT_LEAST_O, PartnerFeatures.TVPROVIDER_ALLOWS_SYSTEM_INSERTS_TO_PROGRAM_TABLE); 55 56 /** 57 * Enable cloud EPG for third parties. 58 * 59 * @see <a href="http://go/cloud-epg-3p-proposal">go/cloud-epg-3p-proposal</a> 60 */ 61 // TODO verify customization for N 62 public static final TestableFeature CLOUD_EPG_FOR_3RD_PARTY = 63 TestableFeature.createTestableFeature( 64 and( 65 not(ASOP_FEATURE), 66 // TODO(b/66696290): use newer version of robolectric. 67 or( 68 TV_PROVIDER_ALLOWS_INSERT_TO_PROGRAM_TABLE, 69 FeatureUtils.ROBOLECTRIC))); 70 71 // TODO(b/76149661): Fix EPG search or remove it 72 public static final Feature EPG_SEARCH = OFF; 73 74 /** A flag which indicates that LC app is unhidden even when there is no input. */ 75 public static final Feature UNHIDE = 76 or( 77 FlagFeature.from( 78 context -> HasSingletons.get(HasUiFlags.class, context), 79 input -> input.getUiFlags().unhideLauncher()), 80 // If LC app runs as non-system app, we unhide the app. 81 not(PermissionUtils::hasAccessAllEpg)); 82 83 public static final Feature PICTURE_IN_PICTURE = 84 new Feature() { 85 private Boolean mEnabled; 86 87 @Override 88 public boolean isEnabled(Context context) { 89 if (mEnabled == null) { 90 mEnabled = 91 Build.VERSION.SDK_INT >= Build.VERSION_CODES.N 92 && context.getPackageManager() 93 .hasSystemFeature( 94 PackageManager.FEATURE_PICTURE_IN_PICTURE); 95 } 96 return mEnabled; 97 } 98 }; 99 100 /** Enable a conflict dialog between currently watched channel and upcoming recording. */ 101 public static final Feature SHOW_UPCOMING_CONFLICT_DIALOG = OFF; 102 103 /** Use input blocklist to disable partner's tuner input. */ 104 public static final Feature USE_PARTNER_INPUT_BLOCKLIST = ON; 105 106 /** Support for interactive applications using the TIAF **/ 107 public static final Feature HAS_TIAF = Sdk.AT_LEAST_T; 108 109 /** Use new components that are consistent with other Google TV styles b/302992748 */ 110 public static final Feature USE_GTV_LIVETV_V2 = 111 new ResourceConfigFeature(R.bool.use_gtv_livetv_v2, false); 112 TvFeatures()113 private TvFeatures() {} 114 } 115