本地设备

public class NativeDevice
extends Object implements IManagedTestDevice, IConfigurationReceiver

java.lang.Object
com.android.tradefed.device.NativeDevice


ITestDevice非全栈 Android 设备的默认实现。

概括

嵌套类

class NativeDevice.AdbAction

用于运行操作系统“adb ....”命令的DeviceAction

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

用于重新启动设备的DeviceAction

enum NativeDevice.RebootMode

一种重启模式。

常数

int INVALID_USER_ID

为任何无效/未找到的用户 ID 返回的值:UserHandle 定义了 -10000 值

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

执行命令重试的默认次数

领域

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

公共构造函数

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

创建一个TestDevice

公共方法

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

boolean checkConnectivity ()

boolean clearErrorDialogs ()

void clearLastConnectedWifiNetwork ()

void clearLogcat ()

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

int createUser (String name, boolean guest, boolean ephemeral)

int createUser (String name)

int createUserNoThrow (String name)

void deleteFile (String deviceFilePath)

boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

boolean disableAdbRoot ()

void disableKeyguard ()

boolean disableNetworkMonitor ()

boolean disconnectFromWifi ()

boolean doesFileExist (String deviceFilePath)

File dumpHeap (String process, String devicePath)

boolean enableAdbRoot ()

boolean enableNetworkMonitor ()

boolean encryptDevice (boolean inplace)

String executeAdbCommand (long timeout, String... cmdArgs)

String executeAdbCommand (String... cmdArgs)

CommandResult executeFastbootCommand (String... cmdArgs)

CommandResult executeFastbootCommand (long timeout, String... cmdArgs)

CommandResult executeLongFastbootCommand (String... cmdArgs)

String executeShellCommand (String command)

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

void executeShellCommand (String command, IShellOutputReceiver receiver)

CommandResult executeShellV2Command (String cmd)

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

CommandResult fastbootWipePartition (String partition)

getActiveApexes ()

getAllSettings (String namespace)

DeviceAllocationState getAllocationState ()
String getAndroidId (int userId)

getAndroidIds ()

int getApiLevel ()

PackageInfo getAppPackageInfo (String packageName)

getAppPackageInfos ()

String getBasebandVersion ()
Integer getBattery ()

boolean getBooleanProperty (String name, boolean defaultValue)

getBootHistory ()

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

String getBootloaderVersion ()

InputStreamSource getBugreport ()

InputStreamSource getBugreportz ()

String getBuildAlias ()

String getBuildFlavor ()

String getBuildId ()

String getBuildSigningKeys ()

DeviceDescriptor getCachedDeviceDescriptor ()

String[] getChildren (String path)

DeviceFoldableState getCurrentFoldableState ()
int getCurrentUser ()

String getDeviceClass ()

long getDeviceDate ()

DeviceDescriptor getDeviceDescriptor ()

TestDeviceState getDeviceState ()

long getDeviceTimeOffset (Date date)

InputStreamSource getEmulatorOutput ()

Process getEmulatorProcess ()

final File getExecuteShellCommandLog ()

包含所有executeShellCommand(String)日志的日志。

long getExternalStoreFreeSpace ()

String getFastbootPath ()

String getFastbootProductType ()

String getFastbootProductVariant ()

String getFastbootSerialNumber ()

String getFastbootVariable (String variableName)

String getFastbootVersion ()

IFileEntry getFileEntry (String path)

IFileEntry getFileEntry (FileListingService.FileEntry entry)

从非根路径获取FileEntry非官方帮助程序。

getFoldableStates ()
IDevice getIDevice ()

getInstalledPackageNames ()

long getIntProperty (String name, long defaultValue)

String getIpAddress ()

KeyguardControllerState getKeyguardState ()

long getLastExpectedRebootTimeMillis ()

int getLaunchApiLevel ()

InputStreamSource getLogcat ()

InputStreamSource getLogcat (int maxBytes)

InputStreamSource getLogcatDump ()

InputStreamSource getLogcatSince (long date)

String getMacAddress ()

getMainlineModuleInfo ()

int getMaxNumberOfRunningUsersSupported ()
int getMaxNumberOfUsersSupported ()

IDeviceStateMonitor getMonitor ()
String getMountPoint (String mountName)

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

getMountPointInfo ()

TestDeviceOptions getOptions ()

long getPartitionFreeSpace (String partition)

Integer getPrimaryUserId ()

ProcessInfo getProcessByName (String processName)

String getProcessPid (String process)

String getProductType ()

String getProductVariant ()

String getProperty (String name)

ITestDevice.RecoveryMode getRecoveryMode ()

InputStreamSource getScreenshot (String format)

InputStreamSource getScreenshot (long displayId)

InputStreamSource getScreenshot (String format, boolean rescale)

InputStreamSource getScreenshot ()

String getSerialNumber ()

String getSetting (int userId, String namespace, String key)

String getSetting (String namespace, String key)

String getSimOperator ()

String getSimState ()

getTombstones ()

long getTotalMemory ()

getUninstallablePackageNames ()

boolean getUseFastbootErase ()

int getUserFlags (int userId)

getUserInfos ()

int getUserSerialNumber (int userId)

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

处理 DeviceEvent,这可能会也可能不会将该设备转换到新的分配状态。

boolean hasFeature (String feature)

String installPackage (File packageFile, boolean reinstall, String... extraArgs)

String installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)

String installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs)

String installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)

boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

boolean isDeviceEncrypted ()

boolean isDirectory (String path)

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

boolean isExecutable (String fullPath)

