1page.title=Setting up CTS 2@jd:body 3 4<!-- 5 Copyright 2015 The Android Open Source Project 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18--> 19<div id="qv-wrapper"> 20 <div id="qv"> 21 <h2>In this document</h2> 22 <ol id="auto-toc"> 23 </ol> 24 </div> 25</div> 26 27<h2 id=physical_environment>Physical environment</h2> 28<h3 id=wifi>Wi-Fi and IPv6</h3> 29<p>CTS tests require a Wi-Fi network that supports IPv6, can treat the Device 30Under Test (DUT) as an isolated client, and has an internet 31connection. An isolated client refers to a 32configuration where the DUT does not have visibility to the 33broadcast/multinetwork messages on that subnetwork, either by a Wi-Fi AP 34configuration or by running the DUT on an isolated sub-network without 35other devices being connected.</p> 36 37<p>If you don't have access to a native IPv6 network, an IPv6 carrier network, 38or a VPN to pass some tests depending on IPv6, you may instead use a Wi-Fi 39access point and an IPv6 tunnel. See Wikipedia <a 40href="http://en.wikipedia.org/wiki/List_of_IPv6_tunnel_brokers">list of IPv6 41tunnel brokers</a>.</p> 42 43<h3 id=ble_beacons>Bluetooth LE beacons</h3> 44<p>If the DUT supports the Bluetooth LE feature, then at least three 45Bluetooth LE beacons should be placed within five meters of the DUT for Bluetooth 46LE scan testing. Those beacons can be any kind, do not need to be 47configured or emit anything specific, and can include iBeacon, 48Eddystone, or even devices simulating BLE beacons.</p> 49 50<h2 id=desktop_setup>Desktop machine setup</h2> 51<p>CTS currently supports 64-bit Linux and Mac OS host machines.</p> 52 53<h3 id=adb>ADB and AAPT</h3> 54<p>Before running the CTS, make sure you have recent versions of both <a 55href="http://developer.android.com/tools/help/adb.html">Android Debug 56Bridge (adb)</a> and <a 57href="http://developer.android.com/guide/topics/manifest/uses-feature-element.html#testing">Android 58Asset Packaging Tool (AAPT)</a> installed and those tools' location added 59to the system path of your machine.</p> 60 61<p>To install ADB, download the <a 62href="http://developer.android.com/sdk/index.html#Other">Android SDK Tools</a> 63package for your operating system, open it, and follow the instructions in the 64included README file. For troubleshooting information, see <a 65href="http://developer.android.com/sdk/installing/index.html?pkg=tools">Installing 66the Stand-alone SDK Tools</a>.</p> 67 68<p>Ensure <code>adb</code> and <code>aapt</code> are in your system path. The 69following command assumes you've opened the package archive in your home 70directory:</p> 71<hr> 72<pre> 73$ export PATH=$PATH:$HOME/android-sdk-linux/build-tools/<version> 74</pre> 75 76<p class="note"><strong>Note:</strong> Please ensure your starting path and 77directory name are correct.</p> 78 79<h3 id=JDK>Java Development Kit (JDK)</h3> 80<p>Install the proper version of the Java Development Kit (JDK). For Android 7.0— 81</p> 82<ul> 83 <li>On Ubuntu, use <a href="http://openjdk.java.net/install/">OpenJDK 8</a>. 84 <li>On Mac OS, use <a 85 href="http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u45-oth-JPR">jdk 86 8u45 or newer</a>.</li> 87</ul> 88<p> 89For details, see the <a href="https://source.android.com/source/requirements.html#jdk">JDK 90requirements</a>. 91</p> 92 93<h3 id=CTS_files>CTS files</h3> 94 95<p><a href="downloads.html">Download</a> and open the CTS 96packages matching your devices' Android version and all the Application Binary 97Interfaces (ABIs) your devices support.</p> 98 99<p>Download and open the latest version of the <a 100href="downloads.html#cts-media-files">CTS Media 101Files</a>.</p> 102 103<h3 id=system_detect>Device detection</h3> 104<p>Follow the step to <a 105href="http://developer.android.com/tools/device.html#setting-up">set up your 106system to detect your device</a>, such as creating a <code>udev</code> rules 107file for Ubuntu Linux.</p> 108 109<h2 id=device_setup>Android device setup</h2> 110 111<h3 id=user_builds>User builds</h3> 112 113<p>A compatible device is defined as a device with a user/release-key signed 114build, so your device should be running a system image based on the known to be 115compatible user build (Android 4.0 and later) from <a 116href="{@docRoot}source/build-numbers.html">Codenames, Tags, and Build 117Numbers</a>.<br> 118 119<p class="caution"><strong>Caution:</strong> When used to confirm Android 120compatibility of your final system image, CTS must be executed on devices with 121a user build.</p> 122 123<h3 id=first-api-level>First API level build property</h3> 124 125<p>Certain CTS requirements depend on the build a device was originally shipped 126with. For example, devices that originally ship with earlier builds may be excluded from 127system requirements that apply to devices that ship with later builds.</p> 128 129<p>To make this information available to CTS, device manufacturers may define 130the build-time property: <code>ro.product.first_api_level</code>. The value of this 131property is the first API level the device was commercially launched with.</p> 132 133<p>OEMs can add <code>PRODUCT_PROPERTY_OVERRIDES</code> into their device.mk file to set 134this property, as shown in the following example: </p> 135 136<pre> 137#ro.product.first_api_level indicates the first api level, device has been commercially launched on. 138PRODUCT_PROPERTY_OVERRIDES +=\ 139ro.product.first_api_level=21 140</pre> 141 142<h3 id=cts-shim-apps>CTS Shim apps</h3> 143 144<p> Android 7.0 includes the following pre-built apps (built from <a 145href="https://android.googlesource.com/platform/frameworks/base/+/master/packages/CtsShim/build/">this 146source</a>) which do not contain any code except for the manifest: </p> 147 148<ul> 149 <li><code><a href="https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r1/packages/CtsShim/CtsShim.apk"> 150 frameworks/base/packages/CtsShim/CtsShim.apk</a></code><br> 151 This apk file is copied to <code>/system/app/CtsShimPrebuilt.apk</code> 152 on the system image. 153 <li><code><a href="https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r1/packages/CtsShim/CtsShimPriv.apk"> 154 frameworks/base/packages/CtsShim/CtsShimPriv.apk</a></code><br> 155 This apk file is copied to <code>/system/priv-app/CtsShimPrivPrebuilt.apk</code> 156 on the system image.</li> 157</ul> 158 159<p> CTS uses these apps to test privileges and permissions. To pass the tests, you must 160preload the apps into the appropriate directories on the system image without 161re-signing them.</p> 162 163<h3 id=storage_requirements>Storage requirements</h3> 164<p>The CTS media stress tests require video clips to be on external storage 165(<code>/sdcard</code>). Most of the clips are from <a 166href="https://peach.blender.org/">Big Buck Bunny</a> which is copyrighted by 167the Blender Foundation under the <a 168href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 license.</a></p> 169<p>The required space depends on the maximum video playback resolution supported 170 by the device (See section 5 in the compatibility definition document for the 171 platform version of the required resolutions.) Note that the video playback 172 capabilities of the device under test will be checked via the <code>android.media.CamcorderProfile</code> APIs for earlier versions of Android and the <code>android.media.MediaCodecInfo.CodecCapabilities</code> APIs from Android 5.0.</p> 173<p>Here are the storage requirements by maximum video playback resolution:</p> 174<ul> 175 <li>480x360: 98MB 176 <li>720x480: 193MB 177 <li>1280x720: 606MB 178 <li>1920x1080: 1863MB 179</ul> 180 181<h3 id=screen_storage>Screen and storage</h3> 182<ol> 183<li>Any device that does not have an embedded screen needs to be connected to a screen.</li> 184<li>If the device has a memory card slot, plug in an empty SD card. <em>Use an 185SD card that supports Ultra High Speed (UHS) Bus with SDHC or SDXC capacity or 186one with at least speed class 10 or higher to ensure it can pass the CTS.</em> 187<p class="warning"><strong>Warning:</strong> CTS may modify/erase data on the SD card plugged into the device.</p> 188</li> 189<li>If the device has SIM card slots, plug in an activated SIM card to each slot. If the device supports SMS, each SIM card should have its own number field populated.</li> 190</li> 191</ol> 192 193<h3 id=developer_uicc>Developer UICC</h3> 194 195<p>In order to run CTS carrier API tests, the device needs to has a SIM card 196with carrier privilege rules on it. See <a 197href="{@docRoot}devices/tech/config/uicc.html#prepare_uicc">Preparing 198the UICC</a>.</p> 199 200<h2 id=config_device>Android device configuration</h2> 201<ol> 202 <li>Factory data reset the device: <strong>Settings > Backup & reset > Factory data reset</strong> 203 <p class="warning"><strong>Warning:</strong> This will erase all user data from the device.</em></p> 204 <li>Set your device's language to English (<strong>United States</strong>) from: <strong>Settings > Language 205 & input > Language</strong> 206 <li>Turn on the location setting if there is a GPS or Wi-Fi / Cellular network 207 feature on the device: <strong>Settings > Location > On</strong> 208 <li>Connect to a Wi-Fi network that supports IPv6, can treat the Device 209Under Test (DUT) as an <em>isolated client</em> (see the <a 210href="#physical_environment">Physical Environment</a> section above), and has an 211internet connection: <strong>Settings > Wi-Fi</strong> 212 <li>Make sure no lock pattern or password is set on the device: <strong>Settings > Security > Screen 213 lock > None</strong> 214 <li>Enable <strong>USB debugging</strong> on your device: <strong>Settings > Developer options > USB debugging</strong>. 215 <p class="note"><strong>Note:</strong> On Android 4.2 and later, <strong>Developer 216 options</strong> is hidden by default. To make them available, go 217 to <strong>Settings > About phone</strong> and tap <strong>Build number</strong> 218 seven times. Return to the previous screen to find <strong>Developer 219 options</strong>. See <a 220 href="http://developer.android.com/studio/run/device.html#developer-device-options">Enabling 221 On-device Developer Options</a> for additional details.</p> 222 <li>Make sure the time is set to 12-hour format: <strong>Settings > Date & time > Use 24-hour format > Off</strong> 223 <li>Select: <strong>Settings > Developer options > Stay Awake > On</strong> 224 <li>Select: <strong>Settings > Developer options > Allow mock locations > On</strong> 225 <p class="note"><strong>Note:</strong> This mock locations setting is applicable only in Android 5.x and 4.4.x.</p> 226 <li>Select: <strong>Settings > Developer options > Verify apps over USB > Off</strong> 227 <p class="note"><strong>Note:</strong> This verify apps step became required in Android 4.2.</p> 228 <li>Launch the browser and dismiss any startup/setup screen. 229 <li>Connect the desktop machine that will be used to test the device with a USB cable 230 <p class="note"><strong>Note:</strong> When you connect a device running Android 4.2.2 or later 231 to your computer, the system shows a dialog asking whether to accept an RSA key that allows 232 debugging through this computer. Select <em>Allow USB debugging</em>.</p> 233 <li> Install and configure helper apps on the device. 234<p class="note"><strong>Note:</strong> For CTS versions 2.1 R2 through 4.2 R4</em>, set up your device (or emulator) 235to run the accessibility tests with:<br> 236<code>adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk</code><br> 237On the device, enable: <strong>Settings > Accessibility > Accessibility > 238Delegating Accessibility Service</strong></p> 239<p class="note"><strong>Note:</strong> For CTS versions prior to 7.0, on devices that declare 240<code>android.software.device_admin</code>, set up your device to run 241the device administration test using:<br> 242<code>adb install -r android-cts/repository/testcases/CtsDeviceAdmin.apk</code><br> 243<p> 244In Settings > Security > Select device administrators, enable the two 245<code>android.deviceadmin.cts.CtsDeviceAdminReceiver*</code> device 246administrators. Ensure the 247<code>android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver</code> and any 248other preloaded device administrators remain disabled. 249</p> 250<li>Copy the CTS media files to the device as follows: 251<p class="note"><strong>Note:</strong> For CTS 2.3 R12 and later, if the 252device supports video codecs, the CTS media files must be copied to the 253device.</p> 254<ul> 255 <li>Navigate (cd) to the path the media files are downloaded and unzipped to. 256 <li>Change the file permissions: <code>chmod u+x copy_media.sh</code> 257 <li>Run <code>copy_media.sh</code>: 258 <ul> 259 <li>To copy clips up to a resolution of 720x480, run: <code>./copy_media.sh 720x480</code> 260 <li>If you are not sure about the maximum resolution, try <code>./copy_media.sh all</code> so that all files are copied. 261 <li>If there are multiple devices under adb, add the -s (serial) option to the end. 262 For example, to copy up to 720x480 to the device with serial 1234567, run: <code>./copy_media.sh 720x480 -s 1234567</code> 263 </ul> 264</ul> 265</ol> 266