Google 致力于为黑人社区推动种族平等。查看具体举措
此页面由 Cloud Translation API 翻译。
Switch to English

本机设备

public class NativeDevice
extends Object implements IManagedTestDevice

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


ITestDevice默认实现非全栈android设备。

摘要

嵌套类

class NativeDevice.AdbAction

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

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 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 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)

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 getFastbootVariable (String variableName)

String getFastbootVersion ()

IFileEntry getFileEntry (String path)

IFileEntry getFileEntry (FileListingService.FileEntry entry)

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

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 ()

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)

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)

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 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)

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)内部Helper方法。

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)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

默认的命令重试次数

常数值:2(0x00000002)

领域

SD卡

protected static final String SD_CARD

选项

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

公共建设者

本机设备

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

创建一个TestDevice

参量
device IDevice :关联的IDevice

stateMonitor IDeviceStateMonitor :要使用的IDeviceStateMonitor机制

allocationMonitor IDeviceMonitorIDeviceMonitor通知分配状态更改。可以为空

公开方法

checkApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

参量
strictMinLevel int

退货
boolean

投掷
DeviceNotAvailableException

checkConnectivity

public boolean checkConnectivity ()

退货
boolean

投掷
DeviceNotAvailableException

clearErrorDialogs

public boolean clearErrorDialogs ()

退货
boolean

投掷
DeviceNotAvailableException

clearLastConnectedWifiNetwork

public void clearLastConnectedWifiNetwork ()

clearLogcat

public void clearLogcat ()

connectToWifiNetwork

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

参量
wifiSsid String

wifiPsk String

退货
boolean

投掷
DeviceNotAvailableException

connectToWifiNetwork

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

createUserNoThrow

public int createUserNoThrow (String name)

参量
name String

退货
int

投掷
DeviceNotAvailableException

删除文件

public void deleteFile (String deviceFilePath)

参量
deviceFilePath String

投掷
DeviceNotAvailableException

deviceSoftRestarted

0

参量
prevSystemServerProcess ProcessInfo

退货
boolean

投掷
DeviceNotAvailableException

deviceSoftRestartedSince

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

参量
utcEpochTime long

timeUnit TimeUnit

退货
boolean

投掷
DeviceNotAvailableException

disableAdbRoot

public boolean disableAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

disableKeyguard

public void disableKeyguard ()

投掷
DeviceNotAvailableException

disableNetworkMonitor

public boolean disableNetworkMonitor ()

退货
boolean

投掷
DeviceNotAvailableException

从Wifi断开

public boolean disconnectFromWifi ()

退货
boolean

投掷
DeviceNotAvailableException

didFileExist

public boolean doesFileExist (String deviceFilePath)

参量
deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

dumpHeap

public File dumpHeap (String process, 
                String devicePath)

参量
process String

devicePath String

退货
File

投掷
DeviceNotAvailableException

enableAdbRoot

public boolean enableAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

enableNetworkMonitor

public boolean enableNetworkMonitor ()

退货
boolean

投掷
DeviceNotAvailableException

cryptoDevice

public boolean encryptDevice (boolean inplace)

参量
inplace boolean

退货
boolean

投掷
DeviceNotAvailableException

executeAdbCommand

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

参量
timeout long

cmdArgs String

退货
String

投掷
DeviceNotAvailableException

executeAdbCommand

public String executeAdbCommand (String... cmdArgs)

参量
cmdArgs String

退货
String

投掷
DeviceNotAvailableException

executeFastbootCommand

public CommandResult executeFastbootCommand (String... cmdArgs)

参量
cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

executeFastbootCommand

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

参量
timeout long

cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

executeLongFastbootCommand

public CommandResult executeLongFastbootCommand (String... cmdArgs)

参量
cmdArgs String

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellCommand

public String executeShellCommand (String command)

参量
command String

退货
String

投掷
DeviceNotAvailableException

executeShellCommand

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

参量
command String

receiver IShellOutputReceiver

maxTimeToOutputShellResponse long

timeUnit TimeUnit

retryAttempts int

投掷
DeviceNotAvailableException

executeShellCommand

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

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

参量
command String

receiver IShellOutputReceiver

投掷
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd)

参量
cmd String

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

参量
cmd String

pipeToOutput OutputStream

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

参量
cmd String

pipeAsInput File

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellV2Command

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