boolean isFastbootEnabled ()

boolean isHeadless ()

boolean isMultiUserSupported ()

boolean isPackageInstalled (String packageName, String userId)

boolean isPackageInstalled (String packageName)

boolean isRuntimePermissionSupported ()

boolean isStateBootloaderOrFastbootd ()

boolean isUserRunning (int userId)

boolean isUserSecondary (int userId)

boolean isWifiEnabled ()

listDisplayIds ()

listUsers ()

boolean logBugreport (String dataName, ITestLogger listener)

void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)

void nonBlockingReboot ()

void postAdbRootAction ()

如果设备需要在 adb root 之后和设备重新上线之前执行某些特定操作,则覆盖。

void postAdbUnrootAction ()

如果设备需要在 adb unroot 之后和设备重新上线之前执行某些特定操作,则覆盖。

void postBootSetup ()

void postInvocationTearDown (Throwable exception)

void preInvocationSetup (IBuildInfo info, MultiMap<String, String> attributes)

boolean pullDir (String deviceFilePath, File localDir)

boolean pullFile (String remoteFilePath, File localFile)

File pullFile (String remoteFilePath)

String pullFileContents (String remoteFilePath)

File pullFileFromExternal (String remoteFilePath)

boolean pushDir (File localFileDir, String deviceFilePath, excludedDirectories) pushDir (File localFileDir, String deviceFilePath, excludedDirectories)

boolean pushDir (File localFileDir, String deviceFilePath)

boolean pushFile (File localFile, String remoteFilePath)

boolean pushString (String contents, String remoteFilePath)

void reboot (String reason)

void reboot ()

void rebootIntoBootloader ()

void rebootIntoFastbootd ()

void rebootIntoRecovery ()

void rebootIntoSideload ()

void rebootIntoSideload (boolean autoReboot)

void rebootUntilOnline ()
void rebootUntilOnline (String reason)

void rebootUserspace ()
void rebootUserspaceUntilOnline ()
void recoverDevice ()

尝试恢复设备通信。

void remountSystemWritable ()

void remountVendorWritable ()

boolean removeAdmin (String componentName, int userId)

void removeOwners ()

boolean removeUser (int userId)

void resetContentProviderSetup ()

重置内容提供商设置的标志以便再次触发它。

boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)

boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners)

boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)

boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners)

void setConfiguration ( IConfiguration configuration)

注入正在使用的IConfiguration

void setDate (Date date)

boolean setDeviceOwner (String componentName, int userId)

void setDeviceState (TestDeviceState deviceState)

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

对于模拟器,设置SizeLimitedOutputStream来记录输出

void setEmulatorProcess (Process p)

void setFastbootEnabled (boolean fastbootEnabled)

void setFastbootPath (String fastbootPath)

void setIDevice (IDevice newDevice)

void setOptions (TestDeviceOptions options)

boolean setProperty (String propKey, String propValue)

void setRecovery (IDeviceRecovery recovery)

void setRecoveryMode (ITestDevice.RecoveryMode mode)

void setSetting (String namespace, String key, String value)

void setSetting (int userId, String namespace, String key, String value)

void setUseFastbootErase (boolean useFastbootErase)

void startLogcat ()

boolean startUser (int userId)

boolean startUser (int userId, boolean waitFlag)

void stopEmulatorOutput ()

void stopLogcat ()

boolean stopUser (int userId)

boolean stopUser (int userId, boolean waitFlag, boolean forceFlag)

String switchToAdbTcp ()

boolean switchToAdbUsb ()

boolean switchUser (int userId)

boolean switchUser (int userId, long timeout)

boolean syncFiles (File localFileDir, String deviceFilePath)

Bugreport takeBugreport ()

boolean unencryptDevice ()

String uninstallPackage (String packageName)

String uninstallPackageForUser (String packageName, int userId)

boolean unlockDevice ()

boolean waitForBootComplete (long timeOut)

void waitForDeviceAvailable ()

void waitForDeviceAvailable (long waitTime)

boolean waitForDeviceInRecovery (long waitTime)

boolean waitForDeviceInSideload (long waitTime)

boolean waitForDeviceNotAvailable (long waitTime)

void waitForDeviceOnline ()

void waitForDeviceOnline (long waitTime)

boolean waitForDeviceShell (long waitTime)

受保护的方法

void checkApiLevelAgainst (String feature, int strictMinLevel)
NativeDevice.RebootDeviceAction createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason)

创建要在执行重新启动操作时使用的RebootDeviceAction

void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

执行 adb 重启。

void ensureRuntimePermissionSupported ()

如果不支持运行时权限,则抛出异常的辅助方法

InputStreamSource getBugreportInternal ()
File getBugreportzInternal ()

将 bugreportz zip 文件作为ERROR(/File)获取的内部帮助程序方法。

IRunUtil getRunUtil ()

获取要使用的RunUtil实例。

String internalGetProperty (String propName, String fastbootVar, String description)

默认情况下从 ddmlib 缓存中获取设备属性,然后根据设备是否处于 Fastboot 状态,返回到“adb shell getprop”或“fastboot getvar”。

boolean isNewer (File localFile, IFileEntry entry)

如果本地文件比远程文件新,则返回true

boolean performDeviceAction (String actionDescription, com.android.tradefed.device.NativeDevice.DeviceAction action, int retryAttempts)

在此设备上执行操作。

void postAdbReboot ()

重新启动后可能采取的额外操作。

void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice、TestDevice)覆盖此方法以进行特定的启动后设置。

