1 /* 2 * Copyright (C) 2016 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.common.feature; 18 19 import static com.android.tv.common.feature.BuildTypeFeature.ENG_ONLY_FEATURE; 20 import static com.android.tv.common.feature.FeatureUtils.and; 21 import static com.android.tv.common.feature.FeatureUtils.or; 22 import static com.android.tv.common.feature.TestableFeature.createTestableFeature; 23 24 import android.content.Context; 25 import android.util.Log; 26 27 import com.android.tv.common.flags.has.HasCloudEpgFlags; 28 import com.android.tv.common.util.LocationUtils; 29 30 import com.android.tv.common.flags.CloudEpgFlags; 31 32 /** 33 * List of {@link Feature} that affect more than just the TV app. 34 * 35 * <p>Remove the {@code Feature} once it is launched. 36 */ 37 public class CommonFeatures { 38 private static final String TAG = "CommonFeatures"; 39 private static final boolean DEBUG = false; 40 41 /** 42 * DVR 43 * 44 * <p>See <a href="https://goto.google.com/atv-dvr-onepager">go/atv-dvr-onepager</a> 45 * 46 * <p>DVR API is introduced in N, it only works when app runs as a system app. 47 */ 48 public static final TestableFeature DVR = 49 createTestableFeature(and(Sdk.AT_LEAST_N, SystemAppFeature.SYSTEM_APP_FEATURE)); 50 51 /** 52 * ENABLE_RECORDING_REGARDLESS_OF_STORAGE_STATUS 53 * 54 * <p>Enables dvr recording regardless of storage status. 55 */ 56 public static final Feature FORCE_RECORDING_UNTIL_NO_SPACE = 57 DeveloperPreferenceFeature.create("force_recording_until_no_space", false); 58 59 /** Show postal code fragment before channel scan. */ 60 public static final Feature ENABLE_CLOUD_EPG_REGION = 61 or( 62 FlagFeature.from(HasCloudEpgFlags::fromContext, CloudEpgFlags::supportedRegion), 63 new Feature() { 64 private final String[] supportedRegions = { 65 // AOSP_Comment_Out "US", "GB" 66 }; 67 68 @Override 69 public boolean isEnabled(Context context) { 70 String country = LocationUtils.getCurrentCountry(context); 71 for (int i = 0; i < supportedRegions.length; i++) { 72 if (supportedRegions[i].equalsIgnoreCase(country)) { 73 return true; 74 } 75 } 76 if (DEBUG) Log.d(TAG, "EPG flag false after country check"); 77 return false; 78 } 79 }); 80 81 // TODO(b/74197177): remove when UI and API finalized. 82 /** Show channel signal strength. */ 83 public static final Feature TUNER_SIGNAL_STRENGTH = ENG_ONLY_FEATURE; 84 85 /** Use AudioOnlyTvService for audio-only inputs. */ 86 public static final Feature ENABLE_TV_SERVICE = ENG_ONLY_FEATURE; 87 } 88