com.android.builder.testing.api
Class DeviceConnector

java.lang.Object
  extended by com.android.builder.testing.api.DeviceConnector
All Implemented Interfaces:
com.android.ddmlib.IShellEnabledDevice

@Beta
public abstract class DeviceConnector
extends java.lang.Object
implements com.android.ddmlib.IShellEnabledDevice

A connector to a device to install/uninstall APKs, and run shell command.


Constructor Summary
DeviceConnector()
           
 
Method Summary
abstract  void connect(int timeOut, com.android.utils.ILogger logger)
          Establishes the connection with the device.
abstract  void disconnect(int timeOut, com.android.utils.ILogger logger)
          Disconnects from the device.
abstract  java.util.List<java.lang.String> getAbis()
          The device supported ABIs.
abstract  java.lang.String getApiCodeName()
          Returns the API codename for the device, or null if it's a release device.
abstract  int getApiLevel()
          Returns the API level of the device, or 0 if it could not be queried.
abstract  int getDensity()
           
abstract  int getHeight()
           
abstract  int getWidth()
           
abstract  void installPackage(java.io.File apkFile, int timeout, com.android.utils.ILogger logger)
          Installs the given APK on the device.
abstract  void pullFile(java.lang.String remote, java.lang.String local)
          Pulls a single file.
abstract  void uninstallPackage(java.lang.String packageName, int timeout, com.android.utils.ILogger logger)
          Uninstall the given package name from the device
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.android.ddmlib.IShellEnabledDevice
executeShellCommand, getName
 

Constructor Detail

DeviceConnector

public DeviceConnector()
Method Detail

connect

public abstract void connect(int timeOut,
                             com.android.utils.ILogger logger)
                      throws com.android.ddmlib.TimeoutException
Establishes the connection with the device. Called before any other actions.

Parameters:
timeOut - the time out.
Throws:
com.android.ddmlib.TimeoutException

disconnect

public abstract void disconnect(int timeOut,
                                com.android.utils.ILogger logger)
                         throws com.android.ddmlib.TimeoutException
Disconnects from the device. No other action is called afterwards.

Parameters:
timeOut - the time out.
Throws:
com.android.ddmlib.TimeoutException

installPackage

public abstract void installPackage(@NonNull
                                    java.io.File apkFile,
                                    int timeout,
                                    com.android.utils.ILogger logger)
                             throws DeviceException
Installs the given APK on the device.

Parameters:
apkFile - the APK file to install.
timeout - the time out.
Throws:
DeviceException

uninstallPackage

public abstract void uninstallPackage(@NonNull
                                      java.lang.String packageName,
                                      int timeout,
                                      com.android.utils.ILogger logger)
                               throws DeviceException
Uninstall the given package name from the device

Parameters:
packageName - the package name
timeout - the time out
Throws:
DeviceException

pullFile

public abstract void pullFile(java.lang.String remote,
                              java.lang.String local)
                       throws java.io.IOException
Pulls a single file.

Parameters:
remote - the full path to the remote file
local - The local destination.
Throws:
java.io.IOException - in case of an IO exception.

getApiLevel

public abstract int getApiLevel()
Returns the API level of the device, or 0 if it could not be queried.

Returns:
the api level

getApiCodeName

public abstract java.lang.String getApiCodeName()
Returns the API codename for the device, or null if it's a release device.

Returns:
the API codename

getAbis

@NonNull
public abstract java.util.List<java.lang.String> getAbis()
The device supported ABIs. This is in preferred order.

Returns:
the list of supported ABIs

getDensity

public abstract int getDensity()

getHeight

public abstract int getHeight()

getWidth

public abstract int getWidth()