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.FeatureUtils.AND; 20 import static com.android.tv.common.feature.TestableFeature.createTestableFeature; 21 22 import android.content.Context; 23 import android.os.Build; 24 import android.text.TextUtils; 25 import android.util.Log; 26 import com.android.tv.common.config.api.RemoteConfig.HasRemoteConfig; 27 import com.android.tv.common.experiments.Experiments; 28 29 import com.android.tv.common.util.CommonUtils; 30 import com.android.tv.common.util.LocationUtils; 31 32 /** 33 * List of {@link Feature} that affect more than just the Live 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 PropertyFeature.create("force_recording_until_no_space", false); 58 59 public static final Feature TUNER = 60 new Feature() { 61 @Override 62 public boolean isEnabled(Context context) { 63 64 if (CommonUtils.isDeveloper()) { 65 // we enable tuner for developers to test tuner in any platform. 66 return true; 67 } 68 69 // This is special handling just for USB Tuner. 70 // It does not require any N API's but relies on a improvements in N for AC3 71 // support 72 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N; 73 } 74 }; 75 76 /** Show postal code fragment before channel scan. */ 77 public static final Feature ENABLE_CLOUD_EPG_REGION = 78 new Feature() { 79 private final String[] supportedRegions = { 80 }; 81 82 83 @Override 84 public boolean isEnabled(Context context) { 85 if (!Experiments.CLOUD_EPG.get()) { 86 if (DEBUG) Log.d(TAG, "Experiments.CLOUD_EPG is false"); 87 return false; 88 } 89 String country = LocationUtils.getCurrentCountry(context); 90 for (int i = 0; i < supportedRegions.length; i++) { 91 if (supportedRegions[i].equalsIgnoreCase(country)) { 92 return true; 93 } 94 } 95 if (DEBUG) Log.d(TAG, "EPG flag false after country check"); 96 return false; 97 } 98 }; 99 } 100