1 /* 2 * Copyright (C) 2017 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.tuner; 18 19 import static com.android.tv.common.feature.FeatureUtils.OFF; 20 21 import android.content.Context; 22 import android.text.TextUtils; 23 import android.util.Log; 24 import com.android.tv.common.BaseApplication; 25 import com.android.tv.common.config.api.RemoteConfig; 26 import com.android.tv.common.feature.CommonFeatures; 27 import com.android.tv.common.feature.Feature; 28 import com.android.tv.common.feature.Model; 29 import com.android.tv.common.feature.PropertyFeature; 30 import com.android.tv.common.util.CommonUtils; 31 import com.android.tv.common.util.LocationUtils; 32 import java.util.Locale; 33 34 /** 35 * List of {@link Feature} for Tuner. 36 * 37 * <p>Remove the {@code Feature} once it is launched. 38 */ 39 public class TunerFeatures extends CommonFeatures { 40 private static final String TAG = "TunerFeatures"; 41 private static final boolean DEBUG = false; 42 43 /** Use network tuner if it is available and there is no other tuner types. */ 44 public static final Feature NETWORK_TUNER = 45 new Feature() { 46 @Override 47 public boolean isEnabled(Context context) { 48 if (!TUNER.isEnabled(context)) { 49 return false; 50 } 51 if (CommonUtils.isDeveloper()) { 52 // Network tuner will be enabled for developers. 53 return true; 54 } 55 return Locale.US 56 .getCountry() 57 .equalsIgnoreCase(LocationUtils.getCurrentCountry(context)); 58 } 59 }; 60 61 /** 62 * USE_SW_CODEC_FOR_SD 63 * 64 * <p>Prefer software based codec for SD channels. 65 */ 66 public static final Feature USE_SW_CODEC_FOR_SD = 67 PropertyFeature.create( 68 "use_sw_codec_for_sd", 69 false 70 ); 71 72 /** Use AC3 software decode. */ 73 public static final Feature AC3_SOFTWARE_DECODE = 74 new Feature() { 75 private final String[] SUPPORTED_REGIONS = {}; 76 77 private Boolean mEnabled; 78 79 @Override 80 public boolean isEnabled(Context context) { 81 if (mEnabled == null) { 82 if (mEnabled == null) { 83 // We will not cache the result of fallback solution. 84 String country = LocationUtils.getCurrentCountry(context); 85 for (int i = 0; i < SUPPORTED_REGIONS.length; ++i) { 86 if (SUPPORTED_REGIONS[i].equalsIgnoreCase(country)) { 87 return true; 88 } 89 } 90 if (DEBUG) Log.d(TAG, "AC3 flag false after country check"); 91 return false; 92 } 93 } 94 if (DEBUG) Log.d(TAG, "AC3 flag " + mEnabled); 95 return mEnabled; 96 } 97 }; 98 99 /** Enable Dvb parsers and listeners. */ 100 public static final Feature ENABLE_FILE_DVB = OFF; 101 102 private TunerFeatures() {} 103 } 104