1 <html devsite> 2 <head> 3 <title>Reference TV App</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 27 <p>A TV application that plays live TV content is required for Android TV devices. 28 A reference TV application (<a href="https://play.google.com/store/apps/details?id=com.google.android.tv">Live TV</a>) 29 is provided alongside the Android platform, which can be used as-is, 30 customized, extended, or replaced. The 31 <a href="https://android.googlesource.com/platform/packages/apps/TV/">source code</a> 32 is available in the Android Open Source Project.</p> 33 34 <p>This article summarizes how to build and customize a system TV App based 35 on Live TV for your Android television device. (You may extend your TV application to implement device 36 manufacturer or country-specific features, however this is not in the scope of 37 the reference TV App.)</p> 38 39 <h2 id=dependencies>Dependencies</h2> 40 41 42 <p>The TV application is a component of the 43 <a href="/devices/tv/">TV Input Framework</a> (TIF) and cannot be used 44 independently of the other components. This means that only devices with TIF 45 will be able to run the 46 <a href="https://play.google.com/store/apps/details?id=com.google.android.tv">Live TV</a> application.</p> 47 48 <p>The Live TV application depends on Android APIs. Different branches have 49 different dependencies on API levels:</p> 50 51 <p class="table-caption" id="table-1"> 52 <strong>Table 1.</strong> Live TV branches.</p> 53 <table> 54 <tr> 55 <th>Branch</th> 56 <th>Target API level</th> 57 <th>Minimum API level</th> 58 </tr> 59 <tr> 60 <td><a href="https://android.googlesource.com/platform/packages/apps/TV/+/master">master</a></td> 61 <td>24 (Android 7.0)</td> 62 <td>23</td> 63 </tr> 64 65 <tr> 66 <td><a href="https://android.googlesource.com/platform/packages/apps/TV/+/android-live-tv">android-live-tv</a></td> 67 <td>23 (Android 6.0)</td> 68 <td>21</td> 69 </tr> 70 <tr> 71 <td><a href="https://android.googlesource.com/platform/packages/apps/TV/+/android-live-tv-l-mr1">android-live-tv-l-mr1</a></td> 72 <td>22 (Android 5.1)</td> 73 <td>21</td> 74 </tr> 75 </table> 76 77 78 <h2 id=get_the_source>Get the source</h2> 79 80 81 <p>To get started, select which version of Live TV youd like from Git. The 82 instructions below are for the current version of Live TV, but you can 83 easily select an earlier version by changing the branch from master to a 84 different one listed in the table above.</p> 85 86 87 <pre class="devsite-click-to-copy"> 88 <code class="devsite-terminal">mkdir live-tv && cd live-tv</code> 89 <code class="devsite-terminal">repo init -u <a href="https://android.googlesource.com/platform/manifest">https://android.googlesource.com/platform/manifest</a> -b master</code> 90 <code class="devsite-terminal">repo sync -j8 -c</code> 91 </pre> 92 93 94 <h2 id=build>Build</h2> 95 96 97 <p>To build the Live TV code, run:</p> 98 99 <pre class="devsite-click-to-copy"> 100 <code class="devsite-terminal">. build/envsetup.sh</code> 101 <code class="devsite-terminal">tapas LiveTv x86</code> 102 <code class="devsite-terminal">make LiveTv</code> 103 </pre> 104 105 106 <h2 id=push>Push</h2> 107 108 109 <p>To push Live TV to your test device:</p> 110 111 <pre class="devsite-terminal devsite-click-to-copy"> 112 adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk 113 </pre> 114 115 <p>If the developer wants the LIVE TV app to have system permissions, the first time it 116 is installed it needs to be pushed to /system/priv-app with:</p> 117 118 <pre class="devsite-terminal devsite-click-to-copy"> 119 adb push $OUT/system/priv-app/LiveTv/LiveTv.apk /system/priv-app/LiveTv/ 120 </pre> 121 122 <h2 id=test>Test</h2> 123 124 125 <p>Once Live TV is on your device, you should test that it is properly 126 integrated. In addition to running the <a href="/compatibility/cts/index.html">Compatibility test suite</a> and the <a href="http://source.android.com/compatibility/cts/verifier.html">CTS Verifier tests</a> for the TV app, you can use these tests below:</p> 127 128 <h3 id=unit_tests>Unit tests</h3> 129 130 131 <p>There are unit and functional tests for the Live TV app. You must have a 132 device (or emulator) connected to run the tests.</p> 133 134 <pre class="devsite-terminal devsite-click-to-copy"> 135 adb shell logcat -c 136 m LiveTv TVTestInput TVUnitTests -j20 &&\ 137 adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\ 138 adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \ 139 adb install -r -d $OUT/data/app/TVUnitTests/TVUnitTests.apk && \ 140 adb shell pm clear <a href="http://com.android.providers.tv/">com.android.providers.tv</a> && \ 141 adb shell pm clear <a href="http://com.google.android.tv/">com.google.android.tv</a> && \ 142 adb shell am instrument \ 143 -e testSetupMode unit \ 144 -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\ 145 adb shell input keyevent KEYCODE_HOME &&\ 146 adb shell am instrument \ 147 -w 'com.android.tv.tests/android.support.test.runner.AndroidJUnitRunner' 148 </pre> 149 150 151 <h3 id=functional_tests>Functional Tests</h3> 152 153 <pre class="devsite-terminal devsite-click-to-copy"> 154 adb shell logcat -c 155 m LiveTv TVTestInput TVFuncTests -j20 &&\ 156 adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\ 157 adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk && \ 158 adb install -r -d $OUT/data/app/TVFuncTests/TVFuncTests.apk && \ 159 adb shell pm clear <a href="http://com.android.providers.tv/">com.android.providers.tv</a> && \ 160 adb shell pm clear <a href="http://com.google.android.tv/">com.google.android.tv</a> && \ 161 adb shell am instrument \ 162 -e testSetupMode func \ 163 -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\ 164 adb shell input keyevent KEYCODE_HOME &&\ 165 adb shell am instrument \ 166 -w 'com.android.tv.tests.ui/android.support.test.runner.AndroidJUnitRunner' 167 </pre> 168 169 170 <h3 id=jank_tests>Jank Tests</h3> 171 172 173 <p>The Jank tests look for dropped frames and delays in rendering.</p> 174 175 <pre class="devsite-terminal devsite-click-to-copy"> 176 adb shell logcat -c 177 m LiveTv TVTestInput TVJankTests -j20 &&\ 178 adb install -r -d $OUT/system/priv-app/LiveTv/LiveTv.apk &&\ 179 adb install -r -d $OUT/system/app/TVTestInput/TVTestInput.apk &&\ 180 adb install -r -d $OUT/data/app/TVJankTests/TVJankTests.apk &&\ 181 adb shell pm clear <a href="http://com.android.providers.tv/">com.android.providers.tv</a> &&\ 182 adb shell pm clear <a href="http://com.google.android.tv/">com.google.android.tv</a> &&\ 183 echo "Creating a lot of channels and EPG data, this may take a while" &&\ 184 adb shell am instrument \ 185 -e testSetupMode jank \ 186 -w com.android.tv.testinput/.instrument.TestSetupInstrumentation &&\ 187 adb shell input keyevent KEYCODE_HOME &&\ 188 adb shell am instrument \ 189 -w 'com.android.tv.tests.jank/android.support.test.runner.AndroidJUnitRunner' 190 </pre> 191 192 </body> 193 </html> 194