void setClock (Clock clock)

设置要使用的 Clock 实例。

void setLogStartDelay (int delay)

设置在线设备开始 logcat 捕获之前等待的时间(以毫秒为单位)。

void waitForDeviceNotAvailable (String operationDesc, long time)

常数

INVALID_USER_ID

public static final int INVALID_USER_ID

为任何无效/未找到的用户 ID 返回的值:UserHandle 定义了 -10000 值

常量值:-10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

常量值:5000 (0x0000000000001388)

最多重试次数

protected static final int MAX_RETRY_ATTEMPTS

执行命令重试的默认次数

常量值:2 (0x00000002)

领域

SD卡

protected static final String SD_CARD

存储_模拟

protected static final String STORAGE_EMULATED

m选项

protected TestDeviceOptions mOptions

状态监视器

protected final IDeviceStateMonitor mStateMonitor

公共构造函数

本地设备

public NativeDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)

创建一个TestDevice

参数
device IDevice :关联的IDevice

stateMonitor IDeviceStateMonitor :要使用的IDeviceStateMonitor机制

allocationMonitor IDeviceMonitor :通知分配状态更改的IDeviceMonitor 。可以为空

公共方法

检查 ApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

参数
strictMinLevel int

退货
boolean

投掷
DeviceNotAvailableException

检查连接性

public boolean checkConnectivity ()

退货
boolean

投掷
DeviceNotAvailableException

清除错误对话框

public boolean clearErrorDialogs ()

退货
boolean

投掷
DeviceNotAvailableException

清除上次连接的 Wifi 网络

public void clearLastConnectedWifiNetwork ()

清除Logcat

public void clearLogcat ()

连接到Wifi网络

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

参数
wifiSsid String

wifiPsk String

退货
boolean

投掷
DeviceNotAvailableException

连接到Wifi网络

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

参数
wifiSsid String

wifiPsk String

scanSsid boolean

退货
boolean

投掷
DeviceNotAvailableException

如果需要连接到 Wifi 网络

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

参数
wifiSsid String

wifiPsk String

scanSsid boolean

退货
boolean

投掷
DeviceNotAvailableException

如果需要连接到 Wifi 网络

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

参数
wifiSsid String

wifiPsk String

退货
boolean

投掷
DeviceNotAvailableException

创建用户

public int createUser (String name, 
                boolean guest, 
                boolean ephemeral)

参数
name String

guest boolean

ephemeral boolean

退货
int

投掷
DeviceNotAvailableException

创建用户

public int createUser (String name)

参数
name String

退货
int

投掷
DeviceNotAvailableException

创建用户不抛出

public int createUserNoThrow (String name)

参数
name String

退货
int

投掷
DeviceNotAvailableException

删除文件

public void deleteFile (String deviceFilePath)

参数
deviceFilePath String

投掷
DeviceNotAvailableException

设备软重启

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

参数
prevSystemServerProcess ProcessInfo

退货
boolean

投掷
DeviceNotAvailableException

设备软重启以来

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

参数
utcEpochTime long

timeUnit TimeUnit

退货
boolean

投掷
DeviceNotAvailableException

禁用AdbRoot

public boolean disableAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

禁用键盘锁

public void disableKeyguard ()

投掷
DeviceNotAvailableException

禁用网络监视器

public boolean disableNetworkMonitor ()

退货
boolean

投掷
DeviceNotAvailableException

断开与Wifi的连接

public boolean disconnectFromWifi ()

退货
boolean

投掷
DeviceNotAvailableException

文件是否存在

public boolean doesFileExist (String deviceFilePath)

参数
deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

转储堆

public File dumpHeap (String process, 
                String devicePath)

参数
process String

devicePath String

退货
File

投掷
DeviceNotAvailableException

启用AdbRoot

public boolean enableAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

启用网络监视器

public boolean enableNetworkMonitor ()

退货
boolean

投掷
DeviceNotAvailableException

加密设备

public boolean encryptDevice (boolean inplace)

参数
inplace boolean

退货
boolean

投掷
DeviceNotAvailableException

执行Adb命令

public String executeAdbCommand (long timeout, 
                String... cmdArgs)

参数
timeout long

cmdArgs String

退货
String

投掷
DeviceNotAvailableException

执行Adb命令

public String executeAdbCommand (String... cmdArgs)

参数
cmdArgs String

退货
String

投掷
DeviceNotAvailableException

执行Fastboot命令

public CommandResult executeFastbootCommand (String... cmdArgs)

参数
cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

执行Fastboot命令

public CommandResult executeFastbootCommand (long timeout, 
                String... cmdArgs)

参数
timeout long

cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

执行LongFastboot命令

public CommandResult executeLongFastbootCommand (String... cmdArgs)

参数
cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

执行Shell命令

public String executeShellCommand (String command)

参数
command String

退货
String

投掷
DeviceNotAvailableException

执行Shell命令

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputShellResponse, 
                TimeUnit timeUnit, 
                int retryAttempts)

参数
command String

receiver IShellOutputReceiver

maxTimeToOutputShellResponse long

timeUnit TimeUnit

retryAttempts int

投掷
DeviceNotAvailableException

执行Shell命令

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeoutForCommand, 
                long maxTimeToOutputShellResponse, 
                TimeUnit timeUnit, 
                int retryAttempts)

参数
command String

receiver IShellOutputReceiver

maxTimeoutForCommand long

maxTimeToOutputShellResponse long

timeUnit TimeUnit

retryAttempts int

投掷
DeviceNotAvailableException