参量
cmd String

maxTimeoutForCommand long

timeUnit TimeUnit

retryAttempts int

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellV2Command

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

参量
cmd String

maxTimeoutForCommand long

timeUnit TimeUnit

退货
CommandResult

投掷
DeviceNotAvailableException

executeShellV2Command

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

fastbootWipePartition

public CommandResult fastbootWipePartition (String partition)

参量
partition String

退货
CommandResult

投掷
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

退货

投掷
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

参量
namespace String

退货

投掷
DeviceNotAvailableException

getAllocationState

public DeviceAllocationState getAllocationState ()

退货
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

参量
userId int

退货
String

投掷
DeviceNotAvailableException

getAndroidIds

public  getAndroidIds ()

退货

投掷
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

退货
int

投掷
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

参量
packageName String

退货
PackageInfo

投掷
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

退货

投掷
DeviceNotAvailableException

getBasebandVersion

public String getBasebandVersion ()

退货
String

投掷
DeviceNotAvailableException

getBattery

public Integer getBattery ()

退货
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

参量
name String

defaultValue boolean

退货
boolean

投掷
DeviceNotAvailableException

getBootHistory

public  getBootHistory ()

退货

投掷
DeviceNotAvailableException

getBootHistorySince

39

参量
utcEpochTime long

timeUnit TimeUnit

退货

投掷
DeviceNotAvailableException

getBootloaderVersion

public String getBootloaderVersion ()

退货
String

投掷
DeviceNotAvailableException

getBugreport

public InputStreamSource getBugreport ()

退货
InputStreamSource

getBugreportz

public InputStreamSource getBugreportz ()

退货
InputStreamSource

getBuildAlias

public String getBuildAlias ()

退货
String

投掷
DeviceNotAvailableException

getBuildFlavor

public String getBuildFlavor ()

退货
String

投掷
DeviceNotAvailableException

getBuildId

public String getBuildId ()

退货
String

投掷
DeviceNotAvailableException

getBuildSigningKeys

public String getBuildSigningKeys ()

退货
String

投掷
DeviceNotAvailableException

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor ()

退货
DeviceDescriptor

getChildren

public String[] getChildren (String path)

参量
path String

退货
String[]

投掷
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

退货
int

投掷
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

退货
String

getDeviceDate

public long getDeviceDate ()

退货
long

投掷
DeviceNotAvailableException

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor ()

退货
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

退货
TestDeviceState

getDeviceTimeOffset

public long getDeviceTimeOffset (Date date)

参量
date Date

退货
long

投掷
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

退货
InputStreamSource

getEmulatorProcess

public Process getEmulatorProcess ()

退货
Process

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

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

退货
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

退货
long

投掷
DeviceNotAvailableException

getFastbootPath

public String getFastbootPath ()

退货
String

getFastbootProductType

public String getFastbootProductType ()

退货
String

投掷
DeviceNotAvailableException

getFastbootProductVariant

public String getFastbootProductVariant ()

退货
String

投掷
DeviceNotAvailableException

getFastbootVariable

public String getFastbootVariable (String variableName)

参量
variableName String

退货
String

投掷
DeviceNotAvailableException

getFastbootVersion

public String getFastbootVersion ()

退货
String

getFileEntry

public IFileEntry getFileEntry (String path)

参量
path String

退货
IFileEntry

投掷
DeviceNotAvailableException

getFileEntry

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

从非根路径获取FileEntry非官方帮助者。修复:重构FileEntry系统,使其可从任何路径使用。 (甚至是非根用户)。

参量
entry FileListingService.FileEntry :一个FileEntry不一定是Ddmlib要求的根目录。

退货
IFileEntry 一个FileEntryWrapper表示FileEntry的。

投掷
DeviceNotAvailableException

getIDevice

public IDevice getIDevice ()

退货
IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

退货

投掷
DeviceNotAvailableException

getIntProperty

65

参量
name String

defaultValue long

退货
long

投掷
DeviceNotAvailableException

getIpAddress

public String getIpAddress ()

退货
String

投掷
DeviceNotAvailableException

getKeyguardState

public KeyguardControllerState getKeyguardState ()

退货
KeyguardControllerState

投掷
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

退货
long

getLaunchApiLevel

public int getLaunchApiLevel ()

退货
int

投掷
DeviceNotAvailableException

getLogcat

