INativeDevice
public
interface
INativeDevice
com.android.tradefed.device.INativeDevice |
Provides an reliable and slightly higher level API to a ddmlib IDevice
.
Summary
Constants | |
---|---|
int |
UNKNOWN_API_LEVEL
Default value when API Level cannot be detected |
Public methods | |
---|---|
abstract
boolean
|
checkApiLevelAgainstNextRelease(int strictMinLevel)
Check whether or not a feature is currently supported given a minimally supported level. |
abstract
void
|
clearLogcat()
Deletes any accumulated logcat data. |
abstract
void
|
deleteFile(String deviceFilePath)
Helper method to delete a file or directory on the device. |
abstract
void
|
deleteFile(String deviceFilePath, int userId)
Helper method to delete a file or directory on the device. |
abstract
boolean
|
deviceSoftRestarted(ProcessInfo prevSystemServerProcess)
Helper method to check if device soft-restarted by comparing current system_server with
previous system_server |
abstract
boolean
|
deviceSoftRestartedSince(long utcEpochTime, TimeUnit timeUnit)
Helper method to check whether device soft-restarted since the UTC time since epoch from
device and its |
abstract
boolean
|
disableAdbRoot()
Turns off adb root. |
abstract
boolean
|
doesFileExist(String deviceFilePath)
Helper method to determine if file on device exists. |
abstract
boolean
|
enableAdbRoot()
Turns on adb root. |
abstract
String
|
executeAdbCommand(long timeout, String... commandArgs)
Helper method which executes a adb command as a system command with a specified timeout. |
abstract
String
|
executeAdbCommand(String... commandArgs)
Helper method which executes a adb command as a system command. |
abstract
String
|
executeAdbCommand(long timeout,
Helper method which executes a adb command as a system command with a specified timeout. |
abstract
CommandResult
|
executeFastbootCommand(long timeout, String... commandArgs)
Helper method which executes a fastboot command as a system command. |
abstract
CommandResult
|
executeFastbootCommand(String... commandArgs)
Helper method which executes a fastboot command as a system command with a default timeout of 2 minutes. |
abstract
CommandResult
|
executeLongFastbootCommand(String... commandArgs)
Helper method which executes a long running fastboot command as a system command. |
abstract
CommandResult
|
executeLongFastbootCommand(
Helper method which executes a long running fastboot command as a system command with system environment variables. |
abstract
String
|
executeShellCommand(String command)
Helper method which executes a adb shell command and returns output as a |
abstract
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
void
|
executeShellCommand(String command, IShellOutputReceiver receiver)
Executes the given adb shell command, retrying multiple times if command fails. |
abstract
CommandResult
|
executeShellV2Command(String command)
Helper method which executes a adb shell command and returns the results as a |
abstract
CommandResult
|
executeShellV2Command(String command, OutputStream pipeToOutput)
Helper method which executes an adb shell command and returns the results as a |
abstract
CommandResult
|
executeShellV2Command(String command, File pipeAsInput)
Helper method which executes an adb shell command and returns the results as a |
abstract
CommandResult
|
executeShellV2Command(String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
CommandResult
|
executeShellV2Command(String command, long maxTimeoutForCommand, TimeUnit timeUnit)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
CommandResult
|
executeShellV2Command(String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
CommandResult
|
executeShellV2Command(String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior. |
abstract
CommandResult
|
fastbootWipePartition(String partition)
Helper method which wipes a partition for the device. |
abstract
int
|
getApiLevel()
Get the device API Level. |
abstract
String
|
getBasebandVersion()
Convenience method to get baseband (radio) version of this device. |
abstract
Integer
|
getBattery()
Returns the current battery level of a device or Null if battery level unavailable. |
abstract
boolean
|
getBooleanProperty(String name, boolean defaultValue)
Returns boolean value of the given property. |
abstract
|
getBootHistory()
Helper method collects the boot history map with boot time and boot reason. |
abstract
|
getBootHistorySince(long utcEpochTime, TimeUnit timeUnit)
Helper method collects the boot history map with boot time and boot reason since the given time since epoch from device and the time unit specified. |
abstract
String
|
getBootloaderVersion()
Convenience method to get the bootloader version of this device. |
abstract
String
|
getBuildAlias()
Retrieve the alias of the build that the device is currently running. |
abstract
String
|
getBuildFlavor()
Retrieve the build flavor for the device. |
abstract
String
|
getBuildId()
Retrieve the build the device is currently running. |
abstract
String
|
getBuildSigningKeys()
Returns the key type used to sign the device image Typically Android devices may be signed with test-keys (like in AOSP) or release-keys (controlled by individual device manufacturers) |
abstract
DeviceDescriptor
|
getCachedDeviceDescriptor()
Returns a cached |
abstract
DeviceDescriptor
|
getCachedDeviceDescriptor(boolean shortDescriptor)
Returns a cached |
abstract
String[]
|
getChildren(String deviceFilePath)
Alternative to using |
abstract
AbstractConnection
|
getConnection()
Returns the connection associated with the device. |
abstract
String
|
getDeviceClass()
Get the device class. |
abstract
long
|
getDeviceDate()
Return the date of the device in millisecond since epoch. |
abstract
DeviceDescriptor
|
getDeviceDescriptor()
Return a |
abstract
DeviceDescriptor
|
getDeviceDescriptor(boolean shortDescriptor)
Return a |
abstract
TestDeviceState
|
getDeviceState()
Get the device's state. |
abstract
long
|
getDeviceTimeOffset(Date date)
Helper to get the time difference between the device and a given |
abstract
InputStreamSource
|
getEmulatorOutput()
Get the stream of emulator stdout and stderr |
abstract
long
|
getExternalStoreFreeSpace()
Helper method to determine amount of free space on device external storage. |
abstract
String
|
getFastbootProductType()
Convenience method to get the product type of this device when its in fastboot mode. |
abstract
String
|
getFastbootProductVariant()
Convenience method to get the product type of this device when its in fastboot mode. |
abstract
String
|
getFastbootSerialNumber()
Returns the fastboot mode serial number. |
abstract
String
|
getFastbootVariable(String variableName)
Retrieve the given fastboot variable value from the device. |
abstract
IFileEntry
|
getFileEntry(String path)
Retrieve a reference to a remote file on device. |
abstract
IDevice
|
getIDevice()
Returns a reference to the associated ddmlib |
abstract
long
|
getIntProperty(String name, long defaultValue)
Returns integer value of the given property from the device. |
abstract
long
|
getLastExpectedRebootTimeMillis()
Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as
returned by |
abstract
int
|
getLaunchApiLevel()
Get the device's first launched API Level. |
abstract
InputStreamSource
|
getLogcat()
Grabs a snapshot stream of the logcat data. |
abstract
InputStreamSource
|
getLogcat(int maxBytes)
Grabs a snapshot stream of the last |
abstract
InputStreamSource
|
getLogcatDump()
Get a dump of the current logcat for device. |
abstract
InputStreamSource
|
getLogcatSince(long date)
Grabs a snapshot stream of captured logcat data starting the date provided. |
abstract
String
|
getMountPoint(String mountName)
Returns a mount point. |
abstract
ITestDevice.MountPointInfo
|
getMountPointInfo(String mountpoint)
Returns a |
abstract
|
getMountPointInfo()
Returns a parsed version of the information in /proc/mounts on the device |
abstract
long
|
getPartitionFreeSpace(String partition)
Helper method to determine amount of free space on device partition. |
abstract
ProcessInfo
|
getProcessByName(String processName)
Helper method runs the "pidof" and "stat" command and returns |
abstract
String
|
getProcessPid(String process)
Returns the pid of the service or null if something went wrong. |
abstract
String
|
getProductType()
Convenience method to get the product type of this device. |
abstract
String
|
getProductVariant()
Convenience method to get the product variant of this device. |
abstract
String
|
getProperty(String name)
Retrieve the given property value from the device. |
abstract
ITestDevice.RecoveryMode
|
getRecoveryMode()
Get the current recovery mode used for the device. |
abstract
String
|
getSerialNumber()
Convenience method to get serial number of this device. |
abstract
|
getTombstones()
Fetch and return the list of tombstones from the devices. |
abstract
long
|
getTotalMemory()
Returns total physical memory size in bytes or -1 in case of internal error |
default
String
|
getTrackingSerial()
For device management purpose get the serial used to track the device. |
abstract
boolean
|
getUseFastbootErase()
Get whether to use fastboot erase or fastboot format to wipe a partition on the device. |
abstract
boolean
|
isAdbRoot()
|
abstract
boolean
|
isAdbTcp()
|
abstract
boolean
|
isAppEnumerationSupported()
Check whether platform on device supports app enumeration |
abstract
boolean
|
isBypassLowTargetSdkBlockSupported()
Check whether platform on device supports bypassing low target sdk block on app installs |
abstract
boolean
|
isDebugfsMounted()
Check if debugfs is mounted. |
abstract
boolean
|
isDeviceEncrypted()
Returns if the device is encrypted. |
abstract
boolean
|
isDirectory(String deviceFilePath)
Return True if the path on the device is a directory, false otherwise. |
abstract
boolean
|
isEncryptionSupported()
Returns if encryption is supported on the device. |
abstract
boolean
|
isExecutable(String fullPath)
Returns True if the file path on the device is an executable file, false otherwise. |
abstract
boolean
|
isHeadless()
Return true if the device is headless (no screen), false otherwise. |
abstract
boolean
|
isRuntimePermissionSupported()
Check whether platform on device supports runtime permission granting |
abstract
boolean
|
isStateBootloaderOrFastbootd()
Returns true if device is in |
abstract
boolean
|
logAnrs(ITestLogger logger)
Collects and log ANRs from the device. |
abstract
void
|
logOnDevice(String tag, Log.LogLevel level, String format, Object... args)
Log a message in the logcat of the device. |
abstract
void
|
mountDebugfs()
Mount debugfs. |
abstract
void
|
nonBlockingReboot()
Issues a command to reboot device and returns on command complete and when device is no longer visible to adb. |
abstract
void
|
postBootSetup()
Perform instructions to configure device for testing that after every boot. |
default
void
|
postInvocationTearDown()
This method is deprecated.
Use |
abstract
void
|
postInvocationTearDown(Throwable invocationException)
Extra steps for device specific required clean up that will be executed after the invocation is done. |
default
void
|
preInvocationSetup(IBuildInfo info, MultiMap<String, String> attributes)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow. |
abstract
boolean
|
pullDir(String deviceFilePath, File localDir)
Recursively pull directory contents from device. |
abstract
boolean
|
pullDir(String deviceFilePath, File localDir, int userId)
Recursively pull directory contents from device. |
abstract
File
|
pullFile(String remoteFilePath, int userId)
Retrieves a file off device, stores it in a local temporary |
abstract
File
|
pullFile(String remoteFilePath)
Retrieves a file off device, stores it in a local temporary |
abstract
boolean
|
pullFile(String remoteFilePath, File localFile)
Retrieves a file off device. |
abstract
boolean
|
pullFile(String remoteFilePath, File localFile, int userId)
Retrieves a file off device. |
abstract
String
|
pullFileContents(String remoteFilePath)
Retrieves a file off device, and returns the contents. |
abstract
File
|
pullFileFromExternal(String remoteFilePath)
A convenience method to retrieve a file from the device's external storage, stores it in a
local temporary |
abstract
boolean
|
pushDir(File localDir, String deviceFilePath, int userId)
Recursively push directory contents to device. |
abstract
boolean
|
pushDir(File localDir, String deviceFilePath,
Recursively push directory contents to device while excluding some directories that are filtered. |
abstract
boolean
|
pushDir(File localDir, String deviceFilePath)
Recursively push directory contents to device. |
abstract
boolean
|
pushFile(File localFile, String deviceFilePath, boolean evaluateContentProviderNeeded)
Variant of |
abstract
boolean
|
pushFile(File localFile, String deviceFilePath)
Push a file to device. |
abstract
boolean
|
pushFile(File localFile, String deviceFilePath, int userId)
Push a file to device. |
abstract
boolean
|
pushString(String contents, String deviceFilePath)
Push file created from a string to device |
abstract
void
|
reboot()
Reboots the device into adb mode. |
abstract
void
|
reboot(String reason)
Reboots the device into adb mode with given |
abstract
void
|
rebootIntoBootloader()
Reboots the device into bootloader mode. |
abstract
void
|
rebootIntoFastbootd()
Reboots the device into fastbootd mode. |
abstract
void
|
rebootIntoRecovery()
Reboots the device into adb recovery mode. |
abstract
void
|
rebootIntoSideload(boolean autoReboot)
Reboots the device into adb sideload mode (note that this is a special mode under recovery) Blocks until device enters sideload mode |
abstract
void
|
rebootIntoSideload()
Reboots the device into adb sideload mode (note that this is a special mode under recovery) Blocks until device enters sideload mode |
abstract
void
|
rebootUntilOnline()
An alternate to |
abstract
void
|
rebootUntilOnline(String reason)
An alternate to |
abstract
void
|
rebootUserspace()
Reboots only userspace part of device. |
abstract
void
|
rebootUserspaceUntilOnline()
An alternate to |
abstract
void
|
remountSystemReadOnly()
Make the system partition on the device read-only. |
abstract
void
|
remountSystemWritable()
Make the system partition on the device writable. |
abstract
void
|
remountVendorReadOnly()
Make the vendor partition on the device read-only. |
abstract
void
|
remountVendorWritable()
Make the vendor partition on the device writable. |
abstract
boolean
|
runInstrumentationTests(IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
Convenience method for performing |
abstract
boolean
|
runInstrumentationTests(IRemoteAndroidTestRunner runner,
Runs instrumentation tests, and provides device recovery. |
abstract
boolean
|
runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId,
Same as |
abstract
boolean
|
runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
Same as |
abstract
void
|
setDate(Date date)
Sets the date on device Note: setting date on device requires root |
abstract
void
|
setOptions(TestDeviceOptions options)
Set the |
abstract
boolean
|
setProperty(String propKey, String propValue)
Sets the given property value on the device. |
abstract
void
|
setRecovery(IDeviceRecovery recovery)
Set the |
abstract
void
|
setRecoveryMode(ITestDevice.RecoveryMode mode)
Set the current recovery mode to use for the device. |
abstract
void
|
setTrackingSerial(String trackingSerial)
For device management purpose track the serial we use for referencing the device. |
abstract
void
|
setUseFastbootErase(boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device. |
abstract
void
|
startLogcat()
Start capturing logcat output from device in the background. |
abstract
void
|
stopEmulatorOutput()
Close and delete the emulator output. |
abstract
void
|
stopLogcat()
Stop capturing logcat output from device, and discard currently saved logcat data. |
abstract
String
|
switchToAdbTcp()
Switch device to adb-over-tcp mode. |
abstract
boolean
|
switchToAdbUsb()
Switch device to adb over usb mode. |
abstract
boolean
|
syncFiles(File localFileDir, String deviceFilePath)
Incrementally syncs the contents of a local file directory to device. |
abstract
boolean
|
unlockDevice()
Unlocks the device if the device is in an encrypted state. |
abstract
void
|
unmountDebugfs()
Unmount debugfs. |
abstract
boolean
|
waitForBootComplete(long timeOut)
Blocks until the device's boot complete flag is set. |
abstract
boolean
|
waitForDeviceAvailable()
Waits for the device to be responsive and available for testing. |
abstract
boolean
|
waitForDeviceAvailable(long waitTime)
Waits for the device to be responsive and available for testing. |
abstract
boolean
|
waitForDeviceAvailableInRecoverPath(long waitTime)
Waits for the device to be responsive and available without considering recovery path. |
abstract
void
|
waitForDeviceBootloader()
Blocks until device is visible via fastboot. |
abstract
boolean
|
waitForDeviceInRecovery(long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from
|
abstract
boolean
|
waitForDeviceInSideload(long waitTime)
Blocks for the device to be in the 'adb sideload' state |
abstract
boolean
|
waitForDeviceNotAvailable(long waitTime)
Blocks for the device to be not available ie missing from adb |
abstract
void
|
waitForDeviceOnline()
Blocks until device is visible via adb. |
abstract
void
|
waitForDeviceOnline(long waitTime)
Blocks until device is visible via adb. |
abstract
boolean
|
waitForDeviceShell(long waitTime)
Waits for device to be responsive to a basic adb shell command. |
Constants
UNKNOWN_API_LEVEL
public static final int UNKNOWN_API_LEVEL
Default value when API Level cannot be detected
Constant Value: -1 (0xffffffff)
Public methods
checkApiLevelAgainstNextRelease
public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
Check whether or not a feature is currently supported given a minimally supported level. This method takes into account unreleased features yet, before API level is raised.
Parameters | |
---|---|
strictMinLevel |
int : The strict min possible level that supports the feature. |
Returns | |
---|---|
boolean |
True if the level is supported. False otherwise. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
clearLogcat
public abstract void clearLogcat ()
Deletes any accumulated logcat data.
This is useful for cases when you want to ensureITestDevice#getLogcat()
only returns
log data produced after a certain point (such as after flashing a new device build, etc).
deleteFile
public abstract void deleteFile (String deviceFilePath)
Helper method to delete a file or directory on the device.
Parameters | |
---|---|
deviceFilePath |
String : The absolute path of the file on the device. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
deleteFile
public abstract void deleteFile (String deviceFilePath, int userId)
Helper method to delete a file or directory on the device.
Parameters | |
---|---|
deviceFilePath |
String : The absolute path of the file on the device. |
userId |
int : The user id to delete from |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
deviceSoftRestarted
public abstract boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
Helper method to check if device soft-restarted by comparing current system_server with
previous system_server ProcessInfo
. Use getProcessByName(String)
to get ProcessInfo
.
Parameters | |
---|---|
prevSystemServerProcess |
ProcessInfo : the previous system_server process ProcessInfo . |
Returns | |
---|---|
boolean |
true if device soft-restarted |
Throws | |
---|---|
RuntimeException |
if device has abnormal boot reason |
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
deviceSoftRestartedSince
public abstract boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
Helper method to check whether device soft-restarted since the UTC time since epoch from
device and its ERROR(/TimeUnit)
. Soft-Restart refers to system_server restarted outside of a
device hard reboot (for example: requested reboot). The current device utcEpochTime in
Milliseccond can be obtained by method getDeviceDate()
.
Parameters | |
---|---|
utcEpochTime |
long : the device time in second since epoch. |
timeUnit |
TimeUnit : the time unit TimeUnit for the given utcEpochTime. |
Returns | |
---|---|
boolean |
true if device soft-restarted |
Throws | |
---|---|
RuntimeException |
if device has abnormal boot reason |
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
disableAdbRoot
public abstract boolean disableAdbRoot ()
Turns off adb root.
Disabling adb root may cause device to disconnect from adb. This method will block until device is available.Returns | |
---|---|
boolean |
true if successful. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
doesFileExist
public abstract boolean doesFileExist (String deviceFilePath)
Helper method to determine if file on device exists.
Parameters | |
---|---|
deviceFilePath |
String : the absolute path of file on device to check |
Returns | |
---|---|
boolean |
true if file exists, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
enableAdbRoot
public abstract boolean enableAdbRoot ()
Turns on adb root. If the "enable-root" setting is "false", will log a message and return without enabling root.
Enabling adb root may cause device to disconnect from adb. This method will block until device is available.Returns | |
---|---|
boolean |
true if successful. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeAdbCommand
public abstract String executeAdbCommand (long timeout, String... commandArgs)
Helper method which executes a adb command as a system command with a specified timeout.
executeShellCommand(String)
should be used instead wherever possible, as that
method provides better failure detection and performance.
Parameters | |
---|---|
timeout |
long : the time in milliseconds before the device is considered unresponsive, 0L for
no timeout |
commandArgs |
String : the adb command and arguments to run |
Returns | |
---|---|
String |
the stdout from command. null if command failed to execute. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeAdbCommand
public abstract String executeAdbCommand (String... commandArgs)
Helper method which executes a adb command as a system command.
executeShellCommand(String)
should be used instead wherever possible, as that
method provides better failure detection and performance.
Parameters | |
---|---|
commandArgs |
String : the adb command and arguments to run |
Returns | |
---|---|
String |
the stdout from command. null if command failed to execute. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeAdbCommand
public abstract String executeAdbCommand (long timeout,envMap, String... commandArgs)
Helper method which executes a adb command as a system command with a specified timeout.
executeShellCommand(String)
should be used instead wherever possible, as that
method provides better failure detection and performance.
Parameters | |
---|---|
timeout |
long : the time in milliseconds before the device is considered unresponsive, 0L for
no timeout |
envMap |
: environment to set for the command |
commandArgs |
String : the adb command and arguments to run |
Returns | |
---|---|
String |
the stdout from command. null if command failed to execute. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)
Helper method which executes a fastboot command as a system command.
Expected to be used when device is already in fastboot mode.Parameters | |
---|---|
timeout |
long : the time in milliseconds before the command expire |
commandArgs |
String : the fastboot command and arguments to run |
Returns | |
---|---|
CommandResult |
the CommandResult containing output of command |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (String... commandArgs)
Helper method which executes a fastboot command as a system command with a default timeout of 2 minutes.
Expected to be used when device is already in fastboot mode.
Parameters | |
---|---|
commandArgs |
String : the fastboot command and arguments to run |
Returns | |
---|---|
CommandResult |
the CommandResult containing output of command |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (String... commandArgs)
Helper method which executes a long running fastboot command as a system command.
Identical toexecuteFastbootCommand(String)
except uses a longer timeout.
Parameters | |
---|---|
commandArgs |
String : the fastboot command and arguments to run |
Returns | |
---|---|
CommandResult |
the CommandResult containing output of command |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (envVarMap, String... commandArgs)
Helper method which executes a long running fastboot command as a system command with system environment variables.
Identical to executeFastbootCommand(String)
except uses a longer timeout.
Parameters | |
---|---|
envVarMap |
: the system environment variables that the fastboot command run with |
commandArgs |
String : the fastboot command and arguments to run |
Returns | |
---|---|
CommandResult |
the CommandResult containing output of command |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellCommand
public abstract String executeShellCommand (String command)
Helper method which executes a adb shell command and returns output as a String
.
Parameters | |
---|---|
command |
String : the adb shell command to run |
Returns | |
---|---|
String |
the shell output |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
receiver |
IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
maxTimeToOutputShellResponse |
long : the maximum amount of time during which the command is
allowed to not output any response; unit as specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts |
int : the maximum number of times to retry command if it fails due to a
exception. DeviceNotResponsiveException will be thrown if retryAttempts
are performed without success. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
receiver |
IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
maxTimeoutForCommand |
long : the maximum timeout for the command to complete; unit as
specified in timeUnit |
maxTimeToOutputShellResponse |
long : the maximum amount of time during which the command is
allowed to not output any response; unit as specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts |
int : the maximum number of times to retry command if it fails due to a
exception. DeviceNotResponsiveException will be thrown if retryAttempts are
performed without success. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver)
Executes the given adb shell command, retrying multiple times if command fails.
A simpler form ofexecuteShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
with
default values.
Parameters | |
---|---|
command |
String : the adb shell command to run |
receiver |
IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command)
Helper method which executes a adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Parameters | |
---|---|
command |
String : The command that should be run. |
Returns | |
---|---|
CommandResult |
The result in CommandResult . |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output and stderr. stdout is
directed to the specified stream.
Parameters | |
---|---|
command |
String : The command that should be run. |
pipeToOutput |
OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
Returns | |
---|---|
CommandResult |
The result in CommandResult . |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Parameters | |
---|---|
command |
String : The command that should be run. |
pipeAsInput |
File : A ERROR(/File) that will be piped as input to the command, or null. |
Returns | |
---|---|
CommandResult |
The result in CommandResult . |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
maxTimeoutForCommand |
long : the maximum timeout for the command to complete; unit as
specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts |
int : the maximum number of times to retry command if it fails due to a
exception. DeviceNotResponsiveException will be thrown if retryAttempts are
performed without success. |
Returns | |
---|---|
CommandResult |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
See also:
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
maxTimeoutForCommand |
long : the maximum timeout for the command to complete; unit as
specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
Returns | |
---|---|
CommandResult |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
See also:
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
pipeAsInput |
File : A ERROR(/File) that will be piped as input to the command, or null. |
pipeToOutput |
OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
maxTimeoutForCommand |
long : the maximum timeout for the command to complete; unit as
specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts |
int : the maximum number of times to retry command if it fails due to a
exception. DeviceNotResponsiveException will be thrown if retryAttempts are
performed without success. |
Returns | |
---|---|
CommandResult |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
See also:
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parameters | |
---|---|
command |
String : the adb shell command to run |
pipeAsInput |
File : A ERROR(/File) that will be piped as input to the command, or null. |
pipeToOutput |
OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
pipeToError |
OutputStream : ERROR(/OutputStream) where the std error will be redirected, or null. |
maxTimeoutForCommand |
long : the maximum timeout for the command to complete; unit as
specified in timeUnit |
timeUnit |
TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts |
int : the maximum number of times to retry command if it fails due to a
exception. DeviceNotResponsiveException will be thrown if retryAttempts are
performed without success. |
Returns | |
---|---|
CommandResult |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
See also:
fastbootWipePartition
public abstract CommandResult fastbootWipePartition (String partition)
Helper method which wipes a partition for the device.
IfgetUseFastbootErase()
is true
, then fastboot erase will be used to wipe
the partition. The device must then create a filesystem the next time the device boots.
Otherwise, fastboot format is used which will create a new filesystem on the device.
Expected to be used when device is already in fastboot mode.
Parameters | |
---|---|
partition |
String : the partition to wipe |
Returns | |
---|---|
CommandResult |
the CommandResult containing output of command |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getApiLevel
public abstract int getApiLevel ()
Get the device API Level. Defaults to UNKNOWN_API_LEVEL
.
Returns | |
---|---|
int |
an integer indicating the API Level of device |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBasebandVersion
public abstract String getBasebandVersion ()
Convenience method to get baseband (radio) version of this device. Getting the radio version
is device specific, so it might not return the correct information for all devices. This
method relies on the gsm.version.baseband propery to return the correct version information.
This is not accurate for some CDMA devices and the version returned here might not match
the version reported from fastboot and might not return the version for the CDMA radio.
TL;DR this method only reports accurate version if the gsm.version.baseband property is the
same as the version returned by fastboot getvar version-baseband
.
Returns | |
---|---|
String |
the String baseband version or null if it cannot be determined
(device has no radio or version string cannot be read) |
Throws | |
---|---|
DeviceNotAvailableException |
if the connection with the device is lost and cannot be recovered. |
getBattery
public abstract Integer getBattery ()
Returns the current battery level of a device or Null if battery level unavailable.
Returns | |
---|---|
Integer |
getBooleanProperty
public abstract boolean getBooleanProperty (String name, boolean defaultValue)
Returns boolean value of the given property.
Parameters | |
---|---|
name |
String : the property name |
defaultValue |
boolean : default value to return if property is empty or doesn't exist. |
Returns | |
---|---|
boolean |
true if the property has value "1" , "y" , "yes" ,
"on" , or "true" , false if the property has value of "0" ,
"n" , "no" , "off" , "false" , or defaultValue
otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
getBootHistory
public abstractgetBootHistory ()
Helper method collects the boot history map with boot time and boot reason.
Returns | |
---|---|
|
Map of boot time (UTC time in second since Epoch) and boot reason |
Throws | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
public abstractgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
Helper method collects the boot history map with boot time and boot reason since the given
time since epoch from device and the time unit specified. The current device utcEpochTime in
Millisecond can be obtained by method getDeviceDate()
.
Parameters | |
---|---|
utcEpochTime |
long : the device time since Epoch. |
timeUnit |
TimeUnit : the time unit TimeUnit . |
Returns | |
---|---|
|
Map of boot time (UTC time in second since Epoch) and boot reason |
Throws | |
---|---|
DeviceNotAvailableException |
getBootloaderVersion
public abstract String getBootloaderVersion ()
Convenience method to get the bootloader version of this device.
Will attempt to retrieve bootloader version from the device's current state. (ie if device is in fastboot mode, it will attempt to retrieve version from fastboot)Returns | |
---|---|
String |
the String bootloader version or null if it cannot be found |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getBuildAlias
public abstract String getBuildAlias ()
Retrieve the alias of the build that the device is currently running.
Build alias is usually a more readable string than build id (typically a number for Nexus builds). For example, final Android 4.2 release has build alias JDQ39, and build id 573038
Returns | |
---|---|
String |
the build alias or fall back to build id if it could not be retrieved |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildFlavor
public abstract String getBuildFlavor ()
Retrieve the build flavor for the device.
Returns | |
---|---|
String |
the build flavor or null if it could not be retrieved |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildId
public abstract String getBuildId ()
Retrieve the build the device is currently running.
Returns | |
---|---|
String |
the build id or IBuildInfo#UNKNOWN_BUILD_ID if it could not be retrieved |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildSigningKeys
public abstract String getBuildSigningKeys ()
Returns the key type used to sign the device image
Typically Android devices may be signed with test-keys (like in AOSP) or release-keys (controlled by individual device manufacturers)
Returns | |
---|---|
String |
The signing key if found, null otherwise. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor ()
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the
current DeviceDescriptor
.
Returns | |
---|---|
DeviceDescriptor |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the
current DeviceDescriptor
.
Parameters | |
---|---|
shortDescriptor |
boolean : Whether or not to limit descriptor to bare minimum info |
Returns | |
---|---|
DeviceDescriptor |
getChildren
public abstract String[] getChildren (String deviceFilePath)
Alternative to using IFileEntry
that sometimes won't work because of permissions.
Parameters | |
---|---|
deviceFilePath |
String : is the path on the device where to do the search |
Returns | |
---|---|
String[] |
Array of string containing all the file in a path on the device. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getConnection
public abstract AbstractConnection getConnection ()
Returns the connection associated with the device.
Returns | |
---|---|
AbstractConnection |
getDeviceClass
public abstract String getDeviceClass ()
Get the device class.
Returns | |
---|---|
String |
the String device class. |
getDeviceDate
public abstract long getDeviceDate ()
Return the date of the device in millisecond since epoch.
Returns | |
---|---|
long |
the date of the device in epoch format. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor ()
Return a DeviceDescriptor
from the device information to get info on it without
passing the actual device object.
Returns | |
---|---|
DeviceDescriptor |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
Return a DeviceDescriptor
from the device information to get info on it without
passing the actual device object.
Parameters | |
---|---|
shortDescriptor |
boolean : Whether or not to limit descriptor to bare minimum info |
Returns | |
---|---|
DeviceDescriptor |
getDeviceState
public abstract TestDeviceState getDeviceState ()
Get the device's state.
Returns | |
---|---|
TestDeviceState |
getDeviceTimeOffset
public abstract long getDeviceTimeOffset (Date date)
Helper to get the time difference between the device and a given ERROR(/Date)
. Use Epoch time
internally.
Parameters | |
---|---|
date |
Date |
Returns | |
---|---|
long |
the difference in milliseconds |
Throws | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public abstract InputStreamSource getEmulatorOutput ()
Get the stream of emulator stdout and stderr
Returns | |
---|---|
InputStreamSource |
emulator output |
getExternalStoreFreeSpace
public abstract long getExternalStoreFreeSpace ()
Helper method to determine amount of free space on device external storage.
Returns | |
---|---|
long |
the amount of free space in KB |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getFastbootProductType
public abstract String getFastbootProductType ()
Convenience method to get the product type of this device when its in fastboot mode.
This method should only be used if device should be in fastboot. Its a bit safer variant than the genericgetProductType()
method in this case, because ITestDevice
will know to recover device into fastboot if device is in incorrect state or is
unresponsive.
Returns | |
---|---|
String |
the String product type name or null if it cannot be determined |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getFastbootProductVariant
public abstract String getFastbootProductVariant ()
Convenience method to get the product type of this device when its in fastboot mode.
This method should only be used if device should be in fastboot. Its a bit safer variant than the genericgetProductType()
method in this case, because ITestDevice
will know to recover device into fastboot if device is in incorrect state or is
unresponsive.
Returns | |
---|---|
String |
the String product type name or null if it cannot be determined |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getFastbootSerialNumber
public abstract String getFastbootSerialNumber ()
Returns the fastboot mode serial number.
Returns | |
---|---|
String |
getFastbootVariable
public abstract String getFastbootVariable (String variableName)
Retrieve the given fastboot variable value from the device.
Parameters | |
---|---|
variableName |
String : the variable name |
Returns | |
---|---|
String |
the property value or null if it does not exist |
Throws | |
---|---|
|
UnsupportedOperationException |
DeviceNotAvailableException |
getFileEntry
public abstract IFileEntry getFileEntry (String path)
Retrieve a reference to a remote file on device.
Parameters | |
---|---|
path |
String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie
both "/system" and "system" syntax is supported) |
Returns | |
---|---|
IFileEntry |
the IFileEntry or null if file at given path cannot
be found |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getIDevice
public abstract IDevice getIDevice ()
Returns a reference to the associated ddmlib IDevice
.
IDevice
may be allocated by DDMS each time the device disconnects and
reconnects from adb. Thus callers should not keep a reference to the IDevice
,
because that reference may become stale.
Returns | |
---|---|
IDevice |
the IDevice |
getIntProperty
public abstract long getIntProperty (String name, long defaultValue)
Returns integer value of the given property from the device.
Parameters | |
---|---|
name |
String : the property name |
defaultValue |
long : default value to return if property is empty or doesn't exist. |
Returns | |
---|---|
long |
the property value or defaultValue if the property is empty, doesn't exist,
or doesn't have an integer value. |
Throws | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public abstract long getLastExpectedRebootTimeMillis ()
Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as
returned by System.currentTimeMillis()
.
Returns | |
---|---|
long |
getLaunchApiLevel
public abstract int getLaunchApiLevel ()
Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL
.
Returns | |
---|---|
int |
an integer indicating the first launched API Level of device |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getLogcat
public abstract InputStreamSource getLogcat ()
Grabs a snapshot stream of the logcat data.
Works in two modes:
TestDeviceOptions.getMaxLogcatDataSize()
bytes of the current contents of the background
logcat capture
Returns | |
---|---|
InputStreamSource |
getLogcat
public abstract InputStreamSource getLogcat (int maxBytes)
Grabs a snapshot stream of the last maxBytes
of captured logcat data.
Useful for cases when you want to capture frequent snapshots of the captured logcat data
without incurring the potentially big disk space penalty of getting the entire getLogcat()
snapshot.
Parameters | |
---|---|
maxBytes |
int : the maximum amount of data to return. Should be an amount that can
comfortably fit in memory |
Returns | |
---|---|
InputStreamSource |
getLogcatDump
public abstract InputStreamSource getLogcatDump ()
Get a dump of the current logcat for device. Unlike getLogcat()
, this method will
always return a static dump of the logcat.
Has the disadvantage that nothing will be returned if device is not reachable.
Returns | |
---|---|
InputStreamSource |
a InputStreamSource of the logcat data. An empty stream is returned if fail
to capture logcat data. |
getLogcatSince
public abstract InputStreamSource getLogcatSince (long date)
Grabs a snapshot stream of captured logcat data starting the date provided. The time on the
device should be used getDeviceDate()
.
Parameters | |
---|---|
date |
long : in millisecond since epoch format of when to start the snapshot until present.
(can be be obtained using 'date +%s') |
Returns | |
---|---|
InputStreamSource |
getMountPoint
public abstract String getMountPoint (String mountName)
Returns a mount point.
Queries the device directly if the cached info inIDevice
is not available.
TODO: move this behavior to IDevice#getMountPoint(String)
Parameters | |
---|---|
mountName |
String : the name of the mount point |
Returns | |
---|---|
String |
the mount point or null |
See also:
getMountPointInfo
public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)
Returns a MountPointInfo
corresponding to the specified mountpoint path, or
null
if that path has nothing mounted or otherwise does not appear in
/proc/mounts as a mountpoint.
Parameters | |
---|---|
mountpoint |
String |
Returns | |
---|---|
ITestDevice.MountPointInfo |
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Throws | |
---|---|
DeviceNotAvailableException |
See also:
getMountPointInfo
public abstractgetMountPointInfo ()
Returns a parsed version of the information in /proc/mounts on the device
Returns | |
---|---|
|
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Throws | |
---|---|
DeviceNotAvailableException |
getPartitionFreeSpace
public abstract long getPartitionFreeSpace (String partition)
Helper method to determine amount of free space on device partition.
Parameters | |
---|---|
partition |
String |
Returns | |
---|---|
long |
the amount of free space in KB |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getProcessByName
public abstract ProcessInfo getProcessByName (String processName)
Helper method runs the "pidof" and "stat" command and returns ProcessInfo
object with
PID and process start time of the given process.
Parameters | |
---|---|
processName |
String : the proces name String. |
Returns | |
---|---|
ProcessInfo |
ProcessInfo of given processName |
Throws | |
---|---|
DeviceNotAvailableException |
getProcessPid
public abstract String getProcessPid (String process)
Returns the pid of the service or null if something went wrong.
Parameters | |
---|---|
process |
String : The proces name String. |
Returns | |
---|---|
String |
Throws | |
---|---|
DeviceNotAvailableException |
getProductType
public abstract String getProductType ()
Convenience method to get the product type of this device.
This method will work if device is in either adb or fastboot mode.Returns | |
---|---|
String |
the String product type name. Will not be null |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered, or if product type can not be determined |
getProductVariant
public abstract String getProductVariant ()
Convenience method to get the product variant of this device.
This method will work if device is in either adb or fastboot mode.Returns | |
---|---|
String |
the String product variant name or null if it cannot be
determined |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
getProperty
public abstract String getProperty (String name)
Retrieve the given property value from the device.
Parameters | |
---|---|
name |
String : the property name |
Returns | |
---|---|
String |
the property value or null if it does not exist |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getRecoveryMode
public abstract ITestDevice.RecoveryMode getRecoveryMode ()
Get the current recovery mode used for the device.
Returns | |
---|---|
ITestDevice.RecoveryMode |
the current recovery mode used for the device. |
getSerialNumber
public abstract String getSerialNumber ()
Convenience method to get serial number of this device.
Returns | |
---|---|
String |
the String serial number |
getTombstones
public abstractgetTombstones ()
Fetch and return the list of tombstones from the devices. Requires root.
method is best-effort so if one tombstone fails to be pulled for any reason it will be
missing from the list. Only a DeviceNotAvailableException
will terminate the method
early.
Returns | |
---|---|
|
A list of tombstone files, empty if no tombstone. |
Throws | |
---|---|
DeviceNotAvailableException |
See also:
getTotalMemory
public abstract long getTotalMemory ()
Returns total physical memory size in bytes or -1 in case of internal error
Returns | |
---|---|
long |
getTrackingSerial
public String getTrackingSerial ()
For device management purpose get the serial used to track the device.
Returns | |
---|---|
String |
getUseFastbootErase
public abstract boolean getUseFastbootErase ()
Get whether to use fastboot erase or fastboot format to wipe a partition on the device.
Returns | |
---|---|
boolean |
true if fastboot erase will be used or false if fastboot format will
be used. |
See also:
isAdbRoot
public abstract boolean isAdbRoot ()
Returns | |
---|---|
boolean |
true if device currently has adb root, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
isAdbTcp
public abstract boolean isAdbTcp ()
Returns | |
---|---|
boolean |
true if device is connected to adb-over-tcp, false
otherwise. |
isAppEnumerationSupported
public abstract boolean isAppEnumerationSupported ()
Check whether platform on device supports app enumeration
Returns | |
---|---|
boolean |
True if app enumeration is supported, false otherwise |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isBypassLowTargetSdkBlockSupported
public abstract boolean isBypassLowTargetSdkBlockSupported ()
Check whether platform on device supports bypassing low target sdk block on app installs
Returns | |
---|---|
boolean |
True if bypass low target sdk block is supported, false otherwise |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isDebugfsMounted
public abstract boolean isDebugfsMounted ()
Check if debugfs is mounted.
Returns | |
---|---|
boolean |
true if debugfs is mounted |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isDeviceEncrypted
public abstract boolean isDeviceEncrypted ()
Returns if the device is encrypted.
Returns | |
---|---|
boolean |
true if the device is encrypted. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
isDirectory
public abstract boolean isDirectory (String deviceFilePath)
Return True if the path on the device is a directory, false otherwise.
Parameters | |
---|---|
deviceFilePath |
String |
Returns | |
---|---|
boolean |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isEncryptionSupported
public abstract boolean isEncryptionSupported ()
Returns if encryption is supported on the device.
Returns | |
---|---|
boolean |
true if the device supports encryption. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isExecutable
public abstract boolean isExecutable (String fullPath)
Returns True if the file path on the device is an executable file, false otherwise.
Parameters | |
---|---|
fullPath |
String |
Returns | |
---|---|
boolean |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isHeadless
public abstract boolean isHeadless ()
Return true if the device is headless (no screen), false otherwise.
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public abstract boolean isRuntimePermissionSupported ()
Check whether platform on device supports runtime permission granting
Returns | |
---|---|
boolean |
True if runtime permission are supported, false otherwise. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
isStateBootloaderOrFastbootd
public abstract boolean isStateBootloaderOrFastbootd ()
Returns true if device is in TestDeviceState#FASTBOOT
or TestDeviceState.FASTBOOTD
.
Returns | |
---|---|
boolean |
logAnrs
public abstract boolean logAnrs (ITestLogger logger)
Collects and log ANRs from the device.
Parameters | |
---|---|
logger |
ITestLogger : an ITestLogger to log the ANRs. |
Returns | |
---|---|
boolean |
True if the logging was successful, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
logOnDevice
public abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)
Log a message in the logcat of the device. This is a safe call that will not throw even if the logging fails.
Parameters | |
---|---|
tag |
String : The tag under which we log our message in the logcat. |
level |
Log.LogLevel : The debug level of the message in the logcat. |
format |
String : The message format. |
args |
Object : the args to be replaced via String.format(). |
mountDebugfs
public abstract void mountDebugfs ()
Mount debugfs.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
nonBlockingReboot
public abstract void nonBlockingReboot ()
Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
postBootSetup
public abstract void postBootSetup ()
Perform instructions to configure device for testing that after every boot.
Should be called after device is fully booted/available In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot. Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
postInvocationTearDown
public void postInvocationTearDown ()
This method is deprecated.
Use postInvocationTearDown(Throwable)
instead.
Extra steps for device specific required clean up that will be executed after the invocation is done.
postInvocationTearDown
public abstract void postInvocationTearDown (Throwable invocationException)
Extra steps for device specific required clean up that will be executed after the invocation is done.
Parameters | |
---|---|
invocationException |
Throwable : if any, the final exception raised by the invocation failure. |
preInvocationSetup
public void preInvocationSetup (IBuildInfo info, MultiMap<String, String> attributes)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
Parameters | |
---|---|
info |
IBuildInfo : The IBuildInfo of the device. |
attributes |
MultiMap : The attributes stored in the invocation context |
Throws | |
---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
TargetSetupError |
pullDir
public abstract boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
Parameters | |
---|---|
deviceFilePath |
String : the absolute file path of the remote source |
localDir |
File : the local directory to pull files into |
Returns | |
---|---|
boolean |
true if file was pulled successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullDir
public abstract boolean pullDir (String deviceFilePath, File localDir, int userId)
Recursively pull directory contents from device.
Parameters | |
---|---|
deviceFilePath |
String : the absolute file path of the remote source |
localDir |
File : the local directory to pull files into |
userId |
int : the user id to pull from |
Returns | |
---|---|
boolean |
true if file was pulled successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullFile
public abstract File pullFile (String remoteFilePath, int userId)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that
File
.
Parameters | |
---|---|
remoteFilePath |
String : the absolute path to file on device. |
userId |
int : The user id to pull from |
Returns | |
---|---|
File |
A ERROR(/File) containing the contents of the device file, or null if the
copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullFile
public abstract File pullFile (String remoteFilePath)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that
File
.
Parameters | |
---|---|
remoteFilePath |
String : the absolute path to file on device. |
Returns | |
---|---|
File |
A ERROR(/File) containing the contents of the device file, or null if the
copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullFile
public abstract boolean pullFile (String remoteFilePath, File localFile)
Retrieves a file off device.
Parameters | |
---|---|
remoteFilePath |
String : the absolute path to file on device. |
localFile |
File : the local file to store contents in. If non-empty, contents will be
replaced. |
Returns | |
---|---|
boolean |
true if file was retrieved successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullFile
public abstract boolean pullFile (String remoteFilePath, File localFile, int userId)
Retrieves a file off device.
Parameters | |
---|---|
remoteFilePath |
String : the absolute path to file on device. |
localFile |
File : the local file to store contents in. If non-empty, contents will be
replaced. |
userId |
int : The user id to pull from |
Returns | |
---|---|
boolean |
true if file was retrieved successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pullFileContents
public abstract String pullFileContents (String remoteFilePath)
Retrieves a file off device, and returns the contents.
Parameters | |
---|---|
remoteFilePath |
String : the absolute path to file on device. |
Returns | |
---|---|
String |
A String containing the contents of the device file, or null if the
copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
pullFileFromExternal
public abstract File pullFileFromExternal (String remoteFilePath)
A convenience method to retrieve a file from the device's external storage, stores it in a
local temporary ERROR(/File)
, and return a reference to that File
.
Parameters | |
---|---|
remoteFilePath |
String : the path to file on device, relative to the device's external storage
mountpoint |
Returns | |
---|---|
File |
A ERROR(/File) containing the contents of the device file, or null if the
copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath, int userId)
Recursively push directory contents to device.
Parameters | |
---|---|
localDir |
File : the local directory to push |
deviceFilePath |
String : the absolute file path of the remote destination |
userId |
int : the user id to push to |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath,excludedDirectories)
Recursively push directory contents to device while excluding some directories that are filtered.
Parameters | |
---|---|
localDir |
File : the local directory to push |
deviceFilePath |
String : the absolute file path of the remote destination |
excludedDirectories |
: Set of excluded directories names that shouldn't be pushed. |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath)
Recursively push directory contents to device.
Parameters | |
---|---|
localDir |
File : the local directory to push |
deviceFilePath |
String : the absolute file path of the remote destination |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath, boolean evaluateContentProviderNeeded)
Variant of pushFile(File, String)
which can optionally consider evaluating the need
for the content provider.
Parameters | |
---|---|
localFile |
File : the local file to push |
deviceFilePath |
String : the remote destination absolute file path |
evaluateContentProviderNeeded |
boolean : whether to check if we need the content provider |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath)
Push a file to device. By default using a content provider.
Parameters | |
---|---|
localFile |
File : the local file to push |
deviceFilePath |
String : the remote destination absolute file path |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath, int userId)
Push a file to device. By default using a content provider.
Parameters | |
---|---|
localFile |
File : the local file to push |
deviceFilePath |
String : the remote destination absolute file path |
userId |
int : the userId to push to |
Returns | |
---|---|
boolean |
true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
pushString
public abstract boolean pushString (String contents, String deviceFilePath)
Push file created from a string to device
Parameters | |
---|---|
contents |
String : the contents of the file to push |
deviceFilePath |
String : the remote destination absolute file path |
Returns | |
---|---|
boolean |
true if string was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
reboot
public abstract void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
reboot
public abstract void reboot (String reason)
Reboots the device into adb mode with given reason
to be persisted across reboot.
Blocks until device becomes available.
Last reboot reason can be obtained by querying sys.boot.reason
propety.
Parameters | |
---|---|
reason |
String : a reason for this reboot, or null if no reason is specified. |
Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
rebootIntoBootloader
public abstract void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
rebootIntoFastbootd
public abstract void rebootIntoFastbootd ()
Reboots the device into fastbootd mode.
Blocks until device is in fastbootd mode.
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
rebootIntoRecovery
public abstract void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryThrows | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
rebootIntoSideload
public abstract void rebootIntoSideload (boolean autoReboot)
Reboots the device into adb sideload mode (note that this is a special mode under recovery)
Blocks until device enters sideload mode
Parameters | |
---|---|
autoReboot |
boolean : whether to automatically reboot the device after sideload |
Throws | |
---|---|
DeviceNotAvailableException |
if device is not in sideload after reboot |
rebootIntoSideload
public abstract void rebootIntoSideload ()
Reboots the device into adb sideload mode (note that this is a special mode under recovery)
Blocks until device enters sideload mode
Throws | |
---|---|
DeviceNotAvailableException |
if device is not in sideload after reboot |
rebootUntilOnline
public abstract void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
rebootUntilOnline
public abstract void rebootUntilOnline (String reason)
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Parameters | |
---|---|
reason |
String : a reason for this reboot, or null if no reason is specified. |
Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
See also:
rebootUserspace
public abstract void rebootUserspace ()
Reboots only userspace part of device.
Blocks until device becomes available.
WARNING. Userspace reboot is currently under active development, use it on your own risk.
Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
rebootUserspaceUntilOnline
public abstract void rebootUserspaceUntilOnline ()
An alternate to rebootUserspace()
()} that only blocks until device is online ie
visible to adb.
Throws | |
---|---|
DeviceNotAvailableException |
if device is not available after reboot |
remountSystemReadOnly
public abstract void remountSystemReadOnly ()
Make the system partition on the device read-only. May reboot the device.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
remountSystemWritable
public abstract void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
remountVendorReadOnly
public abstract void remountVendorReadOnly ()
Make the vendor partition on the device read-only. May reboot the device.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
remountVendorWritable
public abstract void remountVendorWritable ()
Make the vendor partition on the device writable. May reboot the device.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection))
with one or more listeners passed as parameters.
Parameters | |
---|---|
runner |
IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
ITestLifeCycleReceiver : the test result listener(s) |
Returns | |
---|---|
boolean |
true if test command completed. false if it failed to
complete, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner,listeners)
Runs instrumentation tests, and provides device recovery.
If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.
If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.
Parameters | |
---|---|
runner |
IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
: the test result listeners |
Returns | |
---|---|
boolean |
true if test command completed. false if it failed to
complete due to device communication exception, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId,listeners)
Same as ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection))
but
runs the test for the given user.
Parameters | |
---|---|
runner |
IRemoteAndroidTestRunner |
userId |
int |
listeners |
|
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner,
ITestLifeCycleReceiver...)
but runs the test for a given user.
Parameters | |
---|---|
runner |
IRemoteAndroidTestRunner |
userId |
int |
listeners |
ITestLifeCycleReceiver |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
setDate
public abstract void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
Parameters | |
---|---|
date |
Date : specify a particular date; will use host date if null |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
setOptions
public abstract void setOptions (TestDeviceOptions options)
Set the TestDeviceOptions
for the device
Parameters | |
---|---|
options |
TestDeviceOptions |
setProperty
public abstract boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
Parameters | |
---|---|
propKey |
String : The key targeted to be set. |
propValue |
String : The property value to be set. |
Returns | |
---|---|
boolean |
returns True if the setprop command was successful, False otherwise. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
setRecovery
public abstract void setRecovery (IDeviceRecovery recovery)
Set the IDeviceRecovery
to use for this device. Should be set when device is first
allocated.
Parameters | |
---|---|
recovery |
IDeviceRecovery : the IDeviceRecovery |
setRecoveryMode
public abstract void setRecoveryMode (ITestDevice.RecoveryMode mode)
Set the current recovery mode to use for the device.
Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etcParameters | |
---|---|
mode |
ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not. |
setTrackingSerial
public abstract void setTrackingSerial (String trackingSerial)
For device management purpose track the serial we use for referencing the device.
Parameters | |
---|---|
trackingSerial |
String |
setUseFastbootErase
public abstract void setUseFastbootErase (boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device.
Parameters | |
---|---|
useFastbootErase |
boolean : true if fastboot erase should be used or false if
fastboot format should be used. |
See also:
startLogcat
public abstract void startLogcat ()
Start capturing logcat output from device in the background.
Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat. When the device is no longer in use,stopLogcat()
must be called.
startLogcat()
and stopLogcat()
do not normally need to be called when
within a TF invocation context, as the TF framework will start and stop logcat.
stopEmulatorOutput
public abstract void stopEmulatorOutput ()
Close and delete the emulator output.
stopLogcat
public abstract void stopLogcat ()
Stop capturing logcat output from device, and discard currently saved logcat data.
Will have no effect if logcat output is not being captured.switchToAdbTcp
public abstract String switchToAdbTcp ()
Switch device to adb-over-tcp mode.
Returns | |
---|---|
String |
the tcp serial number or null if device could not be switched |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
switchToAdbUsb
public abstract boolean switchToAdbUsb ()
Switch device to adb over usb mode.
Returns | |
---|---|
boolean |
true if switch was successful, false otherwise. |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
syncFiles
public abstract boolean syncFiles (File localFileDir, String deviceFilePath)
Incrementally syncs the contents of a local file directory to device.
Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date. Hidden files (with names starting with ".") will be ignored. Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.Parameters | |
---|---|
localFileDir |
File : the local file directory containing files to recursively push. |
deviceFilePath |
String : the remote destination absolute file path root. All directories in thos
file path must be readable. ie pushing to /data/local/tmp when adb is not root
will fail |
Returns | |
---|---|
boolean |
true if files were synced successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
unlockDevice
public abstract boolean unlockDevice ()
Unlocks the device if the device is in an encrypted state.
This method may restart the framework but will not callpostBootSetup()
. Therefore,
the device might not be fully ready to be tested when this method returns.
Returns | |
---|---|
boolean |
true if successful or if the device is unencrypted. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
UnsupportedOperationException |
if encryption is not supported on the device. |
unmountDebugfs
public abstract void unmountDebugfs ()
Unmount debugfs.
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
waitForBootComplete
public abstract boolean waitForBootComplete (long timeOut)
Blocks until the device's boot complete flag is set.
Parameters | |
---|---|
timeOut |
long : time in msecs to wait for the flag to be set |
Returns | |
---|---|
boolean |
true if device's boot complete flag is set within the timeout |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
waitForDeviceAvailable
public abstract boolean waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
Returns | |
---|---|
boolean |
True if device is available, False if recovery is disabled and unavailable. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
waitForDeviceAvailable
public abstract boolean waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Returns | |
---|---|
boolean |
True if device is available, False if recovery is disabled and unavailable. |
Throws | |
---|---|
DeviceNotAvailableException |
if device is still unresponsive after waitTime expires. |
waitForDeviceAvailableInRecoverPath
public abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)
Waits for the device to be responsive and available without considering recovery path.
Parameters | |
---|---|
waitTime |
long |
Returns | |
---|---|
boolean |
True if device is available, False if unavailable. |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
waitForDeviceBootloader
public abstract void waitForDeviceBootloader ()
Blocks until device is visible via fastboot. Use default timeout.
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
waitForDeviceInRecovery
public abstract boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from
IDeviceRecovery
).
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Returns | |
---|---|
boolean |
true if device boots into recovery before time expires.
false otherwise |
waitForDeviceInSideload
public abstract boolean waitForDeviceInSideload (long waitTime)
Blocks for the device to be in the 'adb sideload' state
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Returns | |
---|---|
boolean |
true if device boots into sideload before time expires. false
otherwise |
waitForDeviceNotAvailable
public abstract boolean waitForDeviceNotAvailable (long waitTime)
Blocks for the device to be not available ie missing from adb
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Returns | |
---|---|
boolean |
true if device becomes not available before time expires.
false otherwise |
waitForDeviceOnline
public abstract void waitForDeviceOnline ()
Blocks until device is visible via adb. Uses default timeout
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
waitForDeviceOnline
public abstract void waitForDeviceOnline (long waitTime)
Blocks until device is visible via adb.
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Throws | |
---|---|
DeviceNotAvailableException |
if connection with device is lost and cannot be recovered. |
waitForDeviceShell
public abstract boolean waitForDeviceShell (long waitTime)
Waits for device to be responsive to a basic adb shell command.
Parameters | |
---|---|
waitTime |
long : the time in ms to wait |
Returns | |
---|---|
boolean |
true if device becomes responsive before waitTime elapses. |