执行Shell命令

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

参数
command String

receiver IShellOutputReceiver

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd)

参数
cmd String

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

参数
cmd String

pipeToOutput OutputStream

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

参数
cmd String

pipeAsInput File

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

参数
cmd String

maxTimeoutForCommand long

timeUnit TimeUnit

retryAttempts int

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit)

参数
cmd String

maxTimeoutForCommand long

timeUnit TimeUnit

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

参数
cmd String

pipeAsInput File

pipeToOutput OutputStream

maxTimeoutForCommand long

timeUnit TimeUnit

retryAttempts int

退货
CommandResult

投掷
DeviceNotAvailableException

执行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                OutputStream pipeToError, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

参数
cmd String

pipeAsInput File

pipeToOutput OutputStream

pipeToError OutputStream

maxTimeoutForCommand long

timeUnit TimeUnit

retryAttempts int

退货
CommandResult

投掷
DeviceNotAvailableException

fastboot擦除分区

public CommandResult fastbootWipePartition (String partition)

参数
partition String

退货
CommandResult

投掷
DeviceNotAvailableException

获取活动顶点

public  getActiveApexes ()

退货

投掷
DeviceNotAvailableException

获取所有设置

public  getAllSettings (String namespace)

参数
namespace String

退货

投掷
DeviceNotAvailableException

获取分配状态

public DeviceAllocationState getAllocationState ()

退货
DeviceAllocationState

获取AndroidId

public String getAndroidId (int userId)

参数
userId int

退货
String

投掷
DeviceNotAvailableException

获取AndroidId

public  getAndroidIds ()

退货

投掷
DeviceNotAvailableException

获取API级别

public int getApiLevel ()

退货
int

投掷
DeviceNotAvailableException

获取应用程序包信息

public PackageInfo getAppPackageInfo (String packageName)

参数
packageName String

退货
PackageInfo

投掷
DeviceNotAvailableException

获取应用程序包信息

public  getAppPackageInfos ()

退货

投掷
DeviceNotAvailableException

获取基带版本

public String getBasebandVersion ()

退货
String

投掷
DeviceNotAvailableException

获取电池

public Integer getBattery ()

退货
Integer

获取布尔属性

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

参数
name String

defaultValue boolean

退货
boolean

投掷
DeviceNotAvailableException

获取启动历史记录

public  getBootHistory ()

退货

投掷
DeviceNotAvailableException

获取启动历史记录

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

参数
utcEpochTime long

timeUnit TimeUnit

退货

投掷
DeviceNotAvailableException

获取Bootloader版本

public String getBootloaderVersion ()

退货
String

投掷
DeviceNotAvailableException

获取错误报告

public InputStreamSource getBugreport ()

退货
InputStreamSource

获取错误报告

public InputStreamSource getBugreportz ()

退货
InputStreamSource

获取构建别名

public String getBuildAlias ()

退货
String

投掷
DeviceNotAvailableException

获取BuildFlavor

public String getBuildFlavor ()

退货
String

投掷
DeviceNotAvailableException

获取构建ID

public String getBuildId ()

退货
String

投掷
DeviceNotAvailableException

获取构建签名密钥

public String getBuildSigningKeys ()

退货
String

投掷
DeviceNotAvailableException

获取缓存设备描述符

public DeviceDescriptor getCachedDeviceDescriptor ()

退货
DeviceDescriptor

获取孩子

public String[] getChildren (String path)

参数
path String

退货
String[]

投掷
DeviceNotAvailableException

获取当前可折叠状态

public DeviceFoldableState getCurrentFoldableState ()

退货
DeviceFoldableState

投掷
DeviceNotAvailableException

获取当前用户

public int getCurrentUser ()

退货
int

投掷
DeviceNotAvailableException

获取设备类

public String getDeviceClass ()

退货
String

获取设备日期

public long getDeviceDate ()

退货
long

投掷
DeviceNotAvailableException

获取设备描述符

public DeviceDescriptor getDeviceDescriptor ()

退货
DeviceDescriptor

获取设备状态

public TestDeviceState getDeviceState ()

退货
TestDeviceState

获取设备时间偏移

public long getDeviceTimeOffset (Date date)

参数
date Date

退货
long

投掷
DeviceNotAvailableException

获取模拟器输出

public InputStreamSource getEmulatorOutput ()

退货
InputStreamSource

获取模拟器进程

public Process getEmulatorProcess ()

退货
Process

获取执行Shell命令日志

public final File getExecuteShellCommandLog ()

包含所有executeShellCommand(String)日志的日志。

退货
File

获取外部存储可用空间

public long getExternalStoreFreeSpace ()

退货
long

投掷
DeviceNotAvailableException

获取快速启动路径

public String getFastbootPath ()

退货
String

获取FastbootProductType

public String getFastbootProductType ()

退货
String

投掷
DeviceNotAvailableException

获取FastbootProductVariant

public String getFastbootProductVariant ()

退货
String

投掷
DeviceNotAvailableException

获取Fastboot序列号

public String getFastbootSerialNumber ()

退货
String

获取Fastboot变量

public String getFastbootVariable (String variableName)

参数
variableName String

退货
String

投掷
DeviceNotAvailableException

获取Fastboot版本

public String getFastbootVersion ()

退货
String

获取文件条目

public IFileEntry getFileEntry (String path)

参数
path String

退货
IFileEntry

投掷
DeviceNotAvailableException

获取文件条目

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

从非根路径获取FileEntry非官方帮助程序。 FIXME:重构 FileEntry 系统,使其可以从任何路径访问。 (即使是非根)。