public InputStreamSource getLogcat ()

退货
InputStreamSource

getLogcat

public InputStreamSource getLogcat (int maxBytes)

参量
maxBytes int

退货
InputStreamSource

getLogcatDump

public InputStreamSource getLogcatDump ()

退货
InputStreamSource

getLogcatSince

public InputStreamSource getLogcatSince (long date)

参量
date long

退货
InputStreamSource

getMacAddress

public String getMacAddress ()

退货
String

getMaxNumberOfRunningUsersSupported

public int getMaxNumberOfRunningUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

getMaxNumberOfUsersSupported

public int getMaxNumberOfUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

getMonitor

10

退货
IDeviceStateMonitor

getMountPoint

public String getMountPoint (String mountName)

参量
mountName String

退货
String

getMountPointInfo

public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

参量
mountpoint String

退货
ITestDevice.MountPointInfo

投掷
DeviceNotAvailableException

getMountPointInfo

public  getMountPointInfo ()

退货

投掷
DeviceNotAvailableException

getOptions

public TestDeviceOptions getOptions ()

退货
TestDeviceOptions

getPartitionFreeSpace

public long getPartitionFreeSpace (String partition)

参量
partition String

退货
long

投掷
DeviceNotAvailableException

getPrimaryUserId

public Integer getPrimaryUserId ()

退货
Integer

投掷
DeviceNotAvailableException

getProcessByName

public ProcessInfo getProcessByName (String processName)

参量
processName String

退货
ProcessInfo

投掷
DeviceNotAvailableException

getProcessPid

public String getProcessPid (String process)

参量
process String

退货
String

投掷
DeviceNotAvailableException

getProductType

public String getProductType ()

退货
String

投掷
DeviceNotAvailableException

getProductVariant

public String getProductVariant ()

退货
String

投掷
DeviceNotAvailableException

getProperty

public String getProperty (String name)

参量
name String

退货
String

投掷
DeviceNotAvailableException

getRecoveryMode

public ITestDevice.RecoveryMode getRecoveryMode ()

退货
ITestDevice.RecoveryMode

getScreenshot

public InputStreamSource getScreenshot (String format)

参量
format String

退货
InputStreamSource

投掷
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (long displayId)

参量
displayId long

退货
InputStreamSource

投掷
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (String format, 
                boolean rescale)

参量
format String

rescale boolean

退货
InputStreamSource

投掷
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot ()

退货
InputStreamSource

投掷
DeviceNotAvailableException

getSerialNumber

public String getSerialNumber ()

退货
String

getSetting

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

参量
userId int

namespace String

key String

退货
String

投掷
DeviceNotAvailableException

getSetting

public String getSetting (String namespace, 
                String key)

参量
namespace String

key String

退货
String

投掷
DeviceNotAvailableException

getSimOperator

public String getSimOperator ()

退货
String

getSimState

public String getSimState ()

退货
String

getTombstones

public  getTombstones ()

退货

投掷
DeviceNotAvailableException

getTotalMemory

public long getTotalMemory ()

退货
long

getUninstallablePackageNames

public  getUninstallablePackageNames ()

退货

投掷
DeviceNotAvailableException

getUseFastbootErase

public boolean getUseFastbootErase ()

退货
boolean

getUserFlags

public int getUserFlags (int userId)

参量
userId int

退货
int

投掷
DeviceNotAvailableException

getUserInfos

public  getUserInfos ()

退货

投掷
DeviceNotAvailableException

getUserSerialNumber

public int getUserSerialNumber (int userId)

参量
userId int

退货
int

投掷
DeviceNotAvailableException

handleAllocationEvent

public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

处理DeviceEvent,该事件可能会或可能不会将此设备转换为新的分配状态。

参量
event DeviceEvent

退货
IManagedTestDevice.DeviceEventResponse

hasFeature

public boolean hasFeature (String feature)

参量
feature String

退货
boolean

投掷
DeviceNotAvailableException

installPackage

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

参量
packageFile File

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

installPackage

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

参量
packageFile File

reinstall boolean

grantPermissions boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

installPackageForUser

939

参量
packageFile File

reinstall boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

installPackageForUser

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

isAdbRoot

public boolean isAdbRoot ()

退货
boolean

投掷
DeviceNotAvailableException

isAdbTcp

public boolean isAdbTcp ()

退货
boolean

