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