参数
entry FileListingService.FileEntryFileEntry不一定是 Ddmlib 所要求的 root。

退货
IFileEntry代表 FileEntry 的FileEntryWrapper

投掷
DeviceNotAvailableException

获取可折叠状态

public  getFoldableStates ()

退货

投掷
DeviceNotAvailableException

获取设备

public IDevice getIDevice ()

退货
IDevice

获取安装包名称

public  getInstalledPackageNames ()

退货

投掷
DeviceNotAvailableException

获取整数属性

public long getIntProperty (String name, 
                long defaultValue)

参数
name String

defaultValue long

退货
long

投掷
DeviceNotAvailableException

获取IP地址

public String getIpAddress ()

退货
String

投掷
DeviceNotAvailableException

获取KeyguardState

public KeyguardControllerState getKeyguardState ()

退货
KeyguardControllerState

投掷
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

退货
long

获取LaunchApiLevel

public int getLaunchApiLevel ()

退货
int

投掷
DeviceNotAvailableException

获取Logcat

public InputStreamSource getLogcat ()

退货
InputStreamSource

获取Logcat

public InputStreamSource getLogcat (int maxBytes)

参数
maxBytes int

退货
InputStreamSource

获取LogcatDump

public InputStreamSource getLogcatDump ()

退货
InputStreamSource

获取LogcatSince

public InputStreamSource getLogcatSince (long date)

参数
date long

退货
InputStreamSource

获取Mac地址

public String getMacAddress ()

退货
String

获取主线模块信息

public  getMainlineModuleInfo ()

退货

投掷
DeviceNotAvailableException

getMaxNumberOfRunningUsersSupported

public int getMaxNumberOfRunningUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

获取支持的最大用户数

public int getMaxNumberOfUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

获取监视器

public IDeviceStateMonitor getMonitor ()

退货
IDeviceStateMonitor

获取挂载点

public String getMountPoint (String mountName)

参数
mountName String

退货
String

获取挂载点信息

public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

参数
mountpoint String

退货
ITestDevice.MountPointInfo

投掷
DeviceNotAvailableException

获取挂载点信息

public  getMountPointInfo ()

退货

投掷
DeviceNotAvailableException

获取选项

public TestDeviceOptions getOptions ()

退货
TestDeviceOptions

获取分区空闲空间

public long getPartitionFreeSpace (String partition)

参数
partition String

退货
long

投掷
DeviceNotAvailableException

获取主用户ID

public Integer getPrimaryUserId ()

退货
Integer

投掷
DeviceNotAvailableException

按名称获取进程

public ProcessInfo getProcessByName (String processName)

参数
processName String

退货
ProcessInfo

投掷
DeviceNotAvailableException

获取进程Pid

public String getProcessPid (String process)

参数
process String

退货
String

投掷
DeviceNotAvailableException

获取产品类型

public String getProductType ()

退货
String

投掷
DeviceNotAvailableException

获取产品变体

public String getProductVariant ()

退货
String

投掷
DeviceNotAvailableException

获取属性

public String getProperty (String name)

参数
name String

退货
String

投掷
DeviceNotAvailableException

获取恢复模式

public ITestDevice.RecoveryMode getRecoveryMode ()

退货
ITestDevice.RecoveryMode

获取屏幕截图

public InputStreamSource getScreenshot (String format)

参数
format String

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取屏幕截图

public InputStreamSource getScreenshot (long displayId)

参数
displayId long

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取屏幕截图

public InputStreamSource getScreenshot (String format, 
                boolean rescale)

参数
format String

rescale boolean

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取屏幕截图

public InputStreamSource getScreenshot ()

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取序列号

public String getSerialNumber ()

退货
String

获取设置

public String getSetting (int userId, 
                String namespace, 
                String key)

参数
userId int

namespace String

key String

退货
String

投掷
DeviceNotAvailableException

获取设置

public String getSetting (String namespace, 
                String key)

参数
namespace String

key String

退货
String

投掷
DeviceNotAvailableException

获取Sim算子

public String getSimOperator ()

退货
String

获取模拟状态

public String getSimState ()

退货
String

获取墓碑

public  getTombstones ()

退货

投掷
DeviceNotAvailableException

获取总内存

public long getTotalMemory ()

退货
long

获取UninstallablePackageNames

public  getUninstallablePackageNames ()

退货

投掷
DeviceNotAvailableException

getUseFastbootErase

public boolean getUseFastbootErase ()

退货
boolean

获取用户标志

public int getUserFlags (int userId)

参数
userId int

退货
int

投掷
DeviceNotAvailableException

获取用户信息

public  getUserInfos ()

退货

投掷
DeviceNotAvailableException

获取用户序列号

public int getUserSerialNumber (int userId)

参数
userId int

退货
int

投掷
DeviceNotAvailableException

处理分配事件

public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

处理 DeviceEvent,这可能会也可能不会将该设备转换到新的分配状态。

参数
event DeviceEvent

退货
IManagedTestDevice.DeviceEventResponse

有特征

public boolean hasFeature (String feature)

参数
feature String

退货
boolean

投掷
DeviceNotAvailableException

安装包

public String installPackage (File packageFile, 
                boolean reinstall, 
                String... extraArgs)

参数
packageFile File

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装包

public String installPackage (File packageFile, 
                boolean reinstall, 
                boolean grantPermissions, 
                String... extraArgs)

参数
packageFile File

reinstall boolean

grantPermissions boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

为用户安装包