isAppEnumerationSupported

public boolean isAppEnumerationSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isDeviceEncrypted

床36b0cbb

退货
boolean

投掷
DeviceNotAvailableException

isDirectory

public boolean isDirectory (String path)

参量
path String

退货
boolean

投掷
DeviceNotAvailableException

isEnableAdbRoot

public boolean isEnableAdbRoot ()

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

isEncryptionSupported

public boolean isEncryptionSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isExecutable

public boolean isExecutable (String fullPath)

参量
fullPath String

退货
boolean

投掷
DeviceNotAvailableException

isFastbootEnabled

public boolean isFastbootEnabled ()

退货
boolean

无头

public boolean isHeadless ()

退货
boolean

投掷
DeviceNotAvailableException

isMultiUserSupported

public boolean isMultiUserSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isPackage已安装

public boolean isPackageInstalled (String packageName, 
                String userId)

参量
packageName String

userId String

退货
boolean

投掷
DeviceNotAvailableException

isPackage已安装

public boolean isPackageInstalled (String packageName)

参量
packageName String

退货
boolean

投掷
DeviceNotAvailableException

isRuntimePermissionSupported

18

退货
boolean

投掷
DeviceNotAvailableException

isStateBootloaderOrFastbootd

public boolean isStateBootloaderOrFastbootd ()

退货
boolean

isUserRunning

第198章

参量
userId int

退货
boolean

投掷
DeviceNotAvailableException

isUserSecondary

第88章

参量
userId int

退货
boolean

投掷
DeviceNotAvailableException

isWifiEnabled

public boolean isWifiEnabled ()

退货
boolean

投掷
DeviceNotAvailableException

listDisplayIds

public  listDisplayIds ()

退货

投掷
DeviceNotAvailableException

listUsers

public  listUsers ()

退货

投掷
DeviceNotAvailableException

logBu​​greport

public boolean logBugreport (String dataName, 
                ITestLogger listener)

参量
dataName String

listener ITestLogger

退货
boolean

logOnDevice

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

参量
tag String

level Log.LogLevel

format String

args Object

nonBlockingReboot

public void nonBlockingReboot ()

投掷
DeviceNotAvailableException

postAdbRootAction

60

如果设备需要在adb root之后且设备重新联机之前执行某些特定操作,则重写。默认实现不包含任何其他操作。不保证在此阶段启用adb root。

投掷
DeviceNotAvailableException

postAdbUnrootAction

public void postAdbUnrootAction ()

如果设备需要在adb unroot之后且设备重新联机之前执行一些特定的操作,则重写。默认实现不包含任何其他操作。不能保证在此阶段禁用adb root。

投掷
DeviceNotAvailableException

postBootSetup

public void postBootSetup ()

投掷
DeviceNotAvailableException

postInvocationTearDown

public void postInvocationTearDown (Throwable exception)

参量
exception Throwable

preInvocationSetup

public void preInvocationSetup (IBuildInfo info)

参量
info IBuildInfo

投掷
DeviceNotAvailableException
TargetSetupError

pullDir

public boolean pullDir (String deviceFilePath, 
                File localDir)

参量
deviceFilePath String

localDir File

退货
boolean

投掷
DeviceNotAvailableException

pullFile

public boolean pullFile (String remoteFilePath, 
                File localFile)

参量
remoteFilePath String

localFile File

退货
boolean

投掷
DeviceNotAvailableException

pullFile

public File pullFile (String remoteFilePath)

参量
remoteFilePath String

退货
File

投掷
DeviceNotAvailableException

pullFileContents

public String pullFileContents (String remoteFilePath)

参量
remoteFilePath String

退货
String

投掷
DeviceNotAvailableException

pullFileFromExternal

public File pullFileFromExternal (String remoteFilePath)

参量
remoteFilePath String

退货
File

投掷
DeviceNotAvailableException

pushDir

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

参量
localFileDir File

deviceFilePath String

excludedDirectories

退货
boolean

投掷
DeviceNotAvailableException

pushDir

815

参量
localFileDir File

deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

pushFile

9

参量
localFile File

remoteFilePath String

退货
boolean

投掷
DeviceNotAvailableException

pushString

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

rebootIntoBootloader

第781章

投掷
DeviceNotAvailableException

rebootIntoFastbootd

public void rebootIntoFastbootd ()

