diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-16 07:14:09 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-16 07:14:09 +0000 |
commit | a31171c1ac2683db95633ad3a5fc84480f3300c4 (patch) | |
tree | 4cebbe9f386841a3555a2b2ba26631277fac13b3 | |
parent | f812050941b9068ffcb21b3c99923d3a6f4be94e (diff) | |
parent | 613abdf0b82bf86ea2a05f2ace1cc342a0334030 (diff) | |
download | TV-android11-mainline-sparse-2020-dec-release.tar.gz |
Snap for 6593884 from 613abdf0b82bf86ea2a05f2ace1cc342a0334030 to mainline-releaser_aml_301500702android-mainline-12.0.0_r55android-mainline-11.0.0_r9android-mainline-11.0.0_r8android-mainline-11.0.0_r7android-mainline-11.0.0_r6android-mainline-11.0.0_r5android-mainline-11.0.0_r45android-mainline-11.0.0_r4android-mainline-11.0.0_r33android-mainline-11.0.0_r3android-mainline-11.0.0_r29android-mainline-11.0.0_r2android-mainline-11.0.0_r19android-mainline-11.0.0_r10android-mainline-11.0.0_r1android11-mainline-sparse-2021-jan-releaseandroid11-mainline-sparse-2020-dec-releaseandroid11-mainline-release
Change-Id: I2ec3d845b26510fed7731829caf3358037fc3fb8
12 files changed, 372 insertions, 0 deletions
diff --git a/tuner/sampletunertvinput/Android.bp b/tuner/sampletunertvinput/Android.bp new file mode 100644 index 00000000..9d737c84 --- /dev/null +++ b/tuner/sampletunertvinput/Android.bp @@ -0,0 +1,62 @@ +// +// 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. +// + +android_app { + name: "sampletunertvinput", + srcs: ["src/**/*.java"], + + optimize: { + enabled: false, + }, + + platform_apis: true, + system_ext_specific: true, + + + privileged: true, + certificate: "platform", + // product_specific: true, + // sdk_version: "system_current", + resource_dirs: ["res"], + static_libs: [ + "android-support-annotations", + "android-support-compat", + "android-support-core-ui", + "android-support-v7-palette", + "android-support-v7-recyclerview", + "androidx.leanback_leanback", + "androidx.tvprovider_tvprovider", + "jsr330", + "live-tv-tuner-proto", + "tv-auto-value-jar", + "tv-auto-factory-jar", + "tv-common", + "tv-error-prone-annotations-jar", + "tv-guava-android-jar", + "tv-javax-annotations-jar", + "tv-lib-dagger", + "tv-lib-exoplayer", + "tv-lib-exoplayer-v2-core", + "tv-lib-dagger-android", + "tv-test-common", + ], + aaptflags: ["-0 .ts"], + plugins: [ + "tv-auto-value", + "tv-auto-factory", + ], + // min_sdk_version: "29", +} diff --git a/tuner/sampletunertvinput/AndroidManifest.xml b/tuner/sampletunertvinput/AndroidManifest.xml new file mode 100644 index 00000000..d282889a --- /dev/null +++ b/tuner/sampletunertvinput/AndroidManifest.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ 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. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.android.tv.samples.sampletunertvinput" + android:sharedUserId="android.uid.system" + coreApp="true"> + + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <uses-permission android:name="android.permission.ACCESS_TV_DESCRAMBLER" /> + <uses-permission android:name="android.permission.ACCESS_TV_TUNER" /> + <uses-permission android:name="android.permission.TUNER_RESOURCE_ACCESS" /> + <uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" /> + <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> + <uses-permission android:name="com.android.tv.permission.RECEIVE_INPUT_EVENT" /> + + <uses-feature android:name="android.software.leanback" android:required="true" /> + <uses-feature android:name="android.software.live_tv" android:required="true" /> + + <uses-sdk android:targetSdkVersion="29" android:minSdkVersion="29" + tools:overrideLibrary="com.android.tv.testing"/> + <application android:label="@string/sample_tuner_tv_input" + tools:replace="android:label,icon,theme,appComponentFactory" + android:icon="@mipmap/ic_launcher" + android:theme="@android:style/Theme.Holo.Light.NoActionBar" + android:appComponentFactory="android.support.v4.app.CoreComponentFactory" > + <uses-library android:name="com.android.libraries.tv.tvsystem" android:required="false" /> + <activity android:name=".SampleTunerTvInputSetupActivity" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + </intent-filter> + </activity> + <service android:name=".SampleTunerTvInputService" + android:permission="android.permission.BIND_TV_INPUT" + android:label="@string/sample_tuner_tv_input" + android:process="com.android.tv.samples.sampletunertvinput"> + <intent-filter> + <action android:name="android.media.tv.TvInputService" /> + </intent-filter> + <meta-data android:name="android.media.tv.input" + android:resource="@xml/sampletunertvinputservice" /> + </service> + </application> +</manifest> diff --git a/tuner/sampletunertvinput/res/mipmap-hdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..454c515a --- /dev/null +++ b/tuner/sampletunertvinput/res/mipmap-hdpi/ic_launcher.png diff --git a/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..5e53eb55 --- /dev/null +++ b/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png diff --git a/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..898bac41 --- /dev/null +++ b/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png diff --git a/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..9da29906 --- /dev/null +++ b/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png diff --git a/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..ff5c4b1a --- /dev/null +++ b/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/tuner/sampletunertvinput/res/values/Strings.xml b/tuner/sampletunertvinput/res/values/Strings.xml new file mode 100644 index 00000000..f76c8eef --- /dev/null +++ b/tuner/sampletunertvinput/res/values/Strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ 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. + --> + +<resources> + <string name="sample_tuner_tv_input" translatable="false">Sample Tuner TV Input</string> +</resources>
\ No newline at end of file diff --git a/tuner/sampletunertvinput/res/xml/sampletunertvinputservice.xml b/tuner/sampletunertvinput/res/xml/sampletunertvinputservice.xml new file mode 100644 index 00000000..ca39d95a --- /dev/null +++ b/tuner/sampletunertvinput/res/xml/sampletunertvinputservice.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<tv-input xmlns:android="http://schemas.android.com/apk/res/android" + android:setupActivity="com.android.tv.samples.sampletunertvinput.SampleTunerTvInputSetupActivity" /> diff --git a/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/AndroidManifest.xml b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/AndroidManifest.xml new file mode 100644 index 00000000..8fc96b2a --- /dev/null +++ b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/AndroidManifest.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ 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. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.android.tv.samples.sampletunertvinput"> + + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <uses-permission android:name="android.permission.ACCESS_TV_DESCRAMBLER" /> + <uses-permission android:name="android.permission.ACCESS_TV_TUNER" /> + <uses-permission android:name="android.permission.TUNER_RESOURCE_ACCESS" /> + <uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" /> + <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> + <uses-permission android:name="com.android.tv.permission.RECEIVE_INPUT_EVENT" /> + + <uses-feature android:name="android.software.leanback" android:required="true" /> + <uses-feature android:name="android.software.live_tv" android:required="true" /> + + <uses-sdk android:targetSdkVersion="27" android:minSdkVersion="23"/> + <application android:label="@string/sample_tuner_tv_input" + tools:replace="android:label,icon,theme,appComponentFactory" + android:icon="@mipmap/ic_launcher" + android:theme="@android:style/Theme.Holo.Light.NoActionBar" + android:appComponentFactory="android.support.v4.app.CoreComponentFactory" > + <activity android:name=".SampleTunerTvInputSetupActivity" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + </intent-filter> + </activity> + <service android:name=".SampleTunerTvInputService" + android:permission="android.permission.BIND_TV_INPUT" + android:label="@string/sample_tuner_tv_input" + android:process="com.android.tv.samples.sampletunertvinput"> + <intent-filter> + <action android:name="android.media.tv.TvInputService" /> + </intent-filter> + <meta-data android:name="android.media.tv.input" + android:resource="@xml/sampletunertvinputservice" /> + </service> + </application> +</manifest> diff --git a/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputService.java b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputService.java new file mode 100644 index 00000000..6ac95353 --- /dev/null +++ b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputService.java @@ -0,0 +1,101 @@ +package com.android.tv.samples.sampletunertvinput; + +import android.content.Context; +import android.media.tv.tuner.frontend.AtscFrontendSettings; +import android.media.tv.tuner.frontend.FrontendSettings; +import android.media.tv.tuner.Tuner; +import android.media.tv.TvInputService; +import android.net.Uri; +import android.util.Log; +import android.view.Surface; + + +/** SampleTunerTvInputService */ +public class SampleTunerTvInputService extends TvInputService { + private static final String TAG = "SampleTunerTvInput"; + private static final boolean DEBUG = true; + + public static final String INPUT_ID = + "com.android.tv.samples.sampletunertvinput/.SampleTunerTvInputService"; + private String mSessionId; + + @Override + public TvInputSessionImpl onCreateSession(String inputId, String sessionId) { + TvInputSessionImpl session = new TvInputSessionImpl(this); + if (DEBUG) { + Log.d(TAG, "onCreateSession(inputId=" + inputId + ", sessionId=" + sessionId + ")"); + } + mSessionId = sessionId; + return session; + } + + @Override + public TvInputSessionImpl onCreateSession(String inputId) { + return new TvInputSessionImpl(this); + } + + class TvInputSessionImpl extends Session { + + private Surface surface; + private final Context mContext; + Tuner tuner; + + + public TvInputSessionImpl(Context context) { + super(context); + mContext = context; + } + + @Override + public void onRelease() { + if (DEBUG) { + Log.d(TAG, "onRelease"); + } + } + + @Override + public boolean onSetSurface(Surface surface) { + if (DEBUG) { + Log.d(TAG, "onSetSurface"); + } + this.surface = surface; + return true; + } + + @Override + public void onSetStreamVolume(float v) { + if (DEBUG) { + Log.d(TAG, "onSetStreamVolume " + v); + } + } + + @Override + public boolean onTune(Uri uri) { + if (DEBUG) { + Log.d(TAG, "onTune " + uri); + } + tuner = new Tuner(mContext, mSessionId, + TvInputService.PRIORITY_HINT_USE_CASE_TYPE_LIVE); + + int feCount = tuner.getFrontendIds().size(); + if (feCount <= 0) return false; + + AtscFrontendSettings settings = + AtscFrontendSettings + .builder() + .setFrequency(2000) + .setModulation(AtscFrontendSettings.MODULATION_AUTO) + .build(); + tuner.tune(settings); + + return true; + } + + @Override + public void onSetCaptionEnabled(boolean b) { + if (DEBUG) { + Log.d(TAG, "onSetCaptionEnabled " + b); + } + } + } +}
\ No newline at end of file diff --git a/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputSetupActivity.java b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputSetupActivity.java new file mode 100644 index 00000000..b932b605 --- /dev/null +++ b/tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputSetupActivity.java @@ -0,0 +1,50 @@ +package com.android.tv.samples.sampletunertvinput; + +import android.app.Activity; +import android.content.Intent; +import android.media.tv.TvInputInfo; +import android.os.Bundle; +import com.android.tv.testing.data.ChannelInfo; +import com.android.tv.testing.data.ChannelUtils; +import com.android.tv.testing.data.ProgramInfo; +import java.util.Collections; + +/** Setup activity for SampleTunerTvInput */ +public class SampleTunerTvInputSetupActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ChannelInfo channel = + new ChannelInfo.Builder() + .setNumber("1-1") + .setName("Sample Channel") + .setLogoUrl( + ChannelInfo.getUriStringForChannelLogo(this, 100)) + .setOriginalNetworkId(1) + .setVideoWidth(640) + .setVideoHeight(480) + .setAudioChannel(2) + .setAudioLanguageCount(1) + .setHasClosedCaption(false) + .setProgram( + new ProgramInfo( + "Sample Program", + "", + 0, + 0, + ProgramInfo.GEN_POSTER, + "Sample description", + ProgramInfo.GEN_DURATION, + null, + ProgramInfo.GEN_GENRE, + null)) + .build(); + + Intent intent = getIntent(); + String inputId = intent.getStringExtra(TvInputInfo.EXTRA_INPUT_ID); + ChannelUtils.updateChannels(this, inputId, Collections.singletonList(channel)); + setResult(Activity.RESULT_OK); + finish(); + } + +} |