1page.title=Working with Devices 2@jd:body 3 4<!-- 5 Copyright 2013 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 20<p>Trade Federation uses an abstraction called 21<code><a href="/reference/com/android/tradefed/device/ITestDevice.html">ITestDevice</a></code> to 22run tests. This abstraction objectifies the lowest-common-denominator Android device:</p> 23<ul> 24<li>It has a serial number</li> 25<li>It has a state: Online, Available, Recovery, or Not Available</li> 26<li>It has some notion of reliability. For instance, if we run a command, we can differentiate 27 between the case where the command hasn't finished yet, the case where the device doesn't support 28 running commands, and the case where the device has become unresponsive while running the 29 command.</li> 30</ul> 31 32<h2>Different Classes of Devices</h2> 33<p>The three primary implementations of <code>ITestDevice</code> represent three common 34usecases.</p> 35 36<h3>Physical Device</h3> 37<p>This is an actual piece of hardware, connected to the TF host machine either by USB, or by using 38adb's TCP feature. The <a href="/reference/com/android/tradefed/device/TestDevice.html" 39>TestDevice</a> class sits atop the ddmlib library, which is a Java interface to adb. So any 40physical device listed in <code>adb devices</code> can be instantiated and used as a 41<code>TestDevice</code>. 42</p> 43 44<h3>Emulator</h3> 45<p>Emulators are handled specially by TF because they live in another process. To interact with an 46Emulator, specify the <code>--emulator</code> argument for the command. See 47<a href="/reference/com/android/tradefed/build/LocalSdkBuildProvider.html" 48>LocalSdkBuildProvider</a> and 49<a href="/reference/com/android/tradefed/targetprep/SdkAvdPreparer.html" 50>SdkAvdPreparer</a> for more info.</p> 51 52<h3>No Device</h3> 53<p>Suppose you have a test that doesn't interact with a device at all. For instance, it might just 54download a file from some service and verify that the file itself is valid. The 55<a href="/reference/com/android/tradefed/device/NullDevice.html" 56>NullDevice</a> is an <code>ITestDevice</code> that is just a stub. It has a serial number like 57<code>null-device-N</code>, and most attempted operations either no-op silently or throw. 58</p> 59