INativeDevice
public interface INativeDevice
com.android.tradefed.device.INativeDevice |
Fornisce un'API affidabile e di livello leggermente superiore a un IDevice
ddmlib .
Riepilogo
Costanti | |
---|---|
int | UNKNOWN_API_LEVEL Valore predefinito quando non è possibile rilevare il livello API |
Metodi pubblici | |
---|---|
abstract boolean | checkApiLevelAgainstNextRelease (int strictMinLevel) Controlla se una funzione è attualmente supportata o meno dato un livello minimo supportato. |
abstract void | clearLogcat () Elimina tutti i dati logcat accumulati. |
abstract void | deleteFile (String deviceFilePath) Metodo di supporto per eliminare un file o una directory sul dispositivo. |
abstract boolean | deviceSoftRestarted ( ProcessInfo prevSystemServerProcess) Metodo di supporto per verificare se il dispositivo è stato riavviato temporaneamente confrontando l'attuale system_server con il precedente system_server |
abstract boolean | deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit) Metodo helper per verificare se il dispositivo è stato riavviato gradualmente dall'ora UTC dall'epoca dal dispositivo e dal relativo |
abstract boolean | disableAdbRoot () Disattiva root adb. |
abstract boolean | doesFileExist (String deviceFilePath) Metodo di supporto per determinare se il file sul dispositivo esiste. |
abstract boolean | enableAdbRoot () Attiva root adb. |
abstract String | executeAdbCommand (long timeout, String... commandArgs) Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato. |
abstract String | executeAdbCommand (String... commandArgs) Metodo helper che esegue un comando adb come comando di sistema. |
abstract String | executeAdbCommand (long timeout, envMap, String... commandArgs) executeAdbCommand (long timeout, envMap, String... commandArgs) Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato. |
abstract CommandResult | executeFastbootCommand (long timeout, String... commandArgs) Metodo helper che esegue un comando fastboot come comando di sistema. |
abstract CommandResult | executeFastbootCommand (String... commandArgs) Metodo helper che esegue un comando fastboot come comando di sistema con un timeout predefinito di 2 minuti. |
abstract CommandResult | executeLongFastbootCommand (String... commandArgs) Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema. |
abstract CommandResult | executeLongFastbootCommand ( envVarMap, String... commandArgs) executeLongFastbootCommand ( envVarMap, String... commandArgs) Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema con variabili di ambiente di sistema. |
abstract String | executeShellCommand (String command) Metodo helper che esegue un comando adb shell e restituisce l'output come |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver) Esegue il comando adb shell specificato, riprovando più volte se il comando fallisce. |
abstract CommandResult | executeShellV2Command (String command) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
abstract CommandResult | executeShellV2Command (String command, OutputStream pipeToOutput) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
abstract CommandResult | fastbootWipePartition (String partition) Metodo di supporto che cancella una partizione per il dispositivo. |
abstract int | getApiLevel () Ottieni il livello API del dispositivo. |
abstract String | getBasebandVersion () Metodo conveniente per ottenere la versione in banda base (radio) di questo dispositivo. |
abstract Integer | getBattery () Restituisce il livello corrente della batteria di un dispositivo o Null se il livello della batteria non è disponibile. |
abstract boolean | getBooleanProperty (String name, boolean defaultValue) Restituisce il valore booleano della proprietà data. |
abstract | getBootHistory () Il metodo helper raccoglie la mappa della cronologia di avvio con l'ora di avvio e il motivo dell'avvio. |
abstract | getBootHistorySince (long utcEpochTime, TimeUnit timeUnit) Il metodo helper raccoglie la mappa della cronologia di avvio con l'ora di avvio e il motivo dell'avvio dall'ora specificata dall'epoca dal dispositivo e l'unità di tempo specificata. |
abstract String | getBootloaderVersion () Metodo conveniente per ottenere la versione bootloader di questo dispositivo. |
abstract String | getBuildAlias () Recupera l'alias della build attualmente in esecuzione sul dispositivo. |
abstract String | getBuildFlavor () Recupera il sapore di costruzione per il dispositivo. |
abstract String | getBuildId () Recupera la build attualmente in esecuzione sul dispositivo. |
abstract String | getBuildSigningKeys () Restituisce il tipo di chiave usato per firmare l'immagine del dispositivo In genere i dispositivi Android possono essere firmati con chiavi di prova (come in AOSP) o chiavi di rilascio (controllate dai singoli produttori di dispositivi) |
abstract DeviceDescriptor | getCachedDeviceDescriptor () Restituisce un |
abstract DeviceDescriptor | getCachedDeviceDescriptor (boolean shortDescriptor) Restituisce un |
abstract String[] | getChildren (String deviceFilePath) Alternativa all'utilizzo |
abstract AbstractConnection | getConnection () Restituisce la connessione associata al dispositivo. |
abstract String | getDeviceClass () Ottieni la classe del dispositivo. |
abstract long | getDeviceDate () Restituisce la data del dispositivo in millisecondi dall'epoca. |
abstract DeviceDescriptor | getDeviceDescriptor () Restituisce un |
abstract DeviceDescriptor | getDeviceDescriptor (boolean shortDescriptor) Restituisce un |
abstract TestDeviceState | getDeviceState () Ottenere lo stato del dispositivo. |
abstract long | getDeviceTimeOffset (Date date) Helper per ottenere la differenza di orario tra il dispositivo e un dato |
abstract InputStreamSource | getEmulatorOutput () Ottieni il flusso dell'emulatore stdout e stderr |
abstract long | getExternalStoreFreeSpace () Metodo di supporto per determinare la quantità di spazio libero sulla memoria esterna del dispositivo. |
abstract String | getFastbootProductType () Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot. |
abstract String | getFastbootProductVariant () Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot. |
abstract String | getFastbootSerialNumber () Restituisce il numero di serie della modalità fastboot. |
abstract String | getFastbootVariable (String variableName) Recupera il valore della variabile di avvio rapido specificato dal dispositivo. |
abstract IFileEntry | getFileEntry (String path) Recupera un riferimento a un file remoto sul dispositivo. |
abstract IDevice | getIDevice () Restituisce un riferimento |
abstract long | getIntProperty (String name, long defaultValue) Restituisce il valore intero della proprietà data dal dispositivo. |
abstract long | getLastExpectedRebootTimeMillis () Restituisce l'ultima volta che le API Tradefed hanno attivato un riavvio in millisecondi da EPOCH come restituito da |
abstract int | getLaunchApiLevel () Ottieni il primo livello API lanciato del dispositivo. |
abstract InputStreamSource | getLogcat () Acquisisce un flusso di istantanee dei dati logcat. |
abstract InputStreamSource | getLogcat (int maxBytes) Acquisisce un flusso di istantanee degli ultimi |
abstract InputStreamSource | getLogcatDump () Ottieni un dump dell'attuale logcat per il dispositivo. |
abstract InputStreamSource | getLogcatSince (long date) Acquisisce un flusso di istantanee dei dati logcat acquisiti a partire dalla data fornita. |
abstract String | getMountPoint (String mountName) Restituisce un punto di montaggio. |
abstract ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) Restituisce un |
abstract | getMountPointInfo () Restituisce una versione analizzata delle informazioni in /proc/mounts sul dispositivo |
abstract long | getPartitionFreeSpace (String partition) Metodo di supporto per determinare la quantità di spazio libero sulla partizione del dispositivo. |
abstract ProcessInfo | getProcessByName (String processName) Il metodo helper esegue il comando "pidof" e "stat" e restituisce l'oggetto |
abstract String | getProcessPid (String process) Restituisce il pid del servizio o null se qualcosa è andato storto. |
abstract String | getProductType () Metodo conveniente per ottenere il tipo di prodotto di questo dispositivo. |
abstract String | getProductVariant () Metodo conveniente per ottenere la variante di prodotto di questo dispositivo. |
abstract String | getProperty (String name) Recupera il valore della proprietà specificato dal dispositivo. |
abstract ITestDevice.RecoveryMode | getRecoveryMode () Ottieni la modalità di ripristino corrente utilizzata per il dispositivo. |
abstract String | getSerialNumber () Metodo conveniente per ottenere il numero di serie di questo dispositivo. |
abstract | getTombstones () Recupera e restituisci l'elenco delle pietre tombali dai dispositivi. |
abstract long | getTotalMemory () Restituisce la dimensione totale della memoria fisica in byte o -1 in caso di errore interno |
abstract boolean | getUseFastbootErase () Scopri se utilizzare la cancellazione fastboot o il formato fastboot per cancellare una partizione sul dispositivo. |
abstract boolean | isAdbRoot () |
abstract boolean | isAdbTcp () |
abstract boolean | isAppEnumerationSupported () Controlla se la piattaforma sul dispositivo supporta l'enumerazione delle app |
abstract boolean | isBypassLowTargetSdkBlockSupported () Verifica se la piattaforma sul dispositivo supporta l'esclusione del blocco sdk con target basso nelle installazioni di app |
abstract boolean | isDeviceEncrypted () Restituisce se il dispositivo è crittografato. |
abstract boolean | isDirectory (String deviceFilePath) Restituisce True se il percorso sul dispositivo è una directory, false in caso contrario. |
abstract boolean | isEncryptionSupported () Restituisce se la crittografia è supportata sul dispositivo. |
abstract boolean | isExecutable (String fullPath) Restituisce True se il percorso del file sul dispositivo è un file eseguibile, false in caso contrario. |
abstract boolean | isHeadless () Restituisce true se il dispositivo è headless (senza schermo), false in caso contrario. |
abstract boolean | isRuntimePermissionSupported () Controlla se la piattaforma sul dispositivo supporta la concessione di autorizzazioni di runtime |
abstract boolean | isStateBootloaderOrFastbootd () Restituisce true se il dispositivo è in |
abstract boolean | logAnrs ( ITestLogger logger) Raccoglie e registra gli ANR dal dispositivo. |
abstract void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) Registra un messaggio nel logcat del dispositivo. |
abstract void | nonBlockingReboot () Emette un comando per riavviare il dispositivo e ritorna al comando completo e quando il dispositivo non è più visibile ad adb. |
abstract void | postBootSetup () Esegui le istruzioni per configurare il dispositivo per testarlo dopo ogni avvio. |
default void | postInvocationTearDown () Questo metodo è deprecato. Utilizzare |
abstract void | postInvocationTearDown (Throwable invocationException) Passaggi aggiuntivi per la pulizia richiesta specifica del dispositivo che verrà eseguita al termine della chiamata. |
default void | preInvocationSetup ( IBuildInfo info, MultiMap <String, String> attributes) Passaggi aggiuntivi per la configurazione richiesta specifica del dispositivo che verrà eseguita sul dispositivo prima del flusso di chiamata. |
abstract boolean | pullDir (String deviceFilePath, File localDir) Estrai in modo ricorsivo i contenuti della directory dal dispositivo. |
abstract File | pullFile (String remoteFilePath, int userId) Recupera un file dal dispositivo, lo archivia in un |
abstract File | pullFile (String remoteFilePath) Recupera un file dal dispositivo, lo archivia in un |
abstract boolean | pullFile (String remoteFilePath, File localFile) Recupera un file dal dispositivo. |
abstract boolean | pullFile (String remoteFilePath, File localFile, int userId) Recupera un file dal dispositivo. |
abstract String | pullFileContents (String remoteFilePath) Recupera un file dal dispositivo e ne restituisce il contenuto. |
abstract File | pullFileFromExternal (String remoteFilePath) Un metodo pratico per recuperare un file dalla memoria esterna del dispositivo, memorizzarlo in un |
abstract boolean | pushDir (File localDir, String deviceFilePath, excludedDirectories) pushDir (File localDir, String deviceFilePath, excludedDirectories) Invia in modo ricorsivo i contenuti delle directory al dispositivo escludendo alcune directory filtrate. |
abstract boolean | pushDir (File localDir, String deviceFilePath) Invia in modo ricorsivo i contenuti della directory al dispositivo. |
abstract boolean | pushFile (File localFile, String deviceFilePath, boolean evaluateContentProviderNeeded) Variante di |
abstract boolean | pushFile (File localFile, String deviceFilePath) Invia un file al dispositivo. |
abstract boolean | pushString (String contents, String deviceFilePath) Invia il file creato da una stringa al dispositivo |
abstract void | reboot () Riavvia il dispositivo in modalità adb. |
abstract void | reboot (String reason) Riavvia il dispositivo in modalità adb con |
abstract void | rebootIntoBootloader () Riavvia il dispositivo in modalità bootloader. |
abstract void | rebootIntoFastbootd () Riavvia il dispositivo in modalità fastbootd. |
abstract void | rebootIntoRecovery () Riavvia il dispositivo in modalità di ripristino adb. |
abstract void | rebootIntoSideload (boolean autoReboot) Riavvia il dispositivo in modalità sideload adb (si noti che questa è una modalità speciale in fase di ripristino) Si blocca finché il dispositivo non entra in modalità sideload |
abstract void | rebootIntoSideload () Riavvia il dispositivo in modalità sideload adb (si noti che questa è una modalità speciale in fase di ripristino) Si blocca finché il dispositivo non entra in modalità sideload |
abstract void | rebootUntilOnline () Un'alternativa a |
abstract void | rebootUntilOnline (String reason) Un'alternativa a |
abstract void | rebootUserspace () Riavvia solo la parte dello spazio utente del dispositivo. |
abstract void | rebootUserspaceUntilOnline () Un'alternativa a |
abstract void | remountSystemReadOnly () Rendere la partizione di sistema sul dispositivo di sola lettura. |
abstract void | remountSystemWritable () Rendi scrivibile la partizione di sistema sul dispositivo. |
abstract void | remountVendorReadOnly () Rendere la partizione del fornitore sul dispositivo di sola lettura. |
abstract void | remountVendorWritable () Rendere scrivibile la partizione del fornitore sul dispositivo. |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) Metodo pratico per eseguire |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) Esegue i test di strumentazione e fornisce il ripristino del dispositivo. |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) Uguale |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) Uguale a |
abstract void | setDate (Date date) Imposta la data sul dispositivo Nota: l'impostazione della data sul dispositivo richiede root |
abstract void | setOptions ( TestDeviceOptions options) Impostare |
abstract boolean | setProperty (String propKey, String propValue) Imposta il valore della proprietà specificato sul dispositivo. |
abstract void | setRecovery ( IDeviceRecovery recovery) Impostare l' |
abstract void | setRecoveryMode ( ITestDevice.RecoveryMode mode) Imposta la modalità di ripristino corrente da utilizzare per il dispositivo. |
abstract void | setUseFastbootErase (boolean useFastbootErase) Imposta se utilizzare la cancellazione fastboot o il formato fastboot per cancellare una partizione sul dispositivo. |
abstract void | startLogcat () Avvia l'acquisizione dell'output logcat dal dispositivo in background. |
abstract void | stopEmulatorOutput () Chiudi ed elimina l'output dell'emulatore. |
abstract void | stopLogcat () Interrompi l'acquisizione dell'output logcat dal dispositivo ed elimina i dati logcat attualmente salvati. |
abstract String | switchToAdbTcp () Passa il dispositivo alla modalità adb-over-tcp. |
abstract boolean | switchToAdbUsb () Passa il dispositivo alla modalità adb su usb. |
abstract boolean | syncFiles (File localFileDir, String deviceFilePath) Sincronizza in modo incrementale il contenuto di una directory di file locale sul dispositivo. |
abstract boolean | unlockDevice () Sblocca il dispositivo se il dispositivo è in uno stato crittografato. |
abstract boolean | waitForBootComplete (long timeOut) Si blocca finché non viene impostato il flag di avvio completo del dispositivo. |
abstract boolean | waitForDeviceAvailable () Attende che il dispositivo sia reattivo e disponibile per il test. |
abstract boolean | waitForDeviceAvailable (long waitTime) Attende che il dispositivo sia reattivo e disponibile per il test. |
abstract boolean | waitForDeviceAvailableInRecoverPath (long waitTime) Attende che il dispositivo sia reattivo e disponibile senza considerare il percorso di ripristino. |
abstract void | waitForDeviceBootloader () Si blocca finché il dispositivo non è visibile tramite fastboot. |
abstract boolean | waitForDeviceInRecovery (long waitTime) Blocchi affinché il dispositivo sia nello stato 'adb recovery' (si noti che questo è distinto da |
abstract boolean | waitForDeviceInSideload (long waitTime) Blocchi affinché il dispositivo sia nello stato 'adb sideload' |
abstract boolean | waitForDeviceNotAvailable (long waitTime) Blocchi affinché il dispositivo non sia disponibile, ovvero mancante da adb |
abstract void | waitForDeviceOnline () Blocca finché il dispositivo non è visibile tramite adb. |
abstract void | waitForDeviceOnline (long waitTime) Blocca finché il dispositivo non è visibile tramite adb. |
abstract boolean | waitForDeviceShell (long waitTime) Attende che il dispositivo risponda a un comando shell adb di base. |
Costanti
UNKNOWN_API_LEVEL
public static final int UNKNOWN_API_LEVEL
Valore predefinito quando non è possibile rilevare il livello API
Valore costante: -1 (0xffffffff)
Metodi pubblici
checkApiLevelAgainstNextRelease
public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
Controlla se una funzione è attualmente supportata o meno dato un livello minimo supportato. Questo metodo tiene conto delle funzionalità non ancora rilasciate, prima che venga innalzato il livello API.
Parametri | |
---|---|
strictMinLevel | int : il minimo livello possibile rigoroso che supporta la funzionalità. |
ritorna | |
---|---|
boolean | Vero se il livello è supportato. Falso altrimenti. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
clearLogcat
public abstract void clearLogcat ()
Elimina tutti i dati logcat accumulati.
Ciò è utile nei casi in cui si desidera garantireITestDevice#getLogcat()
restituisca solo i dati di registro prodotti dopo un certo punto (ad esempio dopo il flashing di una nuova build del dispositivo, ecc.). cancella il file
public abstract void deleteFile (String deviceFilePath)
Metodo di supporto per eliminare un file o una directory sul dispositivo.
Parametri | |
---|---|
deviceFilePath | String : il percorso assoluto del file sul dispositivo. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
deviceSoftRiavviato
public abstract boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
Metodo di supporto per verificare se il dispositivo è stato riavviato temporaneamente confrontando l'attuale system_server con il precedente system_server ProcessInfo
. Utilizzare getProcessByName(String)
per ottenere ProcessInfo
.
Parametri | |
---|---|
prevSystemServerProcess | ProcessInfo : il precedente processo system_server ProcessInfo . |
ritorna | |
---|---|
boolean | true se il dispositivo è stato riavviato gradualmente |
Getta | |
---|---|
RuntimeException | se il dispositivo ha un motivo di avvio anomalo |
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
deviceSoftRestartedSince
public abstract boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
Metodo helper per verificare se il dispositivo è stato riavviato gradualmente dall'ora UTC dall'epoca dal dispositivo e dal relativo ERROR(/TimeUnit)
. Soft-Restart si riferisce a system_server riavviato al di fuori di un riavvio forzato del dispositivo (ad esempio: riavvio richiesto). Il dispositivo corrente utcEpochTime in Milliseccond può essere ottenuto con il metodo getDeviceDate()
.
Parametri | |
---|---|
utcEpochTime | long : il tempo del dispositivo in secondi dall'epoca. |
timeUnit | TimeUnit : l'unità di tempo TimeUnit per il dato utcEpochTime. |
ritorna | |
---|---|
boolean | true se il dispositivo è stato riavviato gradualmente |
Getta | |
---|---|
RuntimeException | se il dispositivo ha un motivo di avvio anomalo |
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
disabilitaAdbRoot
public abstract boolean disableAdbRoot ()
Disattiva root adb.
La disabilitazione di adb root può causare la disconnessione del dispositivo da adb. Questo metodo si bloccherà finché il dispositivo non sarà disponibile.ritorna | |
---|---|
boolean | true in caso di successo. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
doesFileExist
public abstract boolean doesFileExist (String deviceFilePath)
Metodo di supporto per determinare se il file sul dispositivo esiste.
Parametri | |
---|---|
deviceFilePath | String : il percorso assoluto del file sul dispositivo da controllare |
ritorna | |
---|---|
boolean | true se il file esiste, false in caso contrario. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
abilitaAdbRoot
public abstract boolean enableAdbRoot ()
Attiva root adb. Se l'impostazione "enable-root" è "false", registrerà un messaggio e restituirà senza abilitare root.
L'abilitazione di adb root potrebbe causare la disconnessione del dispositivo da adb. Questo metodo si bloccherà finché il dispositivo non sarà disponibile.ritorna | |
---|---|
boolean | true in caso di successo. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiAdbComando
public abstract String executeAdbCommand (long timeout, String... commandArgs)
Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato.
executeShellCommand(String)
dovrebbe essere utilizzato invece ove possibile, in quanto tale metodo fornisce prestazioni e rilevamento degli errori migliori.
Parametri | |
---|---|
timeout | long : il tempo in millisecondi prima che il dispositivo non risponda, 0L per nessun timeout |
commandArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiAdbComando
public abstract String executeAdbCommand (String... commandArgs)
Metodo helper che esegue un comando adb come comando di sistema.
executeShellCommand(String)
dovrebbe essere utilizzato invece ove possibile, in quanto tale metodo fornisce prestazioni e rilevamento degli errori migliori.Parametri | |
---|---|
commandArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiAdbComando
public abstract String executeAdbCommand (long timeout,envMap, String... commandArgs)
Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato.
executeShellCommand(String)
dovrebbe essere utilizzato invece ove possibile, in quanto tale metodo fornisce prestazioni e rilevamento degli errori migliori.
Parametri | |
---|---|
timeout | long : il tempo in millisecondi prima che il dispositivo non risponda, 0L per nessun timeout |
envMap | |
commandArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiFastbootCommand
public abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)
Metodo helper che esegue un comando fastboot come comando di sistema.
Previsto per essere utilizzato quando il dispositivo è già in modalità fastboot.Parametri | |
---|---|
timeout | long : il tempo in millisecondi prima della scadenza del comando |
commandArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiFastbootCommand
public abstract CommandResult executeFastbootCommand (String... commandArgs)
Metodo helper che esegue un comando fastboot come comando di sistema con un timeout predefinito di 2 minuti.
Previsto per essere utilizzato quando il dispositivo è già in modalità fastboot.
Parametri | |
---|---|
commandArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (String... commandArgs)
Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema.
Identico aexecuteFastbootCommand(String)
tranne che utilizza un timeout più lungo.Parametri | |
---|---|
commandArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (envVarMap, String... commandArgs)
Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema con variabili di ambiente di sistema.
Identico a executeFastbootCommand(String)
tranne che utilizza un timeout più lungo.
Parametri | |
---|---|
envVarMap | |
commandArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
executeShellCommand
public abstract String executeShellCommand (String command)
Metodo helper che esegue un comando adb shell e restituisce l'output come String
.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
ritorna | |
---|---|
String | l'output della shell |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
receiver | IShellOutputReceiver : IShellOutputReceiver a cui indirizzare l'output della shell. |
maxTimeToOutputShellResponse | long : l'intervallo di tempo massimo durante il quale il comando può non emettere alcuna risposta; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
retryAttempts | int : il numero massimo di volte per riprovare il comando se fallisce a causa di un'eccezione. DeviceNotResponsiveException verrà generata se retryAttempts viene eseguito senza successo. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
receiver | IShellOutputReceiver : IShellOutputReceiver a cui indirizzare l'output della shell. |
maxTimeoutForCommand | long : il timeout massimo per il completamento del comando; unità specificata in timeUnit |
maxTimeToOutputShellResponse | long : l'intervallo di tempo massimo durante il quale il comando può non emettere alcuna risposta; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
retryAttempts | int : il numero massimo di volte per riprovare il comando se fallisce a causa di un'eccezione. DeviceNotResponsiveException verrà generata se retryAttempts viene eseguito senza successo. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver)
Esegue il comando adb shell specificato, riprovando più volte se il comando fallisce.
Una forma più semplice diexecuteShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
con valori predefiniti.Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
receiver | IShellOutputReceiver : IShellOutputReceiver a cui indirizzare l'output della shell. |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command)
Metodo helper che esegue un comando adb shell e restituisce i risultati come CommandResult
opportunamente popolato con l'output dello stato del comando, stdout e stderr.
Parametri | |
---|---|
command | String : il comando da eseguire. |
ritorna | |
---|---|
CommandResult | Il risultato in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)
Metodo helper che esegue un comando adb shell e restituisce i risultati come CommandResult
opportunamente popolato con l'output dello stato del comando e stderr. stdout è indirizzato al flusso specificato.
Parametri | |
---|---|
command | String : il comando da eseguire. |
pipeToOutput | OutputStream : ERROR(/OutputStream) dove verrà reindirizzato l'output std o null. |
ritorna | |
---|---|
CommandResult | Il risultato in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput)
Metodo helper che esegue un comando adb shell e restituisce i risultati come CommandResult
opportunamente popolato con l'output dello stato del comando, stdout e stderr.
Parametri | |
---|---|
command | String : il comando da eseguire. |
pipeAsInput | File : Un ERROR(/File) che verrà reindirizzato come input al comando, o null. |
ritorna | |
---|---|
CommandResult | Il risultato in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
maxTimeoutForCommand | long : il timeout massimo per il completamento del comando; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
retryAttempts | int : il numero massimo di volte per riprovare il comando se fallisce a causa di un'eccezione. DeviceNotResponsiveException verrà generata se retryAttempts viene eseguito senza successo. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
maxTimeoutForCommand | long : il timeout massimo per il completamento del comando; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
pipeAsInput | File : Un ERROR(/File) che verrà reindirizzato come input al comando, o null. |
pipeToOutput | OutputStream : ERROR(/OutputStream) dove verrà reindirizzato l'output std o null. |
maxTimeoutForCommand | long : il timeout massimo per il completamento del comando; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
retryAttempts | int : il numero massimo di volte per riprovare il comando se fallisce a causa di un'eccezione. DeviceNotResponsiveException verrà generata se retryAttempts viene eseguito senza successo. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
eseguiShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Esegue un comando adb shell, con più parametri per controllare il comportamento del comando.
Parametri | |
---|---|
command | String : il comando adb shell da eseguire |
pipeAsInput | File : Un ERROR(/File) che verrà reindirizzato come input al comando, o null. |
pipeToOutput | OutputStream : ERROR(/OutputStream) dove verrà reindirizzato l'output std o null. |
pipeToError | OutputStream : ERROR(/OutputStream) dove verrà reindirizzato l'errore std o null. |
maxTimeoutForCommand | long : il timeout massimo per il completamento del comando; unità specificata in timeUnit |
timeUnit | TimeUnit : unità per maxTimeToOutputShellResponse |
retryAttempts | int : il numero massimo di volte per riprovare il comando se fallisce a causa di un'eccezione. DeviceNotResponsiveException verrà generata se retryAttempts viene eseguito senza successo. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
Guarda anche:
fastbootWipePartition
public abstract CommandResult fastbootWipePartition (String partition)
Metodo di supporto che cancella una partizione per il dispositivo.
SegetUseFastbootErase()
è true
, la cancellazione rapida verrà utilizzata per cancellare la partizione. Il dispositivo deve quindi creare un filesystem al successivo avvio del dispositivo. In caso contrario, viene utilizzato il formato fastboot che creerà un nuovo filesystem sul dispositivo. Previsto per essere utilizzato quando il dispositivo è già in modalità fastboot.Parametri | |
---|---|
partition | String : la partizione da pulire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getApiLevel
public abstract int getApiLevel ()
Ottieni il livello API del dispositivo. Il valore predefinito è UNKNOWN_API_LEVEL
.
ritorna | |
---|---|
int | un numero intero che indica il livello API del dispositivo |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBasebandVersion
public abstract String getBasebandVersion ()
Metodo conveniente per ottenere la versione in banda base (radio) di questo dispositivo. Ottenere la versione radio è specifico del dispositivo, quindi potrebbe non restituire le informazioni corrette per tutti i dispositivi. Questo metodo si basa sulla proprietà gsm.version.baseband per restituire le informazioni sulla versione corretta. Questo non è accurato per alcuni dispositivi CDMA e la versione restituita qui potrebbe non corrispondere alla versione riportata da fastboot e potrebbe non restituire la versione per la radio CDMA. TL;DR questo metodo riporta solo la versione accurata se la proprietà gsm.version.baseband è la stessa della versione restituita da fastboot getvar version-baseband
.
ritorna | |
---|---|
String | la versione in banda base String o null se non può essere determinata (il dispositivo non ha radio o la stringa della versione non può essere letta) |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getBattery
public abstract Integer getBattery ()
Restituisce il livello corrente della batteria di un dispositivo o Null se il livello della batteria non è disponibile.
ritorna | |
---|---|
Integer |
getBooleanProperty
public abstract boolean getBooleanProperty (String name, boolean defaultValue)
Restituisce il valore booleano della proprietà data.
Parametri | |
---|---|
name | String : il nome della proprietà |
defaultValue | boolean : valore predefinito da restituire se la proprietà è vuota o non esiste. |
ritorna | |
---|---|
boolean | true se la proprietà ha valore "1" , "y" , "yes" , "on" o "true" , false se la proprietà ha valore "0" , "n" , "no" , "off" , "false" , altrimenti defaultValue . |
Getta | |
---|---|
DeviceNotAvailableException |
getBootHistory
public abstractgetBootHistory ()
Il metodo helper raccoglie la mappa della cronologia di avvio con l'ora di avvio e il motivo dell'avvio.
ritorna | |
---|---|
Mappa dell'ora di avvio (ora UTC in secondi da Epoch) e motivo dell'avvio |
Getta | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
public abstractgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
Il metodo helper raccoglie la mappa della cronologia di avvio con l'ora di avvio e il motivo dell'avvio dall'ora specificata dall'epoca dal dispositivo e l'unità di tempo specificata. Il dispositivo corrente utcEpochTime in millisecondi può essere ottenuto con il metodo getDeviceDate()
.
Parametri | |
---|---|
utcEpochTime | long : il tempo del dispositivo da Epoch. |
timeUnit | TimeUnit : l'unità di tempo TimeUnit . |
ritorna | |
---|---|
Mappa dell'ora di avvio (ora UTC in secondi da Epoch) e motivo dell'avvio |
Getta | |
---|---|
DeviceNotAvailableException |
getBootloaderVersion
public abstract String getBootloaderVersion ()
Metodo conveniente per ottenere la versione bootloader di questo dispositivo.
Tenterà di recuperare la versione del bootloader dallo stato corrente del dispositivo. (ovvero se il dispositivo è in modalità fastboot, tenterà di recuperare la versione da fastboot)ritorna | |
---|---|
String | la versione del bootloader String o null se non è possibile trovarla |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getBuildAlias
public abstract String getBuildAlias ()
Recupera l'alias della build attualmente in esecuzione sul dispositivo.
L'alias di build è in genere una stringa più leggibile rispetto all'id di build (in genere un numero per le build di Nexus). Ad esempio, la versione finale di Android 4.2 ha l'alias build JDQ39 e l'ID build 573038
ritorna | |
---|---|
String | l'alias build o eseguire il fallback all'id build se non è stato possibile recuperarlo |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildFlavor
public abstract String getBuildFlavor ()
Recupera il sapore di costruzione per il dispositivo.
ritorna | |
---|---|
String | il sapore di build o null se non è stato possibile recuperarlo |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildId
public abstract String getBuildId ()
Recupera la build attualmente in esecuzione sul dispositivo.
ritorna | |
---|---|
String | l'ID build o IBuildInfo#UNKNOWN_BUILD_ID se non è stato possibile recuperarlo |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBuildSigningKeys
public abstract String getBuildSigningKeys ()
Restituisce il tipo di chiave usato per firmare l'immagine del dispositivo
In genere i dispositivi Android possono essere firmati con chiavi di prova (come in AOSP) o chiavi di rilascio (controllate dai singoli produttori di dispositivi)
ritorna | |
---|---|
String | La chiave di firma se trovata, null in caso contrario. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor ()
Restituisce un DeviceDescriptor
memorizzato nella cache se il dispositivo è allocato, altrimenti restituisce il DeviceDescriptor
corrente.
ritorna | |
---|---|
DeviceDescriptor |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)
Restituisce un DeviceDescriptor
memorizzato nella cache se il dispositivo è allocato, altrimenti restituisce il DeviceDescriptor
corrente.
Parametri | |
---|---|
shortDescriptor | boolean : se limitare o meno il descrittore alle informazioni minime |
ritorna | |
---|---|
DeviceDescriptor |
getChildren
public abstract String[] getChildren (String deviceFilePath)
Alternativa all'utilizzo IFileEntry
che a volte non funziona a causa delle autorizzazioni.
Parametri | |
---|---|
deviceFilePath | String : è il percorso sul dispositivo dove effettuare la ricerca |
ritorna | |
---|---|
String[] | Matrice di stringhe contenente tutti i file in un percorso sul dispositivo. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getConnection
public abstract AbstractConnection getConnection ()
Restituisce la connessione associata al dispositivo.
ritorna | |
---|---|
AbstractConnection |
getDeviceClass
public abstract String getDeviceClass ()
Ottieni la classe del dispositivo.
ritorna | |
---|---|
String | la classe del dispositivo String . |
getDeviceDate
public abstract long getDeviceDate ()
Restituisce la data del dispositivo in millisecondi dall'epoca.
ritorna | |
---|---|
long | la data del dispositivo in formato epoca. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor ()
Restituisce un DeviceDescriptor
dalle informazioni sul dispositivo per ottenere informazioni su di esso senza passare l'oggetto dispositivo effettivo.
ritorna | |
---|---|
DeviceDescriptor |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
Restituisce un DeviceDescriptor
dalle informazioni sul dispositivo per ottenere informazioni su di esso senza passare l'oggetto dispositivo effettivo.
Parametri | |
---|---|
shortDescriptor | boolean : se limitare o meno il descrittore alle informazioni minime |
ritorna | |
---|---|
DeviceDescriptor |
getDeviceState
public abstract TestDeviceState getDeviceState ()
Ottenere lo stato del dispositivo.
ritorna | |
---|---|
TestDeviceState |
getDeviceTimeOffset
public abstract long getDeviceTimeOffset (Date date)
Helper per ottenere la differenza di orario tra il dispositivo e un dato ERROR(/Date)
. Usa Epoch time internamente.
Parametri | |
---|---|
date | Date |
ritorna | |
---|---|
long | la differenza in millisecondi |
Getta | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public abstract InputStreamSource getEmulatorOutput ()
Ottieni il flusso dell'emulatore stdout e stderr
ritorna | |
---|---|
InputStreamSource | uscita dell'emulatore |
getExternalStoreFreeSpace
public abstract long getExternalStoreFreeSpace ()
Metodo di supporto per determinare la quantità di spazio libero sulla memoria esterna del dispositivo.
ritorna | |
---|---|
long | la quantità di spazio libero in KB |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getFastbootProductType
public abstract String getFastbootProductType ()
Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot.
Questo metodo dovrebbe essere utilizzato solo se il dispositivo deve essere in fastboot. In questo caso è una variante un po' più sicura rispetto al metodogetProductType()
generico, perché ITestDevice saprà ripristinare il dispositivo in fastboot se il dispositivo si trova in uno stato errato o non risponde.ritorna | |
---|---|
String | il nome del tipo di prodotto String o null se non può essere determinato |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getFastbootProductVariant
public abstract String getFastbootProductVariant ()
Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot.
Questo metodo dovrebbe essere utilizzato solo se il dispositivo deve essere in fastboot. In questo caso è una variante un po' più sicura rispetto al metodogetProductType()
generico, perché ITestDevice saprà ripristinare il dispositivo in fastboot se il dispositivo si trova in uno stato errato o non risponde.ritorna | |
---|---|
String | il nome del tipo di prodotto String o null se non può essere determinato |
Getta | |
---|---|
DeviceNotAvailableException | se la connessione con il dispositivo viene persa e non può essere ripristinata. |
getFastbootSerialNumber
public abstract String getFastbootSerialNumber ()
Restituisce il numero di serie della modalità fastboot.
ritorna | |
---|---|
String |
getFastbootVariable
public abstract String getFastbootVariable (String variableName)
Recupera il valore della variabile di avvio rapido specificato dal dispositivo.
Parametri | |
---|---|
variableName | String : il nome della variabile |
ritorna | |
---|---|
String | il valore della proprietà o null se non esiste |
Getta | |
---|---|
| Eccezione operazione non supportata |
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 captureReturns | |
---|---|
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 |
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 |
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(). |
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. |
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,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 |
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. |
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 |
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. |
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. |
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. |