Reference TV app

A TV app that plays live TV content is required for some classes of Android TV devices, such as panel TVs and operator STBs. The source code for a reference app is available in the Android Open Source Project.

This page summarizes how to build and customize a system TV app based on Live TV for your Android television device.

Dependencies

The Live TV app is a component of the TV Input Framework (TIF) and can't be used independently of the other TIF components. Different branches of the app have different dependencies on Android API levels:

Branch Target API level Minimum API level
main 24 (Android 7.0) 23
android-live-tv 23 (Android 6.0) 21
android-live-tv-l-mr1 22 (Android 5.1) 21

Get the source

To get started, select a Live TV version from Git. The following instructions are for the current version of Live TV. To use an earlier version, switch to one of the Git branches listed in the previous table.

mkdir live-tv && cd live-tv
repo init -u https://android.googlesource.com/platform/manifest -b main
repo sync -j8 -c

Build

To build the Live TV code, run:

. build/envsetup.sh
tapas LiveTv x86
make LiveTv

Push

Use the following code to push Live TV to your test device:

adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk

If you intend the Live TV app to have system permissions, use the following code to push it to /system/priv-app the first time you install it:

adb push $OUT/system/priv-app/LiveTv/LiveTv.apk  /system/priv-app/LiveTv/

Test

After Live TV is installed on your device, test that it's properly integrated using the following tests in addition to the Compatibility test suite and the CTS Verifier tests for the TV app. You must have a device or emulator connected to run all test types.

Unit tests

adb shell logcat -c
m LiveTv TVTestInput TVUnitTests -j20 &&\
adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\
adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \
adb install -r -d $OUT/data/app/TVUnitTests/TVUnitTests.apk && \
adb shell pm clear com.android.providers.tv && \
adb shell pm clear com.android.tv && \
adb shell am instrument \
  -e testSetupMode unit \
  -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\
adb shell input keyevent KEYCODE_HOME &&\
adb shell am instrument \
  -w 'com.android.tv.tests/android.support.test.runner.AndroidJUnitRunner'

Functional tests

adb shell logcat -c
m LiveTv TVTestInput TVFuncTests -j20 &&\
adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\
adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \
adb install -r -d $OUT/data/app/TVFuncTests/TVFuncTests.apk && \
adb shell pm clear com.android.providers.tv && \
adb shell pm clear com.android.tv && \
adb shell am instrument \
  -e testSetupMode func \
  -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\
adb shell input keyevent KEYCODE_HOME &&\
adb shell am instrument \
  -w 'com.android.tv.tests.ui/android.support.test.runner.AndroidJUnitRunner'

Jank tests

The jank tests look for dropped frames and delays in rendering.

adb shell logcat -c
m LiveTv TVTestInput TVJankTests -j20 &&\
adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\
adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk &&\
adb install -r -d $OUT/data/app/TVJankTests/TVJankTests.apk &&\
adb shell pm clear com.android.providers.tv &&\
adb shell pm clear com.android.tv &&\
echo "Creating a lot of channels and EPG data, this may take a while" &&\
adb shell am instrument \
  -e testSetupMode jank \
  -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\
adb shell input keyevent KEYCODE_HOME &&\
adb shell am instrument \
  -w 'com.android.tv.tests.jank/android.support.test.runner.AndroidJUnitRunner'