public String installPackageForUser (File packageFile, 
                boolean reinstall, 
                int userId, 
                String... extraArgs)

参数
packageFile File

reinstall boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

为用户安装包

public String installPackageForUser (File packageFile, 
                boolean reinstall, 
                boolean grantPermissions, 
                int userId, 
                String... extraArgs)

参数
packageFile File

reinstall boolean

grantPermissions boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

是AdbRoot

public boolean isAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

是AdbTcp

public boolean isAdbTcp ()

退货
boolean

isAppEnumerationSupported 是否支持

public boolean isAppEnumerationSupported ()

退货
boolean

投掷
DeviceNotAvailableException

设备已加密

public boolean isDeviceEncrypted ()

退货
boolean

投掷
DeviceNotAvailableException

是目录

public boolean isDirectory (String path)

参数
path String

退货
boolean

投掷
DeviceNotAvailableException

isEnableAdbRoot

public boolean isEnableAdbRoot ()

退货
boolean true如果应在设备上启用 adb root

是否支持加密

public boolean isEncryptionSupported ()

退货
boolean

投掷
DeviceNotAvailableException

是可执行文件

public boolean isExecutable (String fullPath)

参数
fullPath String

退货
boolean

投掷
DeviceNotAvailableException

是否启用快速启动

public boolean isFastbootEnabled ()

退货
boolean

是无头的

public boolean isHeadless ()

退货
boolean

投掷
DeviceNotAvailableException

是否支持多用户

public boolean isMultiUserSupported ()

退货
boolean

投掷
DeviceNotAvailableException

软件包已安装

public boolean isPackageInstalled (String packageName, 
                String userId)

参数
packageName String

userId String

退货
boolean

投掷
DeviceNotAvailableException

软件包已安装

public boolean isPackageInstalled (String packageName)

参数
packageName String

退货
boolean

投掷
DeviceNotAvailableException

isRuntimePermissionSupported

public boolean isRuntimePermissionSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isStateBootloaderOrFastbootd

public boolean isStateBootloaderOrFastbootd ()

退货
boolean

正在运行

public boolean isUserRunning (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

是用户次要的

public boolean isUserSecondary (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

是否启用Wifi

public boolean isWifiEnabled ()

退货
boolean

投掷
DeviceNotAvailableException

列表显示 ID

public  listDisplayIds ()

退货

投掷
DeviceNotAvailableException

列出用户

public  listUsers ()

退货

投掷
DeviceNotAvailableException

日志错误报告

public boolean logBugreport (String dataName, 
                ITestLogger listener)

参数
dataName String

listener ITestLogger

退货
boolean

登录设备

public void logOnDevice (String tag, 
                Log.LogLevel level, 
                String format, 
                Object... args)

参数
tag String

level Log.LogLevel

format String

args Object

非阻塞重启

public void nonBlockingReboot ()

投掷
DeviceNotAvailableException

postAdbRoot 操作

public void postAdbRootAction ()

如果设备需要在 adb root 之后和设备重新上线之前执行某些特定操作,则覆盖。默认实现不包括任何附加操作。在此阶段不保证启用 adb root。

投掷
DeviceNotAvailableException

postAdbUnrootAction

public void postAdbUnrootAction ()

如果设备需要在 adb unroot 之后和设备重新上线之前执行某些特定操作,则覆盖。默认实现不包含任何其他操作。在此阶段不保证 adb root 被禁用。

投掷
DeviceNotAvailableException

启动后设置

public void postBootSetup ()

投掷
DeviceNotAvailableException

调用后拆卸

public void postInvocationTearDown (Throwable exception)

参数
exception Throwable

调用前设置

public void preInvocationSetup (IBuildInfo info, 
                MultiMap<String, String> attributes)

参数
info IBuildInfo

attributes MultiMap

投掷
DeviceNotAvailableException
TargetSetupError

拉目录

public boolean pullDir (String deviceFilePath, 
                File localDir)

参数
deviceFilePath String

localDir File

退货
boolean

投掷
DeviceNotAvailableException

拉文件

public boolean pullFile (String remoteFilePath, 
                File localFile)

参数
remoteFilePath String

localFile File

退货
boolean

投掷
DeviceNotAvailableException

拉文件

public File pullFile (String remoteFilePath)

参数
remoteFilePath String

退货
File

投掷
DeviceNotAvailableException

拉取文件内容

public String pullFileContents (String remoteFilePath)

参数
remoteFilePath String

退货
String

投掷
DeviceNotAvailableException

从外部拉文件

public File pullFileFromExternal (String remoteFilePath)

参数
remoteFilePath String

退货
File

投掷
DeviceNotAvailableException

推目录

public boolean pushDir (File localFileDir, 
                String deviceFilePath, 
                 excludedDirectories)

参数
localFileDir File

deviceFilePath String

excludedDirectories

退货
boolean

投掷
DeviceNotAvailableException

推目录

public boolean pushDir (File localFileDir, 
                String deviceFilePath)

参数
localFileDir File

deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

推送文件

public boolean pushFile (File localFile, 
                String remoteFilePath)

参数
localFile File

remoteFilePath String

退货
boolean

投掷
DeviceNotAvailableException

推串

public boolean pushString (String contents, 
                String remoteFilePath)

参数
contents String

remoteFilePath String

退货
boolean

投掷
DeviceNotAvailableException

重启

public void reboot (String reason)

参数
reason String

投掷
DeviceNotAvailableException

重启

public void reboot ()

投掷
DeviceNotAvailableException

重新启动进入引导加载程序

public void rebootIntoBootloader ()

投掷
DeviceNotAvailableException

重新启动进入Fastbootd

public void rebootIntoFastbootd ()

投掷
DeviceNotAvailableException

重新启动进入恢复

public void rebootIntoRecovery ()

投掷
DeviceNotAvailableException

重新启动进入旁载

public void rebootIntoSideload ()

投掷
DeviceNotAvailableException

重新启动进入旁载

public void rebootIntoSideload (boolean autoReboot)

参数
autoReboot boolean

投掷
DeviceNotAvailableException

重新启动直到上线

public void rebootUntilOnline ()

投掷
DeviceNotAvailableException

重新启动直到上线

public void rebootUntilOnline (String reason)

参数
reason String

投掷
DeviceNotAvailableException

重新启动用户空间

public void rebootUserspace ()

投掷
DeviceNotAvailableException

重新启动用户空间直到上线

public void rebootUserspaceUntilOnline ()

投掷
DeviceNotAvailableException

恢复设备

public void recoverDevice ()

尝试恢复设备通信。

投掷
DeviceNotAvailableException如果设备不再可用

重新挂载系统可写

public void remountSystemWritable ()

投掷
DeviceNotAvailableException

重新挂载VendorWritable

public void remountVendorWritable ()

投掷
DeviceNotAvailableException

删除管理员

public boolean removeAdmin (String componentName, 
                int userId)

参数
componentName String

userId int

退货
boolean

投掷
DeviceNotAvailableException

删除所有者

public void removeOwners ()

投掷
DeviceNotAvailableException

删除用户

public boolean removeUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

重置ContentProvider设置

public void resetContentProviderSetup ()

重置内容提供商设置的标志以便再次触发它。

运行仪器测试

public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                ITestLifeCycleReceiver... listeners)

参数
runner IRemoteAndroidTestRunner

listeners ITestLifeCycleReceiver

退货
boolean

投掷
DeviceNotAvailableException

运行仪器测试

public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                 listeners)

