[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Reference TV app\n\nA TV app that plays live TV content is required for some classes of Android TV\ndevices, such as panel TVs and operator STBs.\nThe [source code](https://android.googlesource.com/platform/packages/apps/TV/)\nfor a reference app is available in the Android Open Source Project.\n\nThis page summarizes how to build and customize a system TV app based\non Live TV for your Android television device.\n| You can extend your TV app to implement device manufacturer or country-specific features, but this is not in the scope of the reference TV app.\n\nDependencies\n------------\n\nThe Live TV app is a component of the [TV Input Framework (TIF)](/docs/devices/tv)\nand can't be used independently of the other TIF components. Different branches of the app have\ndifferent dependencies on Android API levels:\n\n| Branch | Target API level | Minimum API level |\n|---------------------------------------------------------------------------------------------------------------|------------------|-------------------|\n| [`main`](https://android.googlesource.com/platform/packages/apps/TV/+/main) | 24 (Android 7.0) | 23 |\n| [`android-live-tv`](https://android.googlesource.com/platform/packages/apps/TV/+/android-live-tv) | 23 (Android 6.0) | 21 |\n| [`android-live-tv-l-mr1`](https://android.googlesource.com/platform/packages/apps/TV/+/android-live-tv-l-mr1) | 22 (Android 5.1) | 21 |\n\nGet the source\n--------------\n\nTo get started, select a Live TV version from Git. The following instructions are for the current\nversion of Live TV. To use an earlier version, switch to one of the Git branches\nlisted in the previous table. \n\n mkdir live-tv && cd live-tv\n repo init -u https://android.googlesource.com/platform/manifest -b main\n repo sync -j8 -c\n\nBuild\n-----\n\nTo build the Live TV code, run: \n\n . build/envsetup.sh\n tapas LiveTv x86\n make LiveTv\n\nPush\n----\n\nUse the following code to push Live TV to your test device: \n\n```\nadb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk\n```\n\nIf you intend the Live TV app to have system permissions, use the following code to push it to\n`/system/priv-app` the first time you install it: \n\n```\nadb push $OUT/system/priv-app/LiveTv/LiveTv.apk /system/priv-app/LiveTv/\n```\n\nTest\n----\n\nAfter Live TV is installed on your device, test that it's properly integrated using the following\ntests in addition to the [Compatibility test suite](/docs/compatibility/cts)\nand the [CTS Verifier tests](/docs/compatibility/cts/verifier) for the TV app.\nYou must have a device or emulator connected to run all test types.\n\n### Unit tests\n\n```\nadb shell logcat -c\nm LiveTv TVTestInput TVUnitTests -j20 &&\\\nadb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\\\nadb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \\\nadb install -r -d $OUT/data/app/TVUnitTests/TVUnitTests.apk && \\\nadb shell pm clear com.android.providers.tv && \\\nadb shell pm clear com.android.tv && \\\nadb shell am instrument \\\n -e testSetupMode unit \\\n -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\\\nadb shell input keyevent KEYCODE_HOME &&\\\nadb shell am instrument \\\n -w 'com.android.tv.tests/android.support.test.runner.AndroidJUnitRunner'\n```\n\n### Functional tests\n\n```\nadb shell logcat -c\nm LiveTv TVTestInput TVFuncTests -j20 &&\\\nadb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\\\nadb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \\\nadb install -r -d $OUT/data/app/TVFuncTests/TVFuncTests.apk && \\\nadb shell pm clear com.android.providers.tv && \\\nadb shell pm clear com.android.tv && \\\nadb shell am instrument \\\n -e testSetupMode func \\\n -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\\\nadb shell input keyevent KEYCODE_HOME &&\\\nadb shell am instrument \\\n -w 'com.android.tv.tests.ui/android.support.test.runner.AndroidJUnitRunner'\n```\n\n### Jank tests\n\nThe jank tests look for dropped frames and delays in rendering. \n\n```\nadb shell logcat -c\nm LiveTv TVTestInput TVJankTests -j20 &&\\\nadb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\\\nadb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk &&\\\nadb install -r -d $OUT/data/app/TVJankTests/TVJankTests.apk &&\\\nadb shell pm clear com.android.providers.tv &&\\\nadb shell pm clear com.android.tv &&\\\necho \"Creating a lot of channels and EPG data, this may take a while\" &&\\\nadb shell am instrument \\\n -e testSetupMode jank \\\n -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\\\nadb shell input keyevent KEYCODE_HOME &&\\\nadb shell am instrument \\\n -w 'com.android.tv.tests.jank/android.support.test.runner.AndroidJUnitRunner'\n```"]]