diff options
author | Live Channels Team <no-reply@google.com> | 2019-04-29 16:08:15 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2019-05-15 08:58:32 -0700 |
commit | bebfebaaf4d82a2907c2bc87c55b2fbd6cdf449d (patch) | |
tree | 2f59be5a5b42559b2eeacaff8bafb5342fb491cb /common | |
parent | c85adda1e306f7f145588c081299a1e393a36b51 (diff) | |
download | TV-bebfebaaf4d82a2907c2bc87c55b2fbd6cdf449d.tar.gz |
Changes imported from Live Channels
- 245843574 CLEANUP: Remove unused fields and methods from TestSingle... by nchalko <nchalko@google.com>
PiperOrigin-RevId: 245843574
Change-Id: I536e4a683efd642e1ff2f9594f6c08b3abc20b1e
Test: m LiveTv
Diffstat (limited to 'common')
43 files changed, 582 insertions, 268 deletions
diff --git a/common/src/com/android/tv/common/BaseApplication.java b/common/src/com/android/tv/common/BaseApplication.java index 45c32567..27e95b7b 100644 --- a/common/src/com/android/tv/common/BaseApplication.java +++ b/common/src/com/android/tv/common/BaseApplication.java @@ -29,7 +29,7 @@ import com.android.tv.common.util.Debug; import com.android.tv.common.util.SystemProperties; import dagger.android.DaggerApplication; -/** The base application class for Live TV applications. */ +/** The base application class for TV applications. */ public abstract class BaseApplication extends DaggerApplication implements BaseSingletons { private RecordingStorageStatusManager mRecordingStorageStatusManager; diff --git a/common/src/com/android/tv/common/BaseSingletons.java b/common/src/com/android/tv/common/BaseSingletons.java index 10530617..c7c94b9d 100644 --- a/common/src/com/android/tv/common/BaseSingletons.java +++ b/common/src/com/android/tv/common/BaseSingletons.java @@ -26,6 +26,8 @@ import com.android.tv.common.util.Clock; public interface BaseSingletons extends HasCloudEpgFlags, HasBuildType, HasConcurrentDvrPlaybackFlags { + /* @deprecated use injection instead. */ + @Deprecated Clock getClock(); RecordingStorageStatusManager getRecordingStorageStatusManager(); diff --git a/common/src/com/android/tv/common/buildtype/BuildTypeModule.java b/common/src/com/android/tv/common/buildtype/BuildTypeModule.java new file mode 100644 index 00000000..43f398d5 --- /dev/null +++ b/common/src/com/android/tv/common/buildtype/BuildTypeModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.tv.common.buildtype; + +import dagger.Module; +import dagger.Provides; +import dagger.Reusable; + +/** Provides BuildType */ +@Module +public class BuildTypeModule { + private static final HasBuildType.BuildType BUILD_TYPE = + BuildTypeFactory.create().getBuildType(); + + @Provides + @Reusable + HasBuildType.BuildType providesBuildType() { + return BUILD_TYPE; + } +} diff --git a/common/src/com/android/tv/common/buildtype/HasBuildType.java b/common/src/com/android/tv/common/buildtype/HasBuildType.java index 7d5677c9..addac07e 100644 --- a/common/src/com/android/tv/common/buildtype/HasBuildType.java +++ b/common/src/com/android/tv/common/buildtype/HasBuildType.java @@ -30,5 +30,7 @@ public interface HasBuildType { PROD } + /** @deprecated use injection instead. */ + @Deprecated BuildType getBuildType(); } diff --git a/common/src/com/android/tv/common/compat/TvInputInfoCompat.java b/common/src/com/android/tv/common/compat/TvInputInfoCompat.java index 685a3ed9..2f06d943 100644 --- a/common/src/com/android/tv/common/compat/TvInputInfoCompat.java +++ b/common/src/com/android/tv/common/compat/TvInputInfoCompat.java @@ -45,13 +45,12 @@ public class TvInputInfoCompat { private final Context mContext; private final TvInputInfo mTvInputInfo; - private final boolean mAudioOnly; + private boolean mAudioOnly; + private boolean mAudioAttributeInit = false; public TvInputInfoCompat(Context context, TvInputInfo tvInputInfo) { mContext = context; mTvInputInfo = tvInputInfo; - // TODO(b/112938832): use tvInputInfo.isAudioOnly() when SDK is updated - mAudioOnly = Boolean.parseBoolean(getExtras().get(ATTRIBUTE_NAME_AUDIO_ONLY)); } public TvInputInfo getTvInputInfo() { @@ -59,6 +58,11 @@ public class TvInputInfoCompat { } public boolean isAudioOnly() { + // TODO(b/112938832): use tvInputInfo.isAudioOnly() when SDK is updated + if (!mAudioAttributeInit) { + mAudioOnly = Boolean.parseBoolean(getExtras().get(ATTRIBUTE_NAME_AUDIO_ONLY)); + mAudioAttributeInit = true; + } return mAudioOnly; } diff --git a/common/src/com/android/tv/common/compat/internal/recording_commands.proto b/common/src/com/android/tv/common/compat/internal/recording_commands.proto index ce59bfa0..c247e781 100644 --- a/common/src/com/android/tv/common/compat/internal/recording_commands.proto +++ b/common/src/com/android/tv/common/compat/internal/recording_commands.proto @@ -19,6 +19,7 @@ // package and should not be used outside it. syntax = "proto3"; + package android.tv.common.compat.internal; option java_outer_classname = "RecordingCommands"; diff --git a/common/src/com/android/tv/common/compat/internal/recording_events.proto b/common/src/com/android/tv/common/compat/internal/recording_events.proto index 68db5ddf..fffa62ab 100644 --- a/common/src/com/android/tv/common/compat/internal/recording_events.proto +++ b/common/src/com/android/tv/common/compat/internal/recording_events.proto @@ -18,6 +18,7 @@ // support new features on older devices. NOTE: this proto is internal to this // package and should not be used outside it. syntax = "proto3"; + package android.tv.common.compat.internal; option java_outer_classname = "RecordingEvents"; @@ -46,4 +47,3 @@ message RecordingStarted { // Recording URI. string uri = 1; } - diff --git a/common/src/com/android/tv/common/compat/internal/tif_commands.proto b/common/src/com/android/tv/common/compat/internal/tif_commands.proto index d5867703..b69d4870 100644 --- a/common/src/com/android/tv/common/compat/internal/tif_commands.proto +++ b/common/src/com/android/tv/common/compat/internal/tif_commands.proto @@ -19,6 +19,7 @@ // package and should not be used outside it. syntax = "proto3"; + package android.tv.common.compat.internal; option java_outer_classname = "Commands"; diff --git a/common/src/com/android/tv/common/compat/internal/tif_events.proto b/common/src/com/android/tv/common/compat/internal/tif_events.proto index 6e71ae11..b15a884a 100644 --- a/common/src/com/android/tv/common/compat/internal/tif_events.proto +++ b/common/src/com/android/tv/common/compat/internal/tif_events.proto @@ -18,6 +18,7 @@ // support new features on older devices. NOTE: this proto is internal to this // package and should not be used outside it. syntax = "proto3"; + package android.tv.common.compat.internal; option java_outer_classname = "Events"; diff --git a/common/src/com/android/tv/common/customization/CustomizationManager.java b/common/src/com/android/tv/common/customization/CustomizationManager.java index 09ecaef8..a888e6b8 100644 --- a/common/src/com/android/tv/common/customization/CustomizationManager.java +++ b/common/src/com/android/tv/common/customization/CustomizationManager.java @@ -97,8 +97,8 @@ public class CustomizationManager { /** * Returns {@code true} if there's a customization package installed and it specifies built-in - * tuner devices are available. The built-in tuner should support DVB API to be recognized by - * Live TV. + * tuner devices are available. The built-in tuner should support DVB API to be recognized by TV + * app. */ public static boolean hasLinuxDvbBuiltInTuner(Context context) { if (sHasLinuxDvbBuiltInTuner == null) { diff --git a/common/src/com/android/tv/common/dagger/ApplicationModule.java b/common/src/com/android/tv/common/dagger/ApplicationModule.java index 4655f777..be9cf885 100644 --- a/common/src/com/android/tv/common/dagger/ApplicationModule.java +++ b/common/src/com/android/tv/common/dagger/ApplicationModule.java @@ -21,8 +21,10 @@ import android.content.Context; import android.os.Looper; import com.android.tv.common.dagger.annotations.ApplicationContext; import com.android.tv.common.dagger.annotations.MainLooper; +import com.android.tv.common.util.Clock; import dagger.Module; import dagger.Provides; +import dagger.Reusable; /** * Provides application-scope qualifiers for the {@link Application}, the application context, and @@ -57,4 +59,10 @@ public final class ApplicationModule { ContentResolver provideContentResolver() { return mApplication.getContentResolver(); } + + @Provides + @Reusable + static Clock providesClock() { + return Clock.SYSTEM; + } } diff --git a/common/src/com/android/tv/common/experiments/ExperimentFlag.java b/common/src/com/android/tv/common/experiments/ExperimentFlag.java deleted file mode 100644 index b8370ad6..00000000 --- a/common/src/com/android/tv/common/experiments/ExperimentFlag.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tv.common.experiments; - -import android.support.annotation.VisibleForTesting; -import com.android.tv.common.BuildConfig; - -import com.google.common.base.Supplier; - -/** Experiments return values based on user, device and other criteria. */ -public final class ExperimentFlag<T> { - - // NOTE: sAllowOverrides IS NEVER USED in the non AOSP version. - private static boolean sAllowOverrides = false; - - @VisibleForTesting - public static void initForTest() { - /* Begin_AOSP_Comment_Out - if (!BuildConfig.AOSP) { - PhenotypeFlag.initForTest(); - return; - } - End_AOSP_Comment_Out */ - sAllowOverrides = true; - } - - /** Returns a boolean experiment */ - public static ExperimentFlag<Boolean> createFlag( -// AOSP_Comment_Out Supplier<Boolean> phenotypeFlag, - boolean defaultValue) { - return new ExperimentFlag<>( -// AOSP_Comment_Out phenotypeFlag, - defaultValue); - } - - private final T mDefaultValue; -// AOSP_Comment_Out private final Supplier<T> mPhenotypeFlag; - -// AOSP_Comment_Out // NOTE: mOverrideValue IS NEVER USED in the non AOSP version. - private T mOverrideValue = null; - // mOverridden IS NEVER USED in the non AOSP version. - private boolean mOverridden = false; - - private ExperimentFlag( -// AOSP_Comment_Out Supplier<T> phenotypeFlag, - // NOTE: defaultValue IS NEVER USED in the non AOSP version. - T defaultValue) { - mDefaultValue = defaultValue; -// AOSP_Comment_Out mPhenotypeFlag = phenotypeFlag; - } - - /** Returns value for this experiment */ - public T get() { - /* Begin_AOSP_Comment_Out - if (!BuildConfig.AOSP) { - return mPhenotypeFlag.get(); - } - End_AOSP_Comment_Out */ - return sAllowOverrides && mOverridden ? mOverrideValue : mDefaultValue; - } - - @VisibleForTesting - public void override(T t) { - - if (sAllowOverrides) { - mOverridden = true; - mOverrideValue = t; - } - } - - @VisibleForTesting - public void resetOverride() { - mOverridden = false; - } - - /* Begin_AOSP_Comment_Out - @VisibleForTesting - T getAospDefaultValueForTesting() { - return mDefaultValue; - } - End_AOSP_Comment_Out */ -} diff --git a/common/src/com/android/tv/common/experiments/Experiments.java b/common/src/com/android/tv/common/experiments/Experiments.java deleted file mode 100644 index 9bfdb547..00000000 --- a/common/src/com/android/tv/common/experiments/Experiments.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tv.common.experiments; - -import static com.android.tv.common.experiments.ExperimentFlag.createFlag; - -import com.android.tv.common.BuildConfig; -// AOSP_Comment_Out import com.android.tv.common.flags.LiveChannels; - -/** - * Set of experiments visible in AOSP. - * - * <p>This file is maintained by hand. - */ -public final class Experiments { - public static final ExperimentFlag<Boolean> ENABLE_UNRATED_CONTENT_SETTINGS = - ExperimentFlag.createFlag( -// AOSP_Comment_Out LiveChannels::enableUnratedContentSettings, - false); - - /** Turn analytics on or off based on the System Checkbox for logging. */ - public static final ExperimentFlag<Boolean> ENABLE_ANALYTICS_VIA_CHECKBOX = - createFlag( -// AOSP_Comment_Out LiveChannels::enableAnalyticsViaCheckbox, - false); - - /** - * Allow developer features such as the dev menu and other aids. - * - * <p>These features are available to select users(aka fishfooders) on production builds. - */ - public static final ExperimentFlag<Boolean> ENABLE_DEVELOPER_FEATURES = - ExperimentFlag.createFlag( -// AOSP_Comment_Out LiveChannels::enableDeveloperFeatures, - BuildConfig.ENG); - - /** - * Allow QA features. - * - * <p>These features must be carefully limited, keeping QA differences to a minimum. - * - * <p>These features are available to select users(aka QA) on production builds. - */ - public static final ExperimentFlag<Boolean> ENABLE_QA_FEATURES = - ExperimentFlag.createFlag( -// AOSP_Comment_Out LiveChannels::enableQaFeatures, - false); - - private Experiments() {} -} diff --git a/common/src/com/android/tv/common/feature/CommonFeatures.java b/common/src/com/android/tv/common/feature/CommonFeatures.java index 04052a7c..f79965bb 100644 --- a/common/src/com/android/tv/common/feature/CommonFeatures.java +++ b/common/src/com/android/tv/common/feature/CommonFeatures.java @@ -28,7 +28,7 @@ import com.android.tv.common.util.LocationUtils; import com.android.tv.common.flags.CloudEpgFlags; /** - * List of {@link Feature} that affect more than just the Live TV app. + * List of {@link Feature} that affect more than just the TV app. * * <p>Remove the {@code Feature} once it is launched. */ diff --git a/common/src/com/android/tv/common/feature/FeatureUtils.java b/common/src/com/android/tv/common/feature/FeatureUtils.java index aaed6c82..e6192cd4 100644 --- a/common/src/com/android/tv/common/feature/FeatureUtils.java +++ b/common/src/com/android/tv/common/feature/FeatureUtils.java @@ -17,7 +17,6 @@ package com.android.tv.common.feature; import android.content.Context; -import com.android.tv.common.BuildConfig; import com.android.tv.common.util.CommonUtils; import java.util.Arrays; @@ -71,23 +70,6 @@ public class FeatureUtils { } }; } - /** - * A feature available in AOSP. - * - * @param googleFeature the feature used in non AOSP builds - * @param aospFeature the feature used in AOSP builds - */ - public static Feature aospFeature( -// AOSP_Comment_Out final Feature googleFeature, - final Feature aospFeature) { - /* Begin_AOSP_Comment_Out - if (!BuildConfig.AOSP) { - return googleFeature; - } else { - End_AOSP_Comment_Out */ - return aospFeature; -// AOSP_Comment_Out } - } /** * Returns a feature that is opposite of the given {@code feature}. diff --git a/common/src/com/android/tv/common/feature/Model.java b/common/src/com/android/tv/common/feature/Model.java index 7aa5148e..450cd216 100644 --- a/common/src/com/android/tv/common/feature/Model.java +++ b/common/src/com/android/tv/common/feature/Model.java @@ -21,10 +21,11 @@ import android.content.Context; /** Holder for {@link android.os.Build#MODEL} features. */ public interface Model { + ModelFeature ARCHER = new ModelFeature("Archer"); ModelFeature NEXUS_PLAYER = new ModelFeature("Nexus Player"); /** True when the {@link android.os.Build#MODEL} equals the {@code model} given. */ - public static final class ModelFeature implements Feature { + final class ModelFeature implements Feature { private final String mModel; private ModelFeature(String model) { diff --git a/common/src/com/android/tv/common/feature/ExperimentFeature.java b/common/src/com/android/tv/common/feature/PermissionFeature.java index 820eda49..02611785 100644 --- a/common/src/com/android/tv/common/feature/ExperimentFeature.java +++ b/common/src/com/android/tv/common/feature/PermissionFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,28 +17,22 @@ package com.android.tv.common.feature; import android.content.Context; -import com.android.tv.common.experiments.ExperimentFlag; +import android.content.pm.PackageManager; -/** A {@link Feature} base on an {@link ExperimentFlag}. */ -public final class ExperimentFeature implements Feature { +/** A feature that is only available when {@code permissionName} is granted. */ +public class PermissionFeature implements Feature { - public static Feature from(ExperimentFlag<Boolean> flag) { - return new ExperimentFeature(flag); - } + public static final PermissionFeature DVB_DEVICE_PERMISSION = + new PermissionFeature("android.permission.DVB_DEVICE"); - private final ExperimentFlag<Boolean> mFlag; + private final String permissionName; - private ExperimentFeature(ExperimentFlag<Boolean> flag) { - mFlag = flag; + private PermissionFeature(String permissionName) { + this.permissionName = permissionName; } @Override public boolean isEnabled(Context context) { - return mFlag.get(); - } - - @Override - public String toString() { - return "ExperimentFeature for " + mFlag; + return context.checkSelfPermission(permissionName) == PackageManager.PERMISSION_GRANTED; } } diff --git a/common/src/com/android/tv/common/flags/CloudEpgFlags.java b/common/src/com/android/tv/common/flags/CloudEpgFlags.java index ab4c6a17..48b950bf 100755 --- a/common/src/com/android/tv/common/flags/CloudEpgFlags.java +++ b/common/src/com/android/tv/common/flags/CloudEpgFlags.java @@ -29,6 +29,6 @@ public interface CloudEpgFlags { /** Is the device in a region supported by Cloud Epg */ boolean supportedRegion(); - /** List of input ids that Live TV will update their EPG. */ + /** List of input ids that the TV app will update their EPG. */ String thirdPartyEpgInputsCsv(); } diff --git a/common/src/com/android/tv/common/flags/DvrFlags.java b/common/src/com/android/tv/common/flags/DvrFlags.java new file mode 100755 index 00000000..3bdd1d69 --- /dev/null +++ b/common/src/com/android/tv/common/flags/DvrFlags.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.tv.common.flags; + +/** DVR flags */ +public interface DvrFlags { + + /** + * Whether or not this feature is compiled into this build. + * + * <p>This returns true by default, unless the is_compiled_selector parameter was set during + * code generation. + */ + boolean compiled(); + + /** Allow user to customize timings of program recordings. */ + boolean startEarlyEndLateEnabled(); +} diff --git a/common/src/com/android/tv/common/flags/LegacyFlags.java b/common/src/com/android/tv/common/flags/LegacyFlags.java new file mode 100755 index 00000000..dbccf702 --- /dev/null +++ b/common/src/com/android/tv/common/flags/LegacyFlags.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.tv.common.flags; + +/** Legacy flags */ +public interface LegacyFlags { + + /** + * Whether or not this feature is compiled into this build. + * + * <p>This returns true by default, unless the is_compiled_selector parameter was set during + * code generation. + */ + boolean compiled(); + + /** Enable Developer Features */ + boolean enableDeveloperFeatures(); + + /** Enable QA Features */ + boolean enableQaFeatures(); + + /** Enable Unrated Content Settings */ + boolean enableUnratedContentSettings(); +} diff --git a/common/src/com/android/tv/common/flags/StartupFlags.java b/common/src/com/android/tv/common/flags/StartupFlags.java new file mode 100755 index 00000000..e6f68370 --- /dev/null +++ b/common/src/com/android/tv/common/flags/StartupFlags.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.tv.common.flags; + +/** Flags for TV App startup */ +public interface StartupFlags { + + /** + * Whether or not this feature is compiled into this build. + * + * <p>This returns true by default, unless the is_compiled_selector parameter was set during + * code generation. + */ + boolean compiled(); + + /** InputId's that will not be warmed up on MainActivity creation. */ + com.android.tv.common.flags.proto.TypedFeatures.StringListParam warmupInputidBlacklist(); +} diff --git a/common/src/com/android/tv/common/flags/TunerFlags.java b/common/src/com/android/tv/common/flags/TunerFlags.java index 5f899b90..5be7b793 100755 --- a/common/src/com/android/tv/common/flags/TunerFlags.java +++ b/common/src/com/android/tv/common/flags/TunerFlags.java @@ -26,9 +26,6 @@ public interface TunerFlags { */ boolean compiled(); - /** Tune using current recording if available. */ - boolean tuneUsingRecording(); - /** Enable using exoplayer V2 */ boolean useExoplayerV2(); } diff --git a/common/src/com/android/tv/common/flags/UiFlags.java b/common/src/com/android/tv/common/flags/UiFlags.java index 4c88d08a..67a98492 100755 --- a/common/src/com/android/tv/common/flags/UiFlags.java +++ b/common/src/com/android/tv/common/flags/UiFlags.java @@ -15,7 +15,7 @@ */ package com.android.tv.common.flags; -/** Flags for Live TV UI */ +/** Flags for TV app UI */ public interface UiFlags { /** @@ -26,6 +26,9 @@ public interface UiFlags { */ boolean compiled(); + /** Critic Ratings */ + boolean enableCriticRatings(); + /** * Number of days to be shown by Recording History. * diff --git a/common/src/com/android/tv/common/flags/impl/DefaultBackendKnobsFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultBackendKnobsFlags.java index a189e473..3d467d24 100644 --- a/common/src/com/android/tv/common/flags/impl/DefaultBackendKnobsFlags.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultBackendKnobsFlags.java @@ -26,7 +26,7 @@ public final class DefaultBackendKnobsFlags @Override public boolean enablePartialProgramFetch() { - return false; + return true; } @Override @@ -36,12 +36,12 @@ public final class DefaultBackendKnobsFlags @Override public boolean fetchProgramsAsNeeded() { - return false; + return true; } @Override public long programGuideInitialFetchHours() { - return 8; + return 4; } @Override diff --git a/common/src/com/android/tv/common/flags/impl/DefaultConcurrentDvrPlaybackFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultConcurrentDvrPlaybackFlags.java index 8d8c584a..fdd62d61 100644 --- a/common/src/com/android/tv/common/flags/impl/DefaultConcurrentDvrPlaybackFlags.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultConcurrentDvrPlaybackFlags.java @@ -27,7 +27,7 @@ public final class DefaultConcurrentDvrPlaybackFlags implements ConcurrentDvrPla @Override public boolean enabled() { - return false; + return true; } @Override diff --git a/common/src/com/android/tv/common/experiments/ExperimentLoader.java b/common/src/com/android/tv/common/flags/impl/DefaultDvrFlags.java index 5f012e11..e0404af8 100644 --- a/common/src/com/android/tv/common/experiments/ExperimentLoader.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultDvrFlags.java @@ -13,16 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.android.tv.common.flags.impl; -package com.android.tv.common.experiments; +/** Flags for tuning non ui behavior. */ +public final class DefaultDvrFlags + implements com.android.tv.common.flags.DvrFlags { -import android.content.Context; - -/** Used to sync {@link ExperimentFlag}s. */ -public class ExperimentLoader { + @Override + public boolean compiled() { + return true; + } - /** Starts a background task to update {@link ExperimentFlag}s */ - public void asyncRefreshExperiments(Context context) { - // Override for your experiment system + @Override + public boolean startEarlyEndLateEnabled() { + return false; } } diff --git a/common/src/com/android/tv/common/flags/impl/DefaultFlagsModule.java b/common/src/com/android/tv/common/flags/impl/DefaultFlagsModule.java index 49352364..2aaf4469 100644 --- a/common/src/com/android/tv/common/flags/impl/DefaultFlagsModule.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultFlagsModule.java @@ -21,6 +21,9 @@ import dagger.Reusable; import com.android.tv.common.flags.BackendKnobsFlags; import com.android.tv.common.flags.CloudEpgFlags; import com.android.tv.common.flags.ConcurrentDvrPlaybackFlags; +import com.android.tv.common.flags.DvrFlags; +import com.android.tv.common.flags.LegacyFlags; +import com.android.tv.common.flags.StartupFlags; import com.android.tv.common.flags.TunerFlags; import com.android.tv.common.flags.UiFlags; @@ -48,6 +51,24 @@ public class DefaultFlagsModule { @Provides @Reusable + DvrFlags provideDvrFlags() { + return new DefaultDvrFlags(); + } + + @Provides + @Reusable + LegacyFlags provideLegacyFlags() { + return DefaultLegacyFlags.DEFAULT; + } + + @Provides + @Reusable + StartupFlags provideStartupFlags() { + return new DefaultStartupFlags(); + } + + @Provides + @Reusable TunerFlags provideTunerFlags() { return new DefaultTunerFlags(); } diff --git a/common/src/com/android/tv/common/flags/impl/DefaultLegacyFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultLegacyFlags.java new file mode 100644 index 00000000..52142416 --- /dev/null +++ b/common/src/com/android/tv/common/flags/impl/DefaultLegacyFlags.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tv.common.flags.impl; + +import com.google.auto.value.AutoValue; +import com.android.tv.common.flags.LegacyFlags; + +/** Default {@link LegacyFlags}. */ +@AutoValue +public abstract class DefaultLegacyFlags implements LegacyFlags { + public static final DefaultLegacyFlags DEFAULT = DefaultLegacyFlags.builder().build(); + + public static Builder builder() { + return new AutoValue_DefaultLegacyFlags.Builder() + .compiled(true) + .enableDeveloperFeatures(false) + .enableQaFeatures(false) + .enableUnratedContentSettings(false); + } + + /** Builder for {@link LegacyFlags} */ + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder compiled(boolean value); + + public abstract Builder enableDeveloperFeatures(boolean value); + + public abstract Builder enableQaFeatures(boolean value); + + public abstract Builder enableUnratedContentSettings(boolean value); + + public abstract DefaultLegacyFlags build(); + } +} diff --git a/common/src/com/android/tv/common/flags/impl/DefaultStartupFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultStartupFlags.java new file mode 100644 index 00000000..48b5a297 --- /dev/null +++ b/common/src/com/android/tv/common/flags/impl/DefaultStartupFlags.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tv.common.flags.impl; + +import com.android.tv.common.flags.proto.TypedFeatures.StringListParam; +import com.android.tv.common.flags.StartupFlags; + +/** Default {@StartupFlags} */ +public class DefaultStartupFlags implements StartupFlags { + @Override + public boolean compiled() { + return true; + } + + @Override + public StringListParam warmupInputidBlacklist() { + return StringListParam.getDefaultInstance(); + } +} diff --git a/common/src/com/android/tv/common/flags/impl/DefaultTunerFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultTunerFlags.java index 195953bc..2d12e368 100644 --- a/common/src/com/android/tv/common/flags/impl/DefaultTunerFlags.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultTunerFlags.java @@ -26,11 +26,6 @@ public class DefaultTunerFlags implements TunerFlags { } @Override - public boolean tuneUsingRecording() { - return false; - } - - @Override public boolean useExoplayerV2() { return false; } diff --git a/common/src/com/android/tv/common/flags/impl/DefaultUiFlags.java b/common/src/com/android/tv/common/flags/impl/DefaultUiFlags.java index fce45853..137615b9 100644 --- a/common/src/com/android/tv/common/flags/impl/DefaultUiFlags.java +++ b/common/src/com/android/tv/common/flags/impl/DefaultUiFlags.java @@ -17,7 +17,7 @@ package com.android.tv.common.flags.impl; import com.android.tv.common.flags.UiFlags; -/** Default Flags for Live TV UI */ +/** Default Flags for TV app UI */ public class DefaultUiFlags implements UiFlags { @Override @@ -26,17 +26,22 @@ public class DefaultUiFlags implements UiFlags { } @Override + public boolean enableCriticRatings() { + return false; + } + + @Override public boolean uhideLauncher() { return false; } @Override public boolean useLeanbackPinPicker() { - return false; + return true; } @Override public long maxHistoryDays() { - return 7; + return 0; } } diff --git a/common/src/com/android/tv/common/flags/impl/SettableFlagsModule.java b/common/src/com/android/tv/common/flags/impl/SettableFlagsModule.java new file mode 100644 index 00000000..b188158c --- /dev/null +++ b/common/src/com/android/tv/common/flags/impl/SettableFlagsModule.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tv.common.flags.impl; + +import dagger.Module; +import dagger.Provides; +import dagger.Reusable; +import com.android.tv.common.flags.BackendKnobsFlags; +import com.android.tv.common.flags.CloudEpgFlags; +import com.android.tv.common.flags.ConcurrentDvrPlaybackFlags; +import com.android.tv.common.flags.DvrFlags; +import com.android.tv.common.flags.LegacyFlags; +import com.android.tv.common.flags.StartupFlags; +import com.android.tv.common.flags.TunerFlags; +import com.android.tv.common.flags.UiFlags; + +/** Provides public fields for each flag so they can be changed before injection. */ +@Module +public class SettableFlagsModule { + + public DefaultBackendKnobsFlags backendKnobsFlags = new DefaultBackendKnobsFlags(); + public DefaultCloudEpgFlags cloudEpgFlags = new DefaultCloudEpgFlags(); + public DefaultConcurrentDvrPlaybackFlags concurrentDvrPlaybackFlags = + new DefaultConcurrentDvrPlaybackFlags(); + public DefaultDvrFlags dvrFlags = new DefaultDvrFlags(); + public DefaultLegacyFlags legacyFlags = DefaultLegacyFlags.DEFAULT; + public DefaultStartupFlags startupFlags = new DefaultStartupFlags(); + public DefaultTunerFlags tunerFlags = new DefaultTunerFlags(); + public DefaultUiFlags uiFlags = new DefaultUiFlags(); + + @Provides + @Reusable + BackendKnobsFlags provideBackendKnobsFlags() { + return backendKnobsFlags; + } + + @Provides + @Reusable + CloudEpgFlags provideCloudEpgFlags() { + return cloudEpgFlags; + } + + @Provides + @Reusable + ConcurrentDvrPlaybackFlags provideConcurrentDvrPlaybackFlags() { + return concurrentDvrPlaybackFlags; + } + + @Provides + @Reusable + DvrFlags provideDvrFlags() { + return dvrFlags; + } + + @Provides + @Reusable + LegacyFlags provideLegacyFlags() { + return legacyFlags; + } + + @Provides + @Reusable + StartupFlags provideStartupFlags() { + return startupFlags; + } + + @Provides + @Reusable + TunerFlags provideTunerFlags() { + return tunerFlags; + } + + @Provides + @Reusable + UiFlags provideUiFlags() { + return uiFlags; + } +} diff --git a/common/src/com/android/tv/common/flags/proto/typed-features.proto b/common/src/com/android/tv/common/flags/proto/typed-features.proto new file mode 100644 index 00000000..855d7311 --- /dev/null +++ b/common/src/com/android/tv/common/flags/proto/typed-features.proto @@ -0,0 +1,20 @@ +syntax = "proto2"; + +package android.tv.common.flags; + +option java_outer_classname = "TypedFeatures"; +option java_package = "com.android.tv.common.flags.proto"; + +// These messages are to specify feature params that are a list of integers. +message Int32ListParam { + repeated int32 element = 1; +} + +message Int64ListParam { + repeated int64 element = 1; +} + +// This message is to specify feature params that are a list of strings. +message StringListParam { + repeated string element = 1; +} diff --git a/common/src/com/android/tv/common/singletons/HasTvInputId.java b/common/src/com/android/tv/common/singletons/HasTvInputId.java index 4bc0a21c..49cf3d2e 100644 --- a/common/src/com/android/tv/common/singletons/HasTvInputId.java +++ b/common/src/com/android/tv/common/singletons/HasTvInputId.java @@ -18,8 +18,8 @@ package com.android.tv.common.singletons; /** * Has TunerInputId. * - * <p>This is used buy both the tuner to get its input id and by the Live TV to get the - * embedded tuner input id. + * <p>This is used buy both the tuner to get its input id and by the TV app to get the embedded + * tuner input id. */ public interface HasTvInputId { diff --git a/common/src/com/android/tv/common/support/tvprovider/README.md b/common/src/com/android/tv/common/support/tvprovider/README.md new file mode 100644 index 00000000..a24dc288 --- /dev/null +++ b/common/src/com/android/tv/common/support/tvprovider/README.md @@ -0,0 +1,6 @@ +## support provider + +This is preview code destined to be put in androidx.tvprovider.media.tv + + +All classes here must have an associated bug to move to androidx diff --git a/common/src/com/android/tv/common/support/tvprovider/TvContractCompatX.java b/common/src/com/android/tv/common/support/tvprovider/TvContractCompatX.java new file mode 100644 index 00000000..353e3421 --- /dev/null +++ b/common/src/com/android/tv/common/support/tvprovider/TvContractCompatX.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tv.common.support.tvprovider; + +import android.net.Uri; +import android.support.annotation.Nullable; +import androidx.tvprovider.media.tv.TvContractCompat; + +/** + * Extensions to the contract between the TV provider and applications. Contains definitions for the + * supported URIs and columns. + * + * <p>TODO(b/126921088): move this to androidx. + */ +public final class TvContractCompatX { + + /** + * Builds a URI that points to a specific channel. + * + * @param inputPackage the package of the input. + * @param internalProviderId the internal provider id + */ + public static Uri buildChannelUri( + @Nullable String inputPackage, @Nullable String internalProviderId) { + Uri.Builder uri = TvContractCompat.Channels.CONTENT_URI.buildUpon(); + if (inputPackage != null) { + uri.appendQueryParameter("package", inputPackage); + } + if (internalProviderId != null) { + uri.appendQueryParameter( + TvContractCompat.Channels.COLUMN_INTERNAL_PROVIDER_ID, internalProviderId); + } + return uri.build(); + } + + /** + * Builds a URI that points to all programs on a given channel. + * + * @param inputPackage the package of the input. + * @param internalProviderId the internal provider id + */ + public static Uri buildProgramsUriForChannel( + @Nullable String inputPackage, @Nullable String internalProviderId) { + Uri.Builder uri = TvContractCompat.Programs.CONTENT_URI.buildUpon(); + if (inputPackage != null) { + uri.appendQueryParameter("package", inputPackage); + } + if (internalProviderId != null) { + uri.appendQueryParameter( + TvContractCompat.Channels.COLUMN_INTERNAL_PROVIDER_ID, internalProviderId); + } + return uri.build(); + } + + /** + * Builds a URI that points to programs on a specific channel whose schedules overlap with the + * given time frame. + * + * @param inputPackage the package of the input. + * @param internalProviderId the internal provider id + * @param startTime The start time used to filter programs. The returned programs should have + * {@link TvContractCompat.Programs#COLUMN_END_TIME_UTC_MILLIS} that is greater than this + * time. + * @param endTime The end time used to filter programs. The returned programs should have {@link + * TvContractCompat.Programs#COLUMN_START_TIME_UTC_MILLIS} that is less than this time. + */ + public static Uri buildProgramsUriForChannel( + @Nullable String inputPackage, + @Nullable String internalProviderId, + long startTime, + long endTime) { + return buildProgramsUriForChannel(inputPackage, internalProviderId) + .buildUpon() + .appendQueryParameter(TvContractCompat.PARAM_START_TIME, String.valueOf(startTime)) + .appendQueryParameter(TvContractCompat.PARAM_END_TIME, String.valueOf(endTime)) + .build(); + } + + /** + * Builds a URI that points to programs whose schedules overlap with the given time frame. + * + * @param startTime The start time used to filter programs. The returned programs should have + * {@link TvContractCompat.Programs#COLUMN_END_TIME_UTC_MILLIS} that is greater than this + * time. + * @param endTime The end time used to filter programs. The returned programs should have {@link + * TvContractCompat.Programs#COLUMN_START_TIME_UTC_MILLIS} that is less than this time. + */ + public static Uri buildProgramsUri(long startTime, long endTime) { + return TvContractCompat.Programs.CONTENT_URI + .buildUpon() + .appendQueryParameter(TvContractCompat.PARAM_START_TIME, String.valueOf(startTime)) + .appendQueryParameter(TvContractCompat.PARAM_END_TIME, String.valueOf(endTime)) + .build(); + } +} diff --git a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java index 3c76c269..2a6ceec5 100644 --- a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java +++ b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java @@ -19,11 +19,11 @@ package com.android.tv.common.ui.setup; import static android.content.Context.ACCESSIBILITY_SERVICE; import android.os.Bundle; -import android.support.v17.leanback.app.GuidedStepFragment; -import android.support.v17.leanback.widget.GuidanceStylist; -import android.support.v17.leanback.widget.GuidedAction; -import android.support.v17.leanback.widget.GuidedActionsStylist; -import android.support.v17.leanback.widget.VerticalGridView; +import androidx.leanback.app.GuidedStepFragment; +import androidx.leanback.widget.GuidanceStylist; +import androidx.leanback.widget.GuidedAction; +import androidx.leanback.widget.GuidedActionsStylist; +import androidx.leanback.widget.VerticalGridView; import android.view.LayoutInflater; import android.view.View; import android.view.View.AccessibilityDelegate; @@ -53,9 +53,9 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); Bundle arguments = getArguments(); - view.findViewById(android.support.v17.leanback.R.id.action_fragment_root) + view.findViewById(androidx.leanback.R.id.action_fragment_root) .setPadding(0, 0, 0, 0); - mContentFragment = view.findViewById(android.support.v17.leanback.R.id.content_fragment); + mContentFragment = view.findViewById(androidx.leanback.R.id.content_fragment); LinearLayout.LayoutParams guidanceLayoutParams = (LinearLayout.LayoutParams) mContentFragment.getLayoutParams(); guidanceLayoutParams.weight = 0; @@ -69,7 +69,7 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { getResources() .getDimensionPixelOffset(R.dimen.setup_done_button_container_width); // Guided actions list - View list = view.findViewById(android.support.v17.leanback.R.id.guidedactions_list); + View list = view.findViewById(androidx.leanback.R.id.guidedactions_list); MarginLayoutParams marginLayoutParams = (MarginLayoutParams) list.getLayoutParams(); // Use content view to check layout direction while view is being created. if (getResources().getConfiguration().getLayoutDirection() @@ -93,12 +93,12 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { gridView.setWindowAlignmentOffset(offset); gridView.setWindowAlignmentOffsetPercent(0); gridView.setItemAlignmentOffsetPercent(0); - ((ViewGroup) view.findViewById(android.support.v17.leanback.R.id.guidedactions_list)) + ((ViewGroup) view.findViewById(androidx.leanback.R.id.guidedactions_list)) .setTransitionGroup(false); // Needed for the shared element transition. // content_frame is defined in leanback. ViewGroup group = - (ViewGroup) view.findViewById(android.support.v17.leanback.R.id.content_frame); + (ViewGroup) view.findViewById(androidx.leanback.R.id.content_frame); group.setClipChildren(false); group.setClipToPadding(false); return view; diff --git a/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java b/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java index c02d3f56..ee00e9fb 100644 --- a/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java +++ b/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java @@ -112,15 +112,15 @@ public abstract class SetupMultiPaneFragment extends SetupFragment { @Override protected int[] getParentIdsForDelay() { return new int[] { - android.support.v17.leanback.R.id.content_fragment, - android.support.v17.leanback.R.id.guidedactions_list + androidx.leanback.R.id.content_fragment, + androidx.leanback.R.id.guidedactions_list }; } @Override public int[] getSharedElementIds() { return new int[] { - android.support.v17.leanback.R.id.action_fragment_background, R.id.done_button_container + androidx.leanback.R.id.action_fragment_background, R.id.done_button_container }; } } diff --git a/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java b/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java index 13b89ea1..59706936 100644 --- a/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java +++ b/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java @@ -20,7 +20,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.graphics.Path; -import android.support.v17.leanback.R; +import androidx.leanback.R; import android.transition.Transition; import android.transition.TransitionValues; import android.view.View; @@ -29,9 +29,9 @@ import android.view.View; * This class is used by Slide and Explode to create an animator that goes from the start position * to the end position. It takes into account the canceled position so that it will not blink out or * shift suddenly when the transition is interrupted. The original class is - * android.support.v17.leanback.transition.TranslationAnimationCreator which is hidden. + * androidx.leanback.transition.TranslationAnimationCreator which is hidden. */ -// Copied from android.support.v17.leanback.transition.TransltaionAnimationCreator +// Copied from androidx.leanback.transition.TransltaionAnimationCreator class TranslationAnimationCreator { /** * Creates an animator that can be used for x and/or y translations. When interrupted, it sets a diff --git a/common/src/com/android/tv/common/util/CommonUtils.java b/common/src/com/android/tv/common/util/CommonUtils.java index 4513a879..662f819c 100644 --- a/common/src/com/android/tv/common/util/CommonUtils.java +++ b/common/src/com/android/tv/common/util/CommonUtils.java @@ -22,10 +22,8 @@ import android.media.tv.TvInputInfo; import android.os.Build; import android.util.ArraySet; import android.util.Log; -import com.android.tv.common.BuildConfig; import com.android.tv.common.CommonConstants; import com.android.tv.common.actions.InputSetupActionUtils; -import com.android.tv.common.experiments.Experiments; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; @@ -53,6 +51,7 @@ public final class CommonUtils { static { BUNDLED_PACKAGE_SET.add("com.android.tv"); +// AOSP_Comment_Out BUNDLED_PACKAGE_SET.add(CommonConstants.BASE_PACKAGE); } private static Boolean sRunningInTest; @@ -123,16 +122,11 @@ public final class CommonUtils { return false; } - /** Returns true if the application is packaged with Live TV. */ + /** Returns true if the application is packaged with TV app. */ public static boolean isPackagedWithLiveChannels(Context context) { return (CommonConstants.BASE_PACKAGE.equals(context.getPackageName())); } - /** Returns true if the current user is a developer. */ - public static boolean isDeveloper() { - return BuildConfig.ENG || Experiments.ENABLE_DEVELOPER_FEATURES.get(); - } - /** Converts time in milliseconds to a ISO 8061 string. */ public static String toIsoDateTimeString(long timeMillis) { return ISO_8601.get().format(new Date(timeMillis)); diff --git a/common/src/com/android/tv/common/util/Debug.java b/common/src/com/android/tv/common/util/Debug.java index ab908741..8e826aef 100644 --- a/common/src/com/android/tv/common/util/Debug.java +++ b/common/src/com/android/tv/common/util/Debug.java @@ -23,11 +23,11 @@ import java.util.concurrent.TimeUnit; /** A class only for help developers. */ public class Debug { /** - * A threshold of start up time, when the start up time of Live TV is more than it, a - * warning will show to the developer. + * A threshold of start up time, when the start up time of TV app is more than it, a warning + * will show to the developer. */ public static final long TIME_START_UP_DURATION_THRESHOLD = TimeUnit.SECONDS.toMillis(6); - /** Tag for measuring start up time of Live TV. */ + /** Tag for measuring start up time of TV app. */ public static final String TAG_START_UP_TIMER = "start_up_timer"; /** A global map for duration timers. */ diff --git a/common/src/com/android/tv/common/util/NetworkTrafficTags.java b/common/src/com/android/tv/common/util/NetworkTrafficTags.java index 3c94aed6..51b6c4dc 100644 --- a/common/src/com/android/tv/common/util/NetworkTrafficTags.java +++ b/common/src/com/android/tv/common/util/NetworkTrafficTags.java @@ -20,7 +20,7 @@ import android.net.TrafficStats; import android.support.annotation.NonNull; import java.util.concurrent.Executor; -/** Constants for tagging network traffic in the Live channels app. */ +/** Constants for tagging network traffic in the TV app. */ public final class NetworkTrafficTags { public static final int DEFAULT_LIVE_CHANNELS = 1; @@ -43,16 +43,16 @@ public final class NetworkTrafficTags { @Override public void execute(final @NonNull Runnable command) { - // TODO(b/62038127): robolectric does not support lamdas in unbundled apps - delegateExecutor.execute( - () -> { - TrafficStats.setThreadStatsTag(tag); - try { - command.run(); - } finally { - TrafficStats.clearThreadStatsTag(); - } - }); + // TODO(b/62038127): robolectric does not support lamdas in unbundled apps + delegateExecutor.execute( + () -> { + TrafficStats.setThreadStatsTag(tag); + try { + command.run(); + } finally { + TrafficStats.clearThreadStatsTag(); + } + }); } } diff --git a/common/src/com/android/tv/common/util/PermissionUtils.java b/common/src/com/android/tv/common/util/PermissionUtils.java index ca1abdc4..e241b91a 100644 --- a/common/src/com/android/tv/common/util/PermissionUtils.java +++ b/common/src/com/android/tv/common/util/PermissionUtils.java @@ -26,6 +26,9 @@ public class PermissionUtils { private static Boolean sHasAccessAllEpgPermission; private static Boolean sHasAccessWatchedHistoryPermission; private static Boolean sHasModifyParentalControlsPermission; + private static Boolean sHasChangeHdmiCecActiveSource; + private static Boolean sHasReadContentRatingSystem; + public static boolean hasAccessAllEpg(Context context) { if (sHasAccessAllEpgPermission == null) { @@ -70,4 +73,24 @@ public class PermissionUtils { return context.checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == PackageManager.PERMISSION_GRANTED; } + + public static boolean hasChangeHdmiCecActiveSource(Context context) { + if (sHasChangeHdmiCecActiveSource == null) { + sHasChangeHdmiCecActiveSource = + context.checkSelfPermission( + "android.permission.CHANGE_HDMI_CEC_ACTIVE_SOURCE") + == PackageManager.PERMISSION_GRANTED; + } + return sHasChangeHdmiCecActiveSource; + } + + public static boolean hasReadContetnRatingSystem(Context context) { + if (sHasReadContentRatingSystem == null) { + sHasReadContentRatingSystem = + context.checkSelfPermission( + "android.permission.READ_CONTENT_RATING_SYSTEMS") + == PackageManager.PERMISSION_GRANTED; + } + return sHasReadContentRatingSystem; + } } |