参数
runner IRemoteAndroidTestRunner

listeners

退货
boolean

投掷
DeviceNotAvailableException

以用户身份运行仪器测试

public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, 
                int userId, 
                ITestLifeCycleReceiver... listeners)

参数
runner IRemoteAndroidTestRunner

userId int

listeners ITestLifeCycleReceiver

退货
boolean

投掷
DeviceNotAvailableException

以用户身份运行仪器测试

public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, 
                int userId, 
                 listeners)

参数
runner IRemoteAndroidTestRunner

userId int

listeners

退货
boolean

投掷
DeviceNotAvailableException

设置配置

public void setConfiguration (IConfiguration configuration)

注入正在使用的IConfiguration

参数
configuration IConfiguration

设置日期

public void setDate (Date date)

参数
date Date

投掷
DeviceNotAvailableException

设置设备所有者

public boolean setDeviceOwner (String componentName, 
                int userId)

参数
componentName String

userId int

退货
boolean

投掷
DeviceNotAvailableException

设置设备状态

public void setDeviceState (TestDeviceState deviceState)

参数
deviceState TestDeviceState

设置模拟器输出流

public void setEmulatorOutputStream (SizeLimitedOutputStream output)

对于模拟器,设置SizeLimitedOutputStream来记录输出

参数
output SizeLimitedOutputStream :记录输出

设置模拟器进程

public void setEmulatorProcess (Process p)

参数
p Process

设置快速启动启用

public void setFastbootEnabled (boolean fastbootEnabled)

参数
fastbootEnabled boolean

设置快速启动路径

public void setFastbootPath (String fastbootPath)

参数
fastbootPath String

设置设备

public void setIDevice (IDevice newDevice)

参数
newDevice IDevice

设置选项

public void setOptions (TestDeviceOptions options)

参数
options TestDeviceOptions

设置属性

public boolean setProperty (String propKey, 
                String propValue)

参数
propKey String

propValue String

退货
boolean

投掷
DeviceNotAvailableException

设置恢复

public void setRecovery (IDeviceRecovery recovery)

参数
recovery IDeviceRecovery

设置恢复模式

public void setRecoveryMode (ITestDevice.RecoveryMode mode)

参数
mode ITestDevice.RecoveryMode

设置设置

public void setSetting (String namespace, 
                String key, 
                String value)

参数
namespace String

key String

value String

投掷
DeviceNotAvailableException

设置设置

public void setSetting (int userId, 
                String namespace, 
                String key, 
                String value)

参数
userId int

namespace String

key String

value String

投掷
DeviceNotAvailableException

设置使用FastbootErase

public void setUseFastbootErase (boolean useFastbootErase)

参数
useFastbootErase boolean

启动Logcat

public void startLogcat ()

启动用户

public boolean startUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

启动用户

public boolean startUser (int userId, 
                boolean waitFlag)

参数
userId int

waitFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

停止模拟器输出

public void stopEmulatorOutput ()

停止Logcat

public void stopLogcat ()

停止用户

public boolean stopUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

停止用户

public boolean stopUser (int userId, 
                boolean waitFlag, 
                boolean forceFlag)

参数
userId int

waitFlag boolean

forceFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

切换到AdbTcp

public String switchToAdbTcp ()

退货
String

投掷
DeviceNotAvailableException

切换到AdbUsb

public boolean switchToAdbUsb ()

退货
boolean

投掷
DeviceNotAvailableException

切换用户

public boolean switchUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

切换用户

public boolean switchUser (int userId, 
                long timeout)

参数
userId int

timeout long

