aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshubang <shubang@google.com>2020-06-15 19:30:30 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-15 19:30:30 +0000
commit613abdf0b82bf86ea2a05f2ace1cc342a0334030 (patch)
tree4cebbe9f386841a3555a2b2ba26631277fac13b3
parentf812050941b9068ffcb21b3c99923d3a6f4be94e (diff)
parent1c8ef0a170e3824a53390efccac1b6ebec7ae4af (diff)
downloadTV-android11-mainline-permission-release.tar.gz
Sample TIS with Tuner APIs. am: 1c8ef0a170android-mainline-12.0.0_r112android-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseandroid11-mainline-tethering-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-releaseaml_tz2_305400100
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/TV/+/11721763 Change-Id: I410316075eccbe4104c5bf6a03434562f10b3e66
-rw-r--r--tuner/sampletunertvinput/Android.bp62
-rw-r--r--tuner/sampletunertvinput/AndroidManifest.xml62
-rw-r--r--tuner/sampletunertvinput/res/mipmap-hdpi/ic_launcher.pngbin0 -> 2815 bytes
-rw-r--r--tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.pngbin0 -> 1822 bytes
-rw-r--r--tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 3470 bytes
-rw-r--r--tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 5402 bytes
-rw-r--r--tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 7199 bytes
-rw-r--r--tuner/sampletunertvinput/res/values/Strings.xml20
-rw-r--r--tuner/sampletunertvinput/res/xml/sampletunertvinputservice.xml19
-rw-r--r--tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/AndroidManifest.xml58
-rw-r--r--tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputService.java101
-rw-r--r--tuner/sampletunertvinput/src/com/android/tv/samples/sampletunertvinput/SampleTunerTvInputSetupActivity.java50
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
new file mode 100644
index 00000000..454c515a
--- /dev/null
+++ b/tuner/sampletunertvinput/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 00000000..5e53eb55
--- /dev/null
+++ b/tuner/sampletunertvinput/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..898bac41
--- /dev/null
+++ b/tuner/sampletunertvinput/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..9da29906
--- /dev/null
+++ b/tuner/sampletunertvinput/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png b/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 00000000..ff5c4b1a
--- /dev/null
+++ b/tuner/sampletunertvinput/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
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();
+ }
+
+}