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