投掷
DeviceNotAvailableException

rebootIntoRecovery

public void rebootIntoRecovery ()

投掷
DeviceNotAvailableException

rebootIntoSideload

public void rebootIntoSideload ()

投掷
DeviceNotAvailableException

rebootIntoSideload

public void rebootIntoSideload (boolean autoReboot)

参量
autoReboot boolean

投掷
DeviceNotAvailableException

rebootUntilOnline

public void rebootUntilOnline ()

投掷
DeviceNotAvailableException

rebootUntilOnline

public void rebootUntilOnline (String reason)

参量
reason String

投掷
DeviceNotAvailableException

rebootUserspace

public void rebootUserspace ()

投掷
DeviceNotAvailableException

rebootUserspaceUntilOnline

public void rebootUserspaceUntilOnline ()

投掷
DeviceNotAvailableException

restoreDevice

public void recoverDevice ()

尝试恢复设备通信。

投掷
DeviceNotAvailableException 如果设备不再可用

remountSystemWritable

public void remountSystemWritable ()

投掷
DeviceNotAvailableException

remountVendorWritable

public void remountVendorWritable ()

投掷
DeviceNotAvailableException

removeAdmin

public boolean removeAdmin (String componentName, 
                int userId)

参量
componentName String

userId int

退货
boolean

投掷
DeviceNotAvailableException

removeOwners

public void removeOwners ()

投掷
DeviceNotAvailableException

removeUser

public boolean removeUser (int userId)

参量
userId int

退货
boolean

投掷
DeviceNotAvailableException

runInstrumentationTests

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

参量
runner IRemoteAndroidTestRunner

listeners ITestLifeCycleReceiver

退货
boolean

投掷
DeviceNotAvailableException

runInstrumentationTests

public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                 listeners)

参量
runner IRemoteAndroidTestRunner

listeners

退货
boolean

投掷
DeviceNotAvailableException

runInstrumentationTestsAsUser

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

参量
runner IRemoteAndroidTestRunner

userId int

listeners ITestLifeCycleReceiver

退货
boolean

投掷
DeviceNotAvailableException

runInstrumentationTestsAsUser

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

参量
runner IRemoteAndroidTestRunner

userId int

listeners

退货
boolean

投掷
DeviceNotAvailableException

设置日期

public void setDate (Date date)

参量
date Date

投掷
DeviceNotAvailableException

setDeviceOwner

public boolean setDeviceOwner (String componentName, 
                int userId)

参量
componentName String

userId int

退货
boolean

投掷
DeviceNotAvailableException

setDeviceState

public void setDeviceState (TestDeviceState deviceState)

参量
deviceState TestDeviceState

setEmulatorOutputStream

public void setEmulatorOutputStream (SizeLimitedOutputStream output)

对于仿真器,将SizeLimitedOutputStream设置为记录输出

参量
output SizeLimitedOutputStream :记录输出

setEmulatorProcess

public void setEmulatorProcess (Process p)

参量
p Process

setFastbootEnabled

public void setFastbootEnabled (boolean fastbootEnabled)

参量
fastbootEnabled boolean

setFastbootPath

public void setFastbootPath (String fastbootPath)

参量
fastbootPath String

setIDevice

public void setIDevice (IDevice newDevice)

参量
newDevice IDevice

setOptions

public void setOptions (TestDeviceOptions options)

参量
options TestDeviceOptions

setProperty

public boolean setProperty (String propKey, 
                String propValue)

参量
propKey String

propValue String

退货
boolean

投掷
DeviceNotAvailableException

setRecovery

public void setRecovery (IDeviceRecovery recovery)

参量
recovery IDeviceRecovery

setRecoveryMode

public void setRecoveryMode (ITestDevice.RecoveryMode mode)

参量
mode ITestDevice.RecoveryMode

setSetting

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

参量
namespace String

key String

value String

投掷
DeviceNotAvailableException

setSetting

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

参量
userId int

namespace String

key String

value String

投掷
DeviceNotAvailableException

setUseFastbootErase

public void setUseFastbootErase (boolean useFastbootErase)

参量
useFastbootErase boolean

startLogcat

public void startLogcat ()

startUser

第681章

参量
userId int

退货
boolean

投掷
DeviceNotAvailableException

startUser

public boolean startUser (int userId, 
                boolean waitFlag)

参量
userId int

waitFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

