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