DeviceImpl
public
final
class
DeviceImpl
extends Object
implements
IDevice
| java.lang.Object | |
| ↳ | com.android.tradefed.device.server.DeviceImpl |
A Device. It can be a physical device or an emulator.
Summary
Public constructors | |
|---|---|
DeviceImpl(ClientTracker clientTracer, String serialNumber, IDevice.DeviceState deviceState)
|
|
Public methods | |
|---|---|
boolean
|
arePropertiesSet()
Returns |
void
|
createForward(int localPort, String remoteSocketName, IDevice.DeviceUnixSocketNamespace namespace)
Creates a port forwarding between a local TCP port and a remote Unix Domain Socket. |
void
|
createForward(int localPort, int remotePort)
Creates a port forwarding between a local and a remote port. |
void
|
createReverse(int remotePort, int localPort)
Creates a port reversing between a remote and a local port. |
void
|
executeBinderCommand(String[] parameters, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, InputStream is)
Executes a Binder command on the device, and sends the result to a receiver This uses exec:cmd |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
Executes a shell command on the device, and sends the result to a receiver. |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, InputStream is)
A version of executeShell command that can take an input stream to send through stdin. |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver)
Executes a shell command on the device, and sends the result to a receiver This is similar to calling |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse)
|
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
Executes a shell command on the device, and sends the result to a receiver. |
void
|
forceStop(String applicationName)
Force stop an application by its application name. |
|
getAbis()
Returns the ABIs supported by this device. |
ListenableFuture<AvdData>
|
getAvdData()
Returns information about the AVD the emulator is running. |
String
|
getAvdName()
Returns the name of the AVD the emulator is running. |
String
|
getAvdPath()
Returns the absolute path to the virtual device in the file system. |
|
getBattery(long freshnessTime, TimeUnit timeUnit)
Return the device's battery level, from 0 to 100 percent. |
|
getBattery()
Return the device's battery level, from 0 to 100 percent. |
Integer
|
getBatteryLevel(long freshnessMs)
Return the device's battery level, from 0 to 100 percent. |
Integer
|
getBatteryLevel()
Return the device's battery level, from 0 to 100 percent. |
ClientImpl
|
getClient(String applicationName)
Returns a |
String
|
getClientName(int pid)
Returns the name of the client by pid or |
ClientTracker
|
getClientTracker()
|
ClientImpl[]
|
getClients()
Returns the array of clients. |
int
|
getDensity()
Returns the density bucket of the device screen by reading the value for system property
|
FileListingService
|
getFileListingService()
Returns a |
String
|
getLanguage()
Returns the user's language. |
InstallMetrics
|
getLastInstallMetrics()
Gets the information about the most recent installation on this device. |
String
|
getMountPoint(String name)
Returns a mount point. |
String
|
getName()
Returns a (humanized) name for this device. |
ClientImpl[]
|
getNativeClients()
|
ClientImpl
|
getNativeClients(String applicationName)
|
ProfileableClientImpl[]
|
getProfileableClients()
Returns the array of profileable clients. |
|
getProperties()
Returns the cached device properties. |
String
|
getProperty(String name)
Convenience method that attempts to retrieve a property via |
String
|
getPropertyCacheOrSync(String name)
A combination of |
int
|
getPropertyCount()
Returns the number of property for this device. |
String
|
getPropertySync(String name)
A variant of |
String
|
getRegion()
Returns the user's region. |
static
String
|
getScreenRecorderCommand(String remoteFilePath, ScreenRecorderOptions options)
|
RawImage
|
getScreenshot()
Takes a screen shot of the device and returns it as a |
RawImage
|
getScreenshot(long timeout, TimeUnit unit)
|
String
|
getSerialNumber()
Returns the serial number of the device. |
IDevice.DeviceState
|
getState()
Returns the state of the device. |
SyncService
|
getSyncService()
Returns a |
ListenableFuture<String>
|
getSystemProperty(String name)
Do a potential asynchronous query for a system property. |
boolean
|
hasClients()
|
void
|
installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)
Installs an Android application on device. |
void
|
installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)
Installs an Android application on device. |
void
|
installPackage(String packageFilePath, boolean reinstall, String... extraArgs)
Installs an Android application on device. |
void
|
installPackages(
Installs an Android application made of several APK files (one main and 0..n split packages) with default timeout |
void
|
installPackages(
Installs an Android application made of several APK files (one main and 0..n split packages) |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)
Installs the application package that was pushed to a temporary location on the device. |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs)
Installs the application package that was pushed to a temporary location on the device. |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)
Installs the application package that was pushed to a temporary location on the device. |
void
|
installRemotePackages(
Installs an Android application made of several APK files sitting locally on the device with default timeout |
void
|
installRemotePackages(
Installs an Android application made of several APK files sitting locally on the device |
boolean
|
isBootLoader()
Returns if the device is in bootloader mode. |
boolean
|
isEmulator()
Returns |
boolean
|
isOffline()
Returns if the device is offline. |
boolean
|
isOnline()
Returns if the device is ready. |
boolean
|
isRoot()
Queries the current root-status of the device. |
void
|
kill(String applicationName)
Kills an application by its application name. |
void
|
pullFile(String remote, String local)
Pulls a single file. |
void
|
push(String[] local, String remote)
Pushes several files or directories. |
void
|
pushFile(String local, String remote)
Pushes a single file. |
SocketChannel
|
rawBinder(String service, String[] parameters)
Invoke the Android Binder Bridge service on a remote device. |
SocketChannel
|
rawExec(String executable, String[] parameters)
Invoke the host:exec service on a remote device. |
void
|
reboot(String into)
Reboot the device. |
void
|
removeForward(int localPort)
Removes a port forwarding between a local and a remote port. |
void
|
removeRemotePackage(String remoteFilePath)
Removes a file from device. |
void
|
removeReverse(int remotePort)
Removes a port reversing between a remote and a local port. |
boolean
|
root()
Ask the adb daemon to become root on the device. |
void
|
startScreenRecorder(String remoteFilePath, ScreenRecorderOptions options, IShellOutputReceiver receiver)
Initiates screen recording on the device if the device supports |
boolean
|
supportsFeature(IDevice.HardwareFeature feature)
Returns whether this device supports the given hardware feature. |
boolean
|
supportsFeature(IDevice.Feature feature)
Returns whether this device supports the given software feature. |
String
|
syncPackageToDevice(String localFilePath)
Pushes a file to device |
String
|
toString()
|
String
|
uninstallApp(String applicationID, String... extraArgs)
Uninstalls an app from the device. |
String
|
uninstallPackage(String packageName)
Uninstalls a package from the device. |
Public constructors
DeviceImpl
public DeviceImpl (ClientTracker clientTracer, String serialNumber, IDevice.DeviceState deviceState)
| Parameters | |
|---|---|
clientTracer |
ClientTracker |
serialNumber |
String |
deviceState |
IDevice.DeviceState |
Public methods
arePropertiesSet
public boolean arePropertiesSet ()
Returns true if properties have been cached
| Returns | |
|---|---|
boolean |
|
createForward
public void createForward (int localPort,
String remoteSocketName,
IDevice.DeviceUnixSocketNamespace namespace)Creates a port forwarding between a local TCP port and a remote Unix Domain Socket.
| Parameters | |
|---|---|
localPort |
int: the local port to forward |
remoteSocketName |
String: name of the unix domain socket created on the device |
namespace |
IDevice.DeviceUnixSocketNamespace: namespace in which the unix domain socket was created |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
createForward
public void createForward (int localPort,
int remotePort)Creates a port forwarding between a local and a remote port.
| Parameters | |
|---|---|
localPort |
int: the local port to forward |
remotePort |
int: the remote port. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
createReverse
public void createReverse (int remotePort,
int localPort)Creates a port reversing between a remote and a local port.
| Parameters | |
|---|---|
remotePort |
int: the remote port to reverse. |
localPort |
int: the local port |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
executeBinderCommand
public void executeBinderCommand (String[] parameters,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
InputStream is)Executes a Binder command on the device, and sends the result to a receiver
This uses exec:cmd
| Parameters | |
|---|---|
parameters |
String: the binder command to execute |
receiver |
IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the binder
command |
maxTimeToOutputResponse |
long |
maxTimeUnits |
TimeUnit |
is |
InputStream: optional input stream to send through stdin |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)Executes a shell command on the device, and sends the result to a receiver.
maxTimeToOutputResponse is used as a maximum waiting time when expecting the
command output from the device.
At any time, if the shell command does not output anything for a period longer than
maxTimeToOutputResponse, then the method will throw ShellCommandUnresponsiveException.
For commands like log output, a maxTimeToOutputResponse value of 0, meaning
that the method will never throw and will block until the receiver's IShellOutputReceiver.isCancelled() returns true, should be used.
| Parameters | |
|---|---|
command |
String: the shell command to execute |
receiver |
IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the shell
command |
maxTimeToOutputResponse |
long: the maximum amount of time during which the command is allowed
to not output any response. A value of 0 means the method will wait forever (until the
receiver cancels the execution) for command output and never throw. |
maxTimeUnits |
TimeUnit: Units for non-zero maxTimeToOutputResponse values. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
InputStream is)A version of executeShell command that can take an input stream to send through stdin.
| Parameters | |
|---|---|
command |
String |
receiver |
IShellOutputReceiver |
maxTimeToOutputResponse |
long |
maxTimeUnits |
TimeUnit |
is |
InputStream |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver)Executes a shell command on the device, and sends the result to a receiver
This is similar to calling
executeShellCommand(command, receiver, DdmPreferences.getTimeOut()).
| Parameters | |
|---|---|
command |
String: the shell command to execute |
receiver |
IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the shell
command |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
int maxTimeToOutputResponse)| Parameters | |
|---|---|
command |
String |
receiver |
IShellOutputReceiver |
maxTimeToOutputResponse |
int |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)Executes a shell command on the device, and sends the result to a receiver.
maxTimeToOutputResponse is used as a maximum waiting time when expecting the
command output from the device.
At any time, if the shell command does not output anything for a period longer than
maxTimeToOutputResponse, then the method will throw ShellCommandUnresponsiveException.
For commands like log output, a maxTimeToOutputResponse value of 0, meaning
that the method will never throw and will block until the receiver's IShellOutputReceiver.isCancelled() returns true, should be used.
| Parameters | |
|---|---|
command |
String: the shell command to execute |
receiver |
IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the shell
command |
maxTimeout |
long: the maximum timeout for the command to return. A value of 0 means no max
timeout will be applied. |
maxTimeToOutputResponse |
long: the maximum amount of time during which the command is allowed
to not output any response. A value of 0 means the method will wait forever (until the
receiver cancels the execution) for command output and never throw. |
maxTimeUnits |
TimeUnit: Units for non-zero maxTimeout and maxTimeToOutputResponse
values. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
forceStop
public void forceStop (String applicationName)
Force stop an application by its application name. This removes all pending alarms and queued computation.
| Parameters | |
|---|---|
applicationName |
String: the name of the application |
getAbis
publicgetAbis ()
Returns the ABIs supported by this device. The ABIs are sorted in preferred order, with the first ABI being the most preferred.
| Returns | |
|---|---|
|
the list of ABIs. |
getAvdData
public ListenableFuture<AvdData> getAvdData ()
Returns information about the AVD the emulator is running.
AvdData.getName is the name of the AVD or null if there isn't any.
AvdData.getPath is the AVD path or null if this is a physical device, the emulator
console subcommand failed, or the emulator's version is older than 30.0.18
| Returns | |
|---|---|
ListenableFuture<AvdData> |
the AvdData for the device. |
getAvdName
public String getAvdName ()
Returns the name of the AVD the emulator is running.
This is only valid if isEmulator() returns true.
If the emulator is not running any AVD (for instance it's running from an Android source
tree build), this method will return "<build>".
Note: Prefer using getAvdData() if you want control over the timeout.
| Returns | |
|---|---|
String |
the name of the AVD or null if there isn't any. |
getAvdPath
public String getAvdPath ()
Returns the absolute path to the virtual device in the file system. The path is operating system dependent; it will have / name separators on Linux and \ separators on Windows.
Note: Prefer using getAvdData() if you want control over the timeout.
| Returns | |
|---|---|
String |
the AVD path or null if this is a physical device, the emulator console subcommand failed, or the emulator's version is older than 30.0.18 |
getBattery
publicgetBattery (long freshnessTime, TimeUnit timeUnit)
Return the device's battery level, from 0 to 100 percent.
The battery level may be cached. Only queries the device for its battery level if
freshnessTime has expired since the last successful query.
| Parameters | |
|---|---|
freshnessTime |
long: the desired recency of battery level |
timeUnit |
TimeUnit: the ERROR(/TimeUnit) of freshnessTime |
| Returns | |
|---|---|
|
a ERROR(/Future) that can be used to query the battery level. The Future will return
a ERROR(/ExecutionException) if battery level could not be retrieved. |
getBattery
publicgetBattery ()
Return the device's battery level, from 0 to 100 percent.
The battery level may be cached. Only queries the device for its battery level if 5 minutes have expired since the last successful query.
| Returns | |
|---|---|
|
a ERROR(/Future) that can be used to query the battery level. The Future will return
a ERROR(/ExecutionException) if battery level could not be retrieved. |
getBatteryLevel
public Integer getBatteryLevel (long freshnessMs)
Return the device's battery level, from 0 to 100 percent.
The battery level may be cached. Only queries the device for its battery level if
freshnessMs ms have expired since the last successful query.
| Returns | |
|---|---|
Integer |
the battery level or null if it could not be retrieved |
getBatteryLevel
public Integer getBatteryLevel ()
Return the device's battery level, from 0 to 100 percent.
The battery level may be cached. Only queries the device for its battery level if 5 minutes have expired since the last successful query.
| Returns | |
|---|---|
Integer |
the battery level or null if it could not be retrieved |
getClient
public ClientImpl getClient (String applicationName)
Returns a Client by its application name.
| Parameters | |
|---|---|
applicationName |
String: the name of the application |
| Returns | |
|---|---|
ClientImpl |
the Client object or null if no match was found. |
getClientName
public String getClientName (int pid)
Returns the name of the client by pid or null if pid is unknown
| Parameters | |
|---|---|
pid |
int: the pid of the client. |
| Returns | |
|---|---|
String |
|
getDensity
public int getDensity ()
Returns the density bucket of the device screen by reading the value for system property
PROP_DEVICE_DENSITY.
| Returns | |
|---|---|
int |
the density, or -1 if it cannot be determined. |
getFileListingService
public FileListingService getFileListingService ()
Returns a FileListingService for this device.
| Returns | |
|---|---|
FileListingService |
|
getLanguage
public String getLanguage ()
Returns the user's language.
| Returns | |
|---|---|
String |
the user's language, or null if it's unknown |
getLastInstallMetrics
public InstallMetrics getLastInstallMetrics ()
Gets the information about the most recent installation on this device.
| Returns | |
|---|---|
InstallMetrics |
InstallMetrics metrics describing the installation. |
getMountPoint
public String getMountPoint (String name)
Returns a mount point.
| Parameters | |
|---|---|
name |
String: the name of the mount point to return |
| Returns | |
|---|---|
String |
|
getName
public String getName ()
Returns a (humanized) name for this device. Typically this is the AVD name for AVD's, and a combination of the manufacturer name, model name & serial number for devices.
| Returns | |
|---|---|
String |
|
getNativeClients
public ClientImpl getNativeClients (String applicationName)
| Parameters | |
|---|---|
applicationName |
String |
| Returns | |
|---|---|
ClientImpl |
|
getProfileableClients
public ProfileableClientImpl[] getProfileableClients ()
Returns the array of profileable clients.
| Returns | |
|---|---|
ProfileableClientImpl[] |
|
getProperties
publicgetProperties ()
Returns the cached device properties. It contains the whole output of 'getprop'
| Returns | |
|---|---|
|
|
getProperty
public String getProperty (String name)
Convenience method that attempts to retrieve a property via IShellEnabledDevice.getSystemProperty(String) with a very short wait time, and swallows exceptions.
Note: Prefer using IShellEnabledDevice.getSystemProperty(String) if you want control over the
timeout.
| Parameters | |
|---|---|
name |
String: the name of the value to return. |
| Returns | |
|---|---|
String |
the value or null if the property value was not immediately available |
getPropertyCacheOrSync
public String getPropertyCacheOrSync (String name)
A combination of getProperty(String) and getPropertySync(String) that will
attempt to retrieve the property from cache. If not found, will synchronously attempt to
query device directly and repopulate the cache if successful.
| Parameters | |
|---|---|
name |
String: the name of the value to return. |
| Returns | |
|---|---|
String |
the value or null if the property does not exist |
getPropertyCount
public int getPropertyCount ()
Returns the number of property for this device.
| Returns | |
|---|---|
int |
|
getPropertySync
public String getPropertySync (String name)
A variant of getProperty(String) that will attempt to retrieve the given property
from device directly, without using cache. This method should (only) be used for any volatile
properties.
| Parameters | |
|---|---|
name |
String: the name of the value to return. |
| Returns | |
|---|---|
String |
the value or null if the property does not exist |
getRegion
public String getRegion ()
Returns the user's region.
| Returns | |
|---|---|
String |
the user's region, or null if it's unknown |
getScreenRecorderCommand
public static String getScreenRecorderCommand (String remoteFilePath,
ScreenRecorderOptions options)| Parameters | |
|---|---|
remoteFilePath |
String |
options |
ScreenRecorderOptions |
| Returns | |
|---|---|
String |
|
getScreenshot
public RawImage getScreenshot ()
Takes a screen shot of the device and returns it as a RawImage.
| Returns | |
|---|---|
RawImage |
the screenshot as a RawImage or null if something went
wrong. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getScreenshot
public RawImage getScreenshot (long timeout, TimeUnit unit)
| Parameters | |
|---|---|
timeout |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
RawImage |
|
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getSerialNumber
public String getSerialNumber ()
Returns the serial number of the device.
| Returns | |
|---|---|
String |
|
getState
public IDevice.DeviceState getState ()
Returns the state of the device.
| Returns | |
|---|---|
IDevice.DeviceState |
|
getSyncService
public SyncService getSyncService ()
Returns a SyncService object to push / pull files to and from the device.
| Returns | |
|---|---|
SyncService |
null if the SyncService couldn't be created. This can happen if adb
refuse to open the connection because the IDevice is invalid (or got
disconnected). |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getSystemProperty
public ListenableFuture<String> getSystemProperty (String name)
Do a potential asynchronous query for a system property.
| Parameters | |
|---|---|
name |
String: the name of the value to return. |
| Returns | |
|---|---|
ListenableFuture<String> |
a ListenableFuture. ERROR(get/Future#get() get) may return
null. |
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
InstallReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
String... extraArgs)Installs an Android application on device. This is a helper method that combines the syncPackageToDevice, installRemotePackage, and removePackage steps
| Parameters | |
|---|---|
packageFilePath |
String: the absolute file system path to file on local host to install |
reinstall |
boolean: set to true if re-install of app should be performed |
receiver |
InstallReceiver: The InstallReceiver to be used to monitor the install and get final
status. |
maxTimeout |
long: the maximum timeout for the command to return. A value of 0 means no max
timeout will be applied. |
maxTimeToOutputResponse |
long: the maximum amount of time during which the command is allowed
to not output any response. A value of 0 means the method will wait forever (until the
receiver cancels the execution) for command output and never throw. |
maxTimeUnits |
TimeUnit: Units for non-zero maxTimeout and maxTimeToOutputResponse
values. |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
InstallReceiver receiver,
String... extraArgs)Installs an Android application on device. This is a helper method that combines the syncPackageToDevice, installRemotePackage, and removePackage steps
| Parameters | |
|---|---|
packageFilePath |
String: the absolute file system path to file on local host to install |
reinstall |
boolean: set to true if re-install of app should be performed |
receiver |
InstallReceiver: The InstallReceiver to be used to monitor the install and get final
status. |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
String... extraArgs)Installs an Android application on device. This is a helper method that combines the syncPackageToDevice, installRemotePackage, and removePackage steps
| Parameters | |
|---|---|
packageFilePath |
String: the absolute file system path to file on local host to install |
reinstall |
boolean: set to true if re-install of app should be performed |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installPackages
public void installPackages (apks, boolean reinstall, installOptions)
Installs an Android application made of several APK files (one main and 0..n split packages) with default timeout
| Parameters | |
|---|---|
apks |
: list of apks to install (1 main APK + 0..n split apks) |
reinstall |
boolean: set to true if re-install of app should be performed |
installOptions |
: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installPackages
public void installPackages (apks, boolean reinstall, installOptions, long timeout, TimeUnit timeoutUnit)
Installs an Android application made of several APK files (one main and 0..n split packages)
| Parameters | |
|---|---|
apks |
: list of apks to install (1 main APK + 0..n split apks) |
reinstall |
boolean: set to true if re-install of app should be performed |
installOptions |
: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
timeout |
long: installation timeout |
timeoutUnit |
TimeUnit: ERROR(/TimeUnit) corresponding to the timeout parameter |
| Throws | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
InstallReceiver receiver,
String... extraArgs)Installs the application package that was pushed to a temporary location on the device.
| Parameters | |
|---|---|
remoteFilePath |
String: absolute file path to package file on device |
reinstall |
boolean: set to true if re-install of app should be performed |
receiver |
InstallReceiver: The InstallReceiver to be used to monitor the install and get final
status. |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
String... extraArgs)Installs the application package that was pushed to a temporary location on the device.
| Parameters | |
|---|---|
remoteFilePath |
String: absolute file path to package file on device |
reinstall |
boolean: set to true if re-install of app should be performed |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
InstallReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
String... extraArgs)Installs the application package that was pushed to a temporary location on the device.
| Parameters | |
|---|---|
remoteFilePath |
String: absolute file path to package file on device |
reinstall |
boolean: set to true if re-install of app should be performed |
receiver |
InstallReceiver: The InstallReceiver to be used to monitor the install and get final
status. |
maxTimeout |
long: the maximum timeout for the command to return. A value of 0 means no max
timeout will be applied. |
maxTimeToOutputResponse |
long: the maximum amount of time during which the command is allowed
to not output any response. A value of 0 means the method will wait forever (until the
receiver cancels the execution) for command output and never throw. |
maxTimeUnits |
TimeUnit: Units for non-zero maxTimeout and maxTimeToOutputResponse
values. |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installRemotePackages
public void installRemotePackages (remoteApks, boolean reinstall, installOptions)
Installs an Android application made of several APK files sitting locally on the device with default timeout
| Parameters | |
|---|---|
remoteApks |
: list of apk file paths on the device to install |
reinstall |
boolean: set to true if re-install of app should be performed |
installOptions |
: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Throws | |
|---|---|
InstallException |
|
installRemotePackages
public void installRemotePackages (remoteApks, boolean reinstall, installOptions, long timeout, TimeUnit timeoutUnit)
Installs an Android application made of several APK files sitting locally on the device
| Parameters | |
|---|---|
remoteApks |
: list of apk file paths sitting on the device to install |
reinstall |
boolean: set to true if re-install of app should be performed |
installOptions |
: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
timeout |
long: installation timeout |
timeoutUnit |
TimeUnit: ERROR(/TimeUnit) corresponding to the timeout parameter |
| Throws | |
|---|---|
InstallException |
|
isBootLoader
public boolean isBootLoader ()
Returns if the device is in bootloader mode.
| Returns | |
|---|---|
boolean |
true if getState() returns DeviceState.BOOTLOADER. |
isEmulator
public boolean isEmulator ()
Returns true if the device is an emulator.
| Returns | |
|---|---|
boolean |
|
isOffline
public boolean isOffline ()
Returns if the device is offline.
| Returns | |
|---|---|
boolean |
true if getState() returns DeviceState.OFFLINE. |
isOnline
public boolean isOnline ()
Returns if the device is ready.
| Returns | |
|---|---|
boolean |
true if getState() returns DeviceState.ONLINE. |
isRoot
public boolean isRoot ()
Queries the current root-status of the device. See "adb root" for more information.
| Returns | |
|---|---|
boolean |
true if the adb daemon is running as root, otherwise false. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
kill
public void kill (String applicationName)
Kills an application by its application name. This only destroy the activities, leaving its state in the Android system alone.
| Parameters | |
|---|---|
applicationName |
String: the name of the application |
pullFile
public void pullFile (String remote,
String local)Pulls a single file.
| Parameters | |
|---|---|
remote |
String: the full path to the remote file |
local |
String: The local destination. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
push
public void push (String[] local,
String remote)Pushes several files or directories.
| Parameters | |
|---|---|
local |
String: the local files to push |
remote |
String: the remote path representing a directory |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
pushFile
public void pushFile (String local,
String remote)Pushes a single file.
| Parameters | |
|---|---|
local |
String: the local filepath. |
remote |
String: the remote filepath |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
rawBinder
public SocketChannel rawBinder (String service,
String[] parameters)Invoke the Android Binder Bridge service on a remote device. Return a socket channel that is connected to the device binder command.
Ownership of the SocketChannel is relinquished to the caller, it must be explicitly closed after usage.
| Parameters | |
|---|---|
service |
String: the name of the Android service to connect to |
parameters |
String: the parameters of the binder command |
| Returns | |
|---|---|
SocketChannel |
A SocketChannel connected to the executing process on the device. after use. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
rawExec
public SocketChannel rawExec (String executable,
String[] parameters)Invoke the host:exec service on a remote device. Return a socket channel that is connected to the executing process. Note that exec service does not differentiate stdout and stderr so whatever is read from the socket can come from either output and be interleaved.
Ownership of the SocketChannel is relinquished to the caller, it must be explicitly closed after usage.
| Parameters | |
|---|---|
executable |
String |
parameters |
String |
| Returns | |
|---|---|
SocketChannel |
A SocketChannel connected to the executing process on the device. after use. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
reboot
public void reboot (String into)
Reboot the device.
| Parameters | |
|---|---|
into |
String: the bootloader name to reboot into, or null to just reboot the device. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeForward
public void removeForward (int localPort)
Removes a port forwarding between a local and a remote port.
| Parameters | |
|---|---|
localPort |
int: the local port to forward |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeRemotePackage
public void removeRemotePackage (String remoteFilePath)
Removes a file from device.
| Parameters | |
|---|---|
remoteFilePath |
String: path on device of file to remove |
| Throws | |
|---|---|
InstallException |
|
removeReverse
public void removeReverse (int remotePort)
Removes a port reversing between a remote and a local port.
| Parameters | |
|---|---|
remotePort |
int: the remote port. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
root
public boolean root ()
Ask the adb daemon to become root on the device. This may silently fail, and can only succeed on developer builds. See "adb root" for more information.
| Returns | |
|---|---|
boolean |
true if the adb daemon is running as root, otherwise false. |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
startScreenRecorder
public void startScreenRecorder (String remoteFilePath,
ScreenRecorderOptions options,
IShellOutputReceiver receiver)Initiates screen recording on the device if the device supports IDevice.Feature.SCREEN_RECORD.
| Parameters | |
|---|---|
remoteFilePath |
String |
options |
ScreenRecorderOptions |
receiver |
IShellOutputReceiver |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
supportsFeature
public boolean supportsFeature (IDevice.HardwareFeature feature)
Returns whether this device supports the given hardware feature.
| Parameters | |
|---|---|
feature |
IDevice.HardwareFeature |
| Returns | |
|---|---|
boolean |
|
supportsFeature
public boolean supportsFeature (IDevice.Feature feature)
Returns whether this device supports the given software feature.
| Parameters | |
|---|---|
feature |
IDevice.Feature |
| Returns | |
|---|---|
boolean |
|
syncPackageToDevice
public String syncPackageToDevice (String localFilePath)
Pushes a file to device
| Parameters | |
|---|---|
localFilePath |
String: the absolute path to file on local host |
| Returns | |
|---|---|
String |
String destination path on device for file |
| Throws | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
toString
public String toString ()
| Returns | |
|---|---|
String |
|
uninstallApp
public String uninstallApp (String applicationID,
String... extraArgs)Uninstalls an app from the device.
| Parameters | |
|---|---|
applicationID |
String: the Android application ID to uninstall |
extraArgs |
String: optional extra arguments to pass. See 'adb shell pm install --help' for
available options. |
| Returns | |
|---|---|
String |
a String with an error code, or null if success. |
| Throws | |
|---|---|
InstallException |
|
uninstallPackage
public String uninstallPackage (String packageName)
Uninstalls a package from the device.
| Parameters | |
|---|---|
packageName |
String: the Android application ID to uninstall |
| Returns | |
|---|---|
String |
a String with an error code, or null if success. |
| Throws | |
|---|---|
InstallException |
|