stopEmulatorOutput

public void stopEmulatorOutput ()

stopLogcat

public void stopLogcat ()

stopUser

public boolean stopUser (int userId)

参量
userId int

退货
boolean

投掷
DeviceNotAvailableException

stopUser

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

参量
userId int

waitFlag boolean

forceFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

switchToAdbTcp

public String switchToAdbTcp ()

退货
String

投掷
DeviceNotAvailableException

switchToAdbUsb

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

采取Bugreport

public Bugreport takeBugreport ()

退货
Bugreport

unencryptDevice

public boolean unencryptDevice ()

退货
boolean

投掷
DeviceNotAvailableException

uninstallPackage

public String uninstallPackage (String packageName)

参量
packageName String

退货
String

投掷
DeviceNotAvailableException

unlockDevice

public boolean unlockDevice ()

退货
boolean

投掷
DeviceNotAvailableException

waitForBootComplete

public boolean waitForBootComplete (long timeOut)

参量
timeOut long

退货
boolean

投掷
DeviceNotAvailableException

waitForDeviceAvailable

public void waitForDeviceAvailable ()

投掷
DeviceNotAvailableException

waitForDeviceAvailable

public void waitForDeviceAvailable (long waitTime)

参量
waitTime long

投掷
DeviceNotAvailableException

waitForDeviceInRecovery

0

参量
waitTime long

退货
boolean

waitForDeviceInSideload

public boolean waitForDeviceInSideload (long waitTime)

参量
waitTime long

退货
boolean

waitForDeviceNotAvailable

public boolean waitForDeviceNotAvailable (long waitTime)

参量
waitTime long

退货
boolean

waitForDeviceOnline

public void waitForDeviceOnline ()

投掷
DeviceNotAvailableException

waitForDeviceOnline

public void waitForDeviceOnline (long waitTime)

参量
waitTime long

投掷
DeviceNotAvailableException

waitForDeviceShell

public boolean waitForDeviceShell (long waitTime)

参量
waitTime long

退货
boolean

受保护的方法

checkApiLevelAgainst

protected void checkApiLevelAgainst (String feature, 
                int strictMinLevel)

参量
feature String

strictMinLevel int

createRebootDeviceAction

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

创建一个RebootDeviceAction以在执行重新引导操作时使用。

参量
rebootMode NativeDevice.RebootMode :此重新引导的模式。

reason String :此重启。

退货
NativeDevice.RebootDeviceAction 创建的RebootDeviceAction

doAdbReboot

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

执行adb重新启动。

参量
rebootMode NativeDevice.RebootMode :此重新引导的模式。

reason String :此重启。

投掷
DeviceNotAvailableException

guaranteeRuntimePermissionSupported

protected void ensureRuntimePermissionSupported ()

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

投掷
DeviceNotAvailableException

getBugreportInternal

protected InputStreamSource getBugreportInternal ()

退货
InputStreamSource

getBugreportzInternal

protected File getBugreportzInternal ()

用于将bugreportz zip文件获取为ERROR(/File)内部Helper方法。

退货
File

getRunUtil

protected IRunUtil getRunUtil ()

获取要使用的RunUtil实例。

退货
IRunUtil

internalGetProperty

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 ,将不尝试快速启动查询

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

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

投掷
DeviceNotAvailableException

isNewer

protected boolean isNewer (File localFile, 
                IFileEntry entry)

如果本地文件比远程文件新,则返回trueIFileEntry精确到分钟,如果时间相等,则该文件将被视为较新。

参量
localFile File

entry IFileEntry

退货
boolean

performDeviceAction

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 如果恢复尝试失败或完成最大尝试但没有成功

postAdbReboot

protected void postAdbReboot ()

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

投掷
DeviceNotAvailableException

prePostBootSetup

protected void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice,TestDevice)针对特定的启动后设置覆盖此方法。

投掷
DeviceNotAvailableException

setClock

protected void setClock (Clock clock)

设置要使用的Clock实例。

参量
clock Clock

setLogStartDelay

protected void setLogStartDelay (int delay)

设置开始联机设备的Logcat捕获之前要等待的时间(以毫秒为单位)。

参量
delay int :以毫秒为单位的延迟

waitForDeviceNotAvailable

protected void waitForDeviceNotAvailable (String operationDesc, 
                long time)

参量
operationDesc String

time long