退货
boolean

投掷
DeviceNotAvailableException

同步文件

public boolean syncFiles (File localFileDir, 
                String deviceFilePath)

参数
localFileDir File

deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

采取错误报告

public Bugreport takeBugreport ()

退货
Bugreport

解密设备

public boolean unencryptDevice ()

退货
boolean

投掷
DeviceNotAvailableException

卸载包

public String uninstallPackage (String packageName)

参数
packageName String

退货
String

投掷
DeviceNotAvailableException

卸载用户包

public String uninstallPackageForUser (String packageName, 
                int userId)

参数
packageName String

userId int

退货
String

投掷
DeviceNotAvailableException

解锁设备

public boolean unlockDevice ()

退货
boolean

投掷
DeviceNotAvailableException

等待启动完成

public boolean waitForBootComplete (long timeOut)

参数
timeOut long

退货
boolean

投掷
DeviceNotAvailableException

等待设备可用

public void waitForDeviceAvailable ()

投掷
DeviceNotAvailableException

等待设备可用

public void waitForDeviceAvailable (long waitTime)

参数
waitTime long

投掷
DeviceNotAvailableException

等待设备恢复

public boolean waitForDeviceInRecovery (long waitTime)

参数
waitTime long

退货
boolean

waitForDeviceInSideload

public boolean waitForDeviceInSideload (long waitTime)

参数
waitTime long

退货
boolean

等待设备不可用

public boolean waitForDeviceNotAvailable (long waitTime)

参数
waitTime long

退货
boolean

等待设备在线

public void waitForDeviceOnline ()

投掷
DeviceNotAvailableException

等待设备在线

public void waitForDeviceOnline (long waitTime)

参数
waitTime long

投掷
DeviceNotAvailableException

等待设备外壳

public boolean waitForDeviceShell (long waitTime)

参数
waitTime long

退货
boolean

受保护的方法

检查ApiLevelAgainst

protected void checkApiLevelAgainst (String feature, 
                int strictMinLevel)

参数
feature String

strictMinLevel int

创建重启设备操作

protected NativeDevice.RebootDeviceAction createRebootDeviceAction (NativeDevice.RebootMode rebootMode, 
                String reason)

创建要在执行重新启动操作时使用的RebootDeviceAction

参数
rebootMode NativeDevice.RebootMode :重启的一种模式。

reason String :用于此次重新启动。

退货
NativeDevice.RebootDeviceAction创建的RebootDeviceAction

执行AdbReboot

protected void doAdbReboot (NativeDevice.RebootMode rebootMode, 
                String reason)

执行 adb 重启。

参数
rebootMode NativeDevice.RebootMode :重启的一种模式。

reason String :用于此次重新启动。

投掷
DeviceNotAvailableException

确保运行时权限支持

protected void ensureRuntimePermissionSupported ()

如果不支持运行时权限,则抛出异常的辅助方法

投掷
DeviceNotAvailableException

获取错误报告内部

protected InputStreamSource getBugreportInternal ()

退货
InputStreamSource

获取 BugreportzInternal

protected File getBugreportzInternal ()

将 bugreportz zip 文件作为ERROR(/File)获取的内部帮助程序方法。

退货
File

获取运行工具

protected IRunUtil getRunUtil ()

获取要使用的RunUtil实例。

退货
IRunUtil

内部获取属性

protected String internalGetProperty (String propName, 
                String fastbootVar, 
                String description)

默认情况下,从 ddmlib 缓存中获取设备属性,然后根据设备是否处于 Fastboot 状态,返回到“adb shell getprop”或“fastboot getvar”。

参数
propName String : `adb shell getprop` 返回的设备属性的名称

fastbootVar String :要查询的等效 fastboot 变量的名称。如果为null ,则不会尝试 fastboot 查询

description String :变量的简单描述。第一个字母应大写。

退货
String一个字符串,可能为null或空,包含给定属性的值

投掷
DeviceNotAvailableException

较新

protected boolean isNewer (File localFile, 
                IFileEntry entry)

如果本地文件比远程文件新,则返回trueIFileEntry精确到分钟,如果次数相等,则认为该文件较新。

参数
localFile File

entry IFileEntry

退货
boolean

执行设备操作

protected boolean performDeviceAction (String actionDescription, 
                com.android.tradefed.device.NativeDevice.DeviceAction action, 
                int retryAttempts)

在此设备上执行操作。如果操作失败,则尝试恢复设备并可选择重试命令。

参数
actionDescription String :要执行的操作的简短描述。仅用于记录目的。

action com.android.tradefed.device.NativeDevice.DeviceAction :要执行的操作

retryAttempts int :如果失败但恢复成功,则重试尝试执行操作

退货
boolean true如果操作执行成功

投掷
DeviceNotAvailableException如果恢复尝试失败或最大尝试次数未成功

Adb重启后

protected void postAdbReboot ()

重新启动后可能采取的额外操作。

投掷
DeviceNotAvailableException

启动后设置前

protected void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice、TestDevice)覆盖此方法以进行特定的启动后设置。

投掷
DeviceNotAvailableException

设置时钟

protected void setClock (Clock clock)

设置要使用的 Clock 实例。

参数
clock Clock

设置日志开始延迟

protected void setLogStartDelay (int delay)

设置在线设备开始 logcat 捕获之前等待的时间(以毫秒为单位)。

参数
delay int : 延迟(以毫秒为单位)

等待设备不可用

protected void waitForDeviceNotAvailable (String operationDesc, 
                long time)

参数
operationDesc String

time long