NativeDevice
public class NativeDevice
extends Object
implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver
java.lang.Oggetto | |
↳ | com.android.tradefed.device.NativeDevice |
Implementazione predefinita di un ITestDevice
Dispositivi Android non full stack.
Riepilogo
Classi nidificate | |
---|---|
class | NativeDevice.AdbAction Un |
class | NativeDevice.AdbShellAction |
class | NativeDevice.RebootDeviceAction |
Costanti | |
---|---|
int | INVALID_USER_ID Valore restituito per qualsiasi ID utente non valido/non trovato: UserHandle ha definito il valore -10000 |
long | MAX_HOST_DEVICE_TIME_OFFSET |
int | MAX_RETRY_ATTEMPTS il numero predefinito di tentativi di esecuzione del comando |
Campi | |
---|---|
protected static final String | SD_CARD |
protected static final String | STORAGE_EMULATED |
protected TestDeviceOptions | mOptions |
protected final IDeviceStateMonitor | mStateMonitor
|
Costruttori pubblici | |
---|---|
NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor) Crea un |
Metodi pubblici | |
---|---|
void | batchPrefetchStartupBuildProps () Micro ottimizzazione (circa 400 millis) precaricando tutti gli oggetti di scena di cui abbiamo bisogno anziché chiamare "adb getprop" per ciascuno di essi. |
boolean | canSwitchToHeadlessSystemUser () Restituisce se è consentito passare all'utente SYSTEM senza testa. |
boolean | checkApiLevelAgainstNextRelease (int strictMinLevel) Controlla se una funzione è attualmente supportata o meno dato un livello minimo supportato. |
boolean | checkConnectivity () Verificare che il dispositivo disponga di connettività di rete. |
boolean | clearErrorDialogs () Tentativo di eliminare eventuali finestre di dialogo di errore attualmente visualizzate sull'interfaccia utente del dispositivo. |
void | clearLastConnectedWifiNetwork () Cancella l'ultima rete Wi-Fi connessa. |
void | clearLogcat () Elimina tutti i dati logcat accumulati. |
boolean | connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) Si connette a una rete Wi-Fi. |
boolean | connectToWifiNetwork (String wifiSsid, String wifiPsk) Si connette a una rete Wi-Fi. |
boolean | connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk) Si connette a una rete wifi.f |
boolean | connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid) Si connette a una rete Wi-Fi. |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid) Una variante di |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk) Una variante di |
int | createUser (String name, boolean guest, boolean ephemeral) Crea un utente con un determinato nome e i flag forniti |
int | createUser (String name, boolean guest, boolean ephemeral, boolean forTesting) Crea un utente con un determinato nome e i flag forniti |
int | createUser (String name) Crea un utente con un determinato nome e flag predefiniti 0. |
int | createUserNoThrow (String name) Crea un utente con un determinato nome e flag predefiniti 0. |
void | deleteFile (String deviceFilePath) Metodo di supporto per eliminare un file o una directory sul dispositivo. |
void | deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver) Rimuove l' |
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 |
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 |
boolean | disableAdbRoot () Disattiva root adb. |
void | disableKeyguard () Tenta di disabilitare il blocco della tastiera. |
boolean | disableNetworkMonitor () Disabilita il monitoraggio della rete sul dispositivo. |
boolean | disconnectFromWifi () Si disconnette da una rete wifi. |
boolean | doesFileExist (String deviceFilePath, int userId) Metodo di supporto per determinare se il file sul dispositivo esiste per un determinato utente. |
boolean | doesFileExist (String deviceFilePath) Metodo di supporto per determinare se il file sul dispositivo esiste. |
File | dumpHeap (String process, String devicePath) Tentativo di eseguire il dump dell'heap da system_server. |
boolean | enableAdbRoot () Attiva root adb. |
boolean | enableNetworkMonitor () Abilita il monitoraggio della rete sul dispositivo. |
String | executeAdbCommand (long timeout, String... cmdArgs) Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato. |
String | executeAdbCommand (long timeout, envMap, String... cmdArgs) executeAdbCommand (long timeout, envMap, String... cmdArgs) Metodo helper che esegue un comando adb come comando di sistema con un timeout specificato. |
String | executeAdbCommand (String... cmdArgs) Metodo helper che esegue un comando adb come comando di sistema. |
CommandResult | executeFastbootCommand (String... cmdArgs) Metodo helper che esegue un comando fastboot come comando di sistema con un timeout predefinito di 2 minuti. |
CommandResult | executeFastbootCommand (long timeout, String... cmdArgs) Metodo helper che esegue un comando fastboot come comando di sistema. |
CommandResult | executeLongFastbootCommand (String... cmdArgs) Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema. |
CommandResult | executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs) Metodo di supporto che esegue un comando fastboot di lunga durata come comando di sistema con variabili di ambiente di sistema. |
String | executeShellCommand (String command) Metodo helper che esegue un comando adb shell e restituisce l'output come |
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. |
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. |
void | executeShellCommand (String command, IShellOutputReceiver receiver) Esegue il comando adb shell specificato, riprovando più volte se il comando fallisce. |
CommandResult | executeShellV2Command (String cmd) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
CommandResult | executeShellV2Command (String cmd, OutputStream pipeToOutput) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput) Metodo helper che esegue un comando adb shell e restituisce i risultati come |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Esegue un comando adb shell, con più parametri per controllare il comportamento del comando. |
CommandResult | executeShellV2Command (String cmd, 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. |
CommandResult | fastbootWipePartition (String partition) Metodo di supporto che cancella una partizione per il dispositivo. |
getActiveApexes () Recupera le informazioni sugli APEX attivati sul dispositivo. | |
getAllSettings (String namespace) Restituisce coppie chiave-valore dello spazio dei nomi richiesto. | |
DeviceAllocationState | getAllocationState () Restituisce lo stato di allocazione corrente del dispositivo |
String | getAndroidId (int userId) Trova e restituisce l'id android associato a uno userId, nullo se non trovato. |
getAndroidIds () Crea una mappa degli ID Android trovati corrispondenti agli ID utente. | |
int | getApiLevel () Ottieni il livello API del dispositivo. |
PackageInfo | getAppPackageInfo (String packageName) Recupera informazioni su un pacchetto installato sul dispositivo. |
getAppPackageInfos () Recupera le informazioni dei pacchetti installati sul dispositivo. | |
String | getBasebandVersion () Metodo conveniente per ottenere la versione in banda base (radio) di questo dispositivo. |
Integer | getBattery () Restituisce il livello corrente della batteria di un dispositivo o Null se il livello della batteria non è disponibile. |
boolean | getBooleanProperty (String name, boolean defaultValue) Restituisce il valore booleano della proprietà data. |
getBootHistory () Il metodo helper raccoglie la mappa della cronologia di avvio con l'ora di avvio e il motivo dell'avvio. | |
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. | |
String | getBootloaderVersion () Metodo conveniente per ottenere la versione bootloader di questo dispositivo. |
InputStreamSource | getBugreport () Recupera una segnalazione di bug dal dispositivo. |
InputStreamSource | getBugreportz () Recupera un bugreportz dal dispositivo. |
String | getBuildAlias () Recupera l'alias della build attualmente in esecuzione sul dispositivo. |
String | getBuildFlavor () Recupera il sapore di costruzione per il dispositivo. |
String | getBuildId () Recupera la build attualmente in esecuzione sul dispositivo. |
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) |
DeviceDescriptor | getCachedDeviceDescriptor () Restituisce un |
DeviceDescriptor | getCachedDeviceDescriptor (boolean shortDescriptor) Restituisce un |
String[] | getChildren (String path) Alternativa all'utilizzo |
AbstractConnection | getConnection () La connessione corrente associata al dispositivo. |
DeviceFoldableState | getCurrentFoldableState () Restituisce lo stato pieghevole corrente del dispositivo o null se si sono verificati problemi. |
int | getCurrentUser () Restituisce l'id dell'utente attualmente in esecuzione. |
String | getDeviceClass () Ottieni la classe del dispositivo. |
long | getDeviceDate () Restituisce la data del dispositivo in millisecondi dall'epoca. |
DeviceDescriptor | getDeviceDescriptor () Restituisce un |
DeviceDescriptor | getDeviceDescriptor (boolean shortDescriptor) Restituisce un |
TestDeviceState | getDeviceState () Ottenere lo stato del dispositivo. |
long | getDeviceTimeOffset (Date date) Helper per ottenere la differenza di orario tra il dispositivo e un dato |
InputStreamSource | getEmulatorOutput () Ottieni il flusso dell'emulatore stdout e stderr |
Process | getEmulatorProcess () Restituisce il |
final File | getExecuteShellCommandLog () Il log che contiene tutti i log |
long | getExternalStoreFreeSpace () Metodo di supporto per determinare la quantità di spazio libero sulla memoria esterna del dispositivo. |
String | getFastbootPath () Restituisce il percorso del file binario fastboot in uso. |
String | getFastbootProductType () Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot. |
String | getFastbootProductVariant () Metodo pratico per ottenere il tipo di prodotto di questo dispositivo quando è in modalità fastboot. |
String | getFastbootSerialNumber () Restituisce il numero di serie della modalità fastboot. |
String | getFastbootVariable (String variableName) Recupera il valore della variabile di avvio rapido specificato dal dispositivo. |
String | getFastbootVersion () Restituisce la stringa della versione del file binario fastboot in uso. |
IFileEntry | getFileEntry (String path) Recupera un riferimento a un file remoto sul dispositivo. |
IFileEntry | getFileEntry (FileListingService.FileEntry entry) Helper non ufficiale per ottenere un |
getFoldableStates () Restituisce l'elenco degli stati ripiegabili sul dispositivo. | |
IDevice | getIDevice () Restituisce un riferimento |
getInstalledPackageNames () Recupera i nomi dei pacchetti dell'applicazione presenti sul dispositivo. | |
long | getIntProperty (String name, long defaultValue) Restituisce il valore intero della proprietà data dal dispositivo. |
String | getIpAddress () Ottiene l'indirizzo IP del dispositivo. |
KeyguardControllerState | getKeyguardState () Restituisce un oggetto per ottenere lo stato corrente del keyguard o null se non supportato. |
long | getLastExpectedRebootTimeMillis () Restituisce l'ultima volta che le API Tradefed hanno attivato un riavvio in millisecondi da EPOCH come restituito da |
int | getLaunchApiLevel () Ottieni il primo livello API lanciato del dispositivo. |
InputStreamSource | getLogcat () Acquisisce un flusso di istantanee dei dati logcat. |
InputStreamSource | getLogcat (int maxBytes) Acquisisce un flusso di istantanee degli ultimi |
InputStreamSource | getLogcatDump () Ottieni un dump dell'attuale logcat per il dispositivo. |
InputStreamSource | getLogcatSince (long date) Acquisisce un flusso di istantanee dei dati logcat acquisiti a partire dalla data fornita. |
String | getMacAddress () Restituisce l'indirizzo MAC del dispositivo, null se non riesce a eseguire la query dal dispositivo. |
Integer | getMainUserId () Restituisce l'ID utente principale. |
getMainlineModuleInfo () Ottieni le informazioni sui moduli mainline installati sul dispositivo. | |
int | getMaxNumberOfRunningUsersSupported () Ottieni il numero massimo di utenti in esecuzione simultanei supportati. |
int | getMaxNumberOfUsersSupported () Ottieni il numero massimo di utenti supportati. |
Process | getMicrodroidProcess () |
IDeviceStateMonitor | getMonitor () Restituisce l' |
String | getMountPoint (String mountName) Restituisce un punto di montaggio. |
ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) Restituisce un |
getMountPointInfo () Restituisce una versione analizzata delle informazioni in /proc/mounts sul dispositivo | |
TestDeviceOptions | getOptions () Recupera le opzioni di test per il dispositivo. |
long | getPartitionFreeSpace (String partition) Metodo di supporto per determinare la quantità di spazio libero sulla partizione del dispositivo. |
Integer | getPrimaryUserId () Restituisce l'ID utente principale. |
ProcessInfo | getProcessByName (String processName) Il metodo helper esegue il comando "pidof" e "stat" e restituisce l'oggetto |
String | getProcessPid (String process) Restituisce il pid del servizio o null se qualcosa è andato storto. |
String | getProductType () Metodo conveniente per ottenere il tipo di prodotto di questo dispositivo. |
String | getProductVariant () Metodo conveniente per ottenere la variante di prodotto di questo dispositivo. |
String | getProperty (String name) Recupera il valore della proprietà specificato dal dispositivo. |
ITestDevice.RecoveryMode | getRecoveryMode () Ottieni la modalità di ripristino corrente utilizzata per il dispositivo. |
InputStreamSource | getScreenshot (String format) Acquisisce uno screenshot dal dispositivo. |
InputStreamSource | getScreenshot (long displayId) Acquisisce uno screenshot dal dispositivo a cui è stato assegnato l'ID display. |
InputStreamSource | getScreenshot (String format, boolean rescale) Acquisisce uno screenshot dal dispositivo. |
InputStreamSource | getScreenshot () Acquisisce uno screenshot dal dispositivo. |
String | getSerialNumber () Metodo conveniente per ottenere il numero di serie di questo dispositivo. |
String | getSetting (int userId, String namespace, String key) Restituisce il valore dell'impostazione richiesta. |
String | getSetting (String namespace, String key) Vedere |
String | getSimOperator () Restituisci l'operatore della carta SIM o null se non disponibile o se il dispositivo non è disponibile. |
String | getSimState () Restituisce lo stato della scheda SIM o nullo se non disponibile o il dispositivo non è disponibile. |
getTombstones () Recupera e restituisci l'elenco delle pietre tombali dai dispositivi. | |
long | getTotalMemory () Restituisce la dimensione totale della memoria fisica in byte o -1 in caso di errore interno |
getUninstallablePackageNames () Recupera i nomi dei pacchetti dell'applicazione che possono essere disinstallati. | |
boolean | getUseFastbootErase () Scopri se utilizzare la cancellazione fastboot o il formato fastboot per cancellare una partizione sul dispositivo. |
int | getUserFlags (int userId) Trova e restituisce i flag di un dato utente. |
getUserInfos () Ottiene la mappa di useId per | |
int | getUserSerialNumber (int userId) Restituisce il numero seriale associato allo userId se trovato, -10000 negli altri casi. |
IManagedTestDevice.DeviceEventResponse | handleAllocationEvent (DeviceEvent event) Elabora il DeviceEvent specificato. Elabora il DeviceEvent, che può o meno trasferire questo dispositivo a un nuovo stato di allocazione. |
boolean | hasFeature (String feature) Controlla se una funzione è disponibile su un dispositivo. |
String | installPackage (File packageFile, boolean reinstall, String... extraArgs) Installa un pacchetto Android sul dispositivo. |
String | installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs) Installa un pacchetto Android sul dispositivo. |
String | installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs) Installa un pacchetto Android sul dispositivo per un determinato utente. |
String | installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) Installa un pacchetto Android sul dispositivo per un determinato utente. |
void | invalidatePropertyCache () |
boolean | isAdbRoot () |
boolean | isAdbTcp () |
boolean | isAppEnumerationSupported () Controlla se la piattaforma sul dispositivo supporta l'enumerazione delle app |
boolean | isBypassLowTargetSdkBlockSupported () Verifica se la piattaforma sul dispositivo supporta l'esclusione del blocco sdk con target basso nelle installazioni di app |
boolean | isDeviceEncrypted () Restituisce se il dispositivo è crittografato. |
boolean | isDirectory (String path) Restituisce True se il percorso sul dispositivo è una directory, false in caso contrario. |
boolean | isEnableAdbRoot () |
boolean | isEncryptionSupported () Restituisce se la crittografia è supportata sul dispositivo. |
boolean | isExecutable (String fullPath) Restituisce True se il percorso del file sul dispositivo è un file eseguibile, false in caso contrario. |
boolean | isFastbootEnabled () Ritorna se fastboot è disponibile per il dispositivo. |
boolean | isHeadless () Restituisce true se il dispositivo è headless (senza schermo), false in caso contrario. |
boolean | isHeadlessSystemUserMode () Restituisce se il dispositivo utilizza la modalità utente di sistema headless. |
boolean | isMainUserPermanentAdmin () Restituisce se l'utente principale è un amministratore permanente e non può essere eliminato o sottoposto a downgrade allo stato di non amministratore. |
boolean | isMultiUserSupported () Determina se è supportato il multiutente. |
boolean | isPackageInstalled (String packageName, String userId) Interroga il dispositivo per un determinato nome di pacchetto e un determinato ID utente per verificare se è attualmente installato o meno per quell'utente. |
boolean | isPackageInstalled (String packageName) Interroga il dispositivo per un determinato nome di pacchetto per verificare se è attualmente installato o meno. |
boolean | isRuntimePermissionSupported () Controlla se la piattaforma sul dispositivo supporta la concessione di autorizzazioni di runtime |
boolean | isStateBootloaderOrFastbootd () Restituisce true se il dispositivo è in |
boolean | isUserRunning (int userId) Controlla se un determinato utente è in esecuzione. |
boolean | isUserSecondary (int userId) Restituisce se l'utente specificato è un utente secondario in base ai suoi flag. |
boolean | isUserVisible (int userId) Verifica se l'utente specificato è visibile. |
boolean | isUserVisibleOnDisplay (int userId, int displayId) Verifica se l'utente specificato è visibile nella visualizzazione specificata. |
boolean | isVisibleBackgroundUsersOnDefaultDisplaySupported () Restituisce se il dispositivo consente agli utenti di essere avviati visibili in background in |
boolean | isVisibleBackgroundUsersSupported () Restituisce se il dispositivo consente agli utenti di essere avviati visibili in background. |
boolean | isWifiEnabled () Verifica se il Wi-Fi è abilitato. |
listDisplayIds () Raccogli l'elenco degli ID display disponibili sul dispositivo come riportato da "dumpsys SurfaceFlinger". | |
listDisplayIdsForStartingVisibleBackgroundUsers () Ottiene l'elenco delle schermate che possono essere utilizzate per | |
listUsers () Ottiene l'elenco degli utenti nel dispositivo. | |
boolean | logAnrs ( ITestLogger logger) Raccoglie e registra gli ANR dal dispositivo. |
boolean | logBugreport (String dataName, ITestLogger listener) Metodo di supporto per prendere un bugreport e registrarlo ai reporter. |
void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) Registra un messaggio nel logcat del dispositivo. |
void | nonBlockingReboot () Emette un comando per riavviare il dispositivo e ritorna al comando completo e quando il dispositivo non è più visibile ad adb. |
void | postAdbRootAction () Eseguire l'override se il dispositivo necessita di alcune azioni specifiche da eseguire dopo il root adb e prima che il dispositivo sia di nuovo online. |
void | postAdbUnrootAction () Eseguire l'override se il dispositivo necessita di alcune azioni specifiche da intraprendere dopo l'annullamento del root di adb e prima che il dispositivo sia di nuovo online. |
void | postBootSetup () Esegui le istruzioni per configurare il dispositivo per testarlo dopo ogni avvio. |
void | postInvocationTearDown (Throwable exception) Passaggi aggiuntivi per la pulizia richiesta specifica del dispositivo che verrà eseguita al termine della chiamata. |
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. |
boolean | pullDir (String deviceFilePath, File localDir) Estrai in modo ricorsivo i contenuti della directory dal dispositivo. |
boolean | pullFile (String remoteFilePath, File localFile) Recupera un file dal dispositivo. |
File | pullFile (String remoteFilePath, int userId) Recupera un file dal dispositivo, lo archivia in un |
File | pullFile (String remoteFilePath) Recupera un file dal dispositivo, lo archivia in un |
boolean | pullFile (String remoteFilePath, File localFile, int userId) Recupera un file dal dispositivo. |
String | pullFileContents (String remoteFilePath) Recupera un file dal dispositivo e ne restituisce il contenuto. |
File | pullFileFromExternal (String remoteFilePath) Un metodo pratico per recuperare un file dalla memoria esterna del dispositivo, memorizzarlo in un |
boolean | pushDir (File localFileDir, String deviceFilePath, excludedDirectories) pushDir (File localFileDir, String deviceFilePath, excludedDirectories) Invia in modo ricorsivo i contenuti delle directory al dispositivo escludendo alcune directory filtrate. |
boolean | pushDir (File localFileDir, String deviceFilePath) Invia in modo ricorsivo i contenuti della directory al dispositivo. |
boolean | pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded) Variante di |
boolean | pushFile (File localFile, String remoteFilePath) Invia un file al dispositivo. |
boolean | pushString (String contents, String remoteFilePath) Invia il file creato da una stringa al dispositivo |
void | reboot (String reason) Riavvia il dispositivo in modalità adb con |
void | reboot () Riavvia il dispositivo in modalità adb. |
void | rebootIntoBootloader () Riavvia il dispositivo in modalità bootloader. |
void | rebootIntoFastbootd () Riavvia il dispositivo in modalità fastbootd. |
void | rebootIntoRecovery () Riavvia il dispositivo in modalità di ripristino adb. |
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 |
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 |
void | rebootUntilOnline () Un'alternativa a |
void | rebootUntilOnline (String reason) Un'alternativa a |
void | rebootUserspace () Riavvia solo la parte dello spazio utente del dispositivo. |
void | rebootUserspaceUntilOnline () Un'alternativa a |
boolean | recoverDevice () Tentativi di ripristinare la comunicazione del dispositivo. |
void | registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver) Registra un |
void | remountSystemReadOnly () Rendere la partizione di sistema sul dispositivo di sola lettura. |
void | remountSystemWritable () Rendi scrivibile la partizione di sistema sul dispositivo. |
void | remountVendorReadOnly () Rendere la partizione del fornitore sul dispositivo di sola lettura. |
void | remountVendorWritable () Rendere scrivibile la partizione del fornitore sul dispositivo. |
boolean | removeAdmin (String componentName, int userId) Rimuovi l'amministratore del dispositivo specificato in un determinato utente e restituisci |
void | removeOwners () Rimuovi tutti i proprietari di profili del dispositivo esistenti con il massimo sforzo. |
boolean | removeUser (int userId) Rimuovere un determinato utente dal dispositivo. |
void | resetContentProviderSetup () Reimpostare il contrassegno per l'impostazione del fornitore di contenuti per attivarlo nuovamente. |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) Metodo pratico per eseguire |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) Esegue i test di strumentazione e fornisce il ripristino del dispositivo. |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) Uguale |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) Uguale a |
void | setConfiguration ( IConfiguration configuration) Inietta l' |
final void | setConnectionAvdInfo ( GceAvdInfo avdInfo) |
void | setDate (Date date) Imposta la data sul dispositivo Nota: l'impostazione della data sul dispositivo richiede root |
boolean | setDeviceOwner (String componentName, int userId) Imposta un componente di amministrazione del dispositivo come proprietario del dispositivo in un determinato utente. |
void | setDeviceState ( TestDeviceState deviceState) Aggiorna lo stato del dispositivo. |
void | setEmulatorOutputStream ( SizeLimitedOutputStream output) Per l'emulatore impostare |
void | setEmulatorProcess (Process p) Imposta |
void | setFastbootEnabled (boolean fastbootEnabled) Imposta l'opzione fastboot per il dispositivo. |
void | setFastbootPath (String fastbootPath) Imposta il percorso del file binario fastboot da utilizzare. |
void | setIDevice (IDevice newDevice) Aggiorna l'IDevice associato a questo ITestDevice. |
void | setLogStartDelay (int delay) Imposta il tempo di attesa in ms prima di avviare l'acquisizione di logcat per un dispositivo online. |
void | setOptions ( TestDeviceOptions options) Impostare |
boolean | setProperty (String propKey, String propValue) Imposta il valore della proprietà specificato sul dispositivo. |
void | setRecovery ( IDeviceRecovery recovery) Impostare l' |
void | setRecoveryMode ( ITestDevice.RecoveryMode mode) Imposta la modalità di ripristino corrente da utilizzare per il dispositivo. |
void | setSetting (String namespace, String key, String value) Vedere |
void | setSetting (int userId, String namespace, String key, String value) Aggiungi un valore di impostazione allo spazio dei nomi di un determinato utente. |
void | setTestLogger ( ITestLogger testLogger) Inietta l'istanza |
void | setUseFastbootErase (boolean useFastbootErase) Imposta se utilizzare la cancellazione fastboot o il formato fastboot per cancellare una partizione sul dispositivo. |
void | startLogcat () Avvia l'acquisizione dell'output logcat dal dispositivo in background. |
boolean | startUser (int userId) Avvia un determinato utente in background se è attualmente interrotto. |
boolean | startUser (int userId, boolean waitFlag) Avvia un determinato utente in background se è attualmente interrotto. |
boolean | startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag) Avvia un dato utente in background, visibile nel dato display (cioè, permettendo all'utente di lanciare attività in quel display). |
void | stopEmulatorOutput () Chiudi ed elimina l'output dell'emulatore. |
void | stopLogcat () Interrompi l'acquisizione dell'output logcat dal dispositivo ed elimina i dati logcat attualmente salvati. |
boolean | stopUser (int userId) Arresta un determinato utente. |
boolean | stopUser (int userId, boolean waitFlag, boolean forceFlag) Arrestare un determinato utente. |
String | switchToAdbTcp () Passa il dispositivo alla modalità adb-over-tcp. |
boolean | switchToAdbUsb () Passa il dispositivo alla modalità adb su usb. |
boolean | switchUser (int userId) Passa a un altro ID utente con un timeout predefinito. |
boolean | switchUser (int userId, long timeout) Passa a un altro ID utente con il timeout fornito come scadenza. |
boolean | syncFiles (File localFileDir, String deviceFilePath) Sincronizza in modo incrementale il contenuto di una directory di file locale sul dispositivo. |
Bugreport | takeBugreport () Prendi un bugreport e lo restituisce all'interno di un oggetto |
String | uninstallPackage (String packageName) Disinstalla un pacchetto Android dal dispositivo. |
String | uninstallPackageForUser (String packageName, int userId) Disinstalla un pacchetto Android dal dispositivo per un determinato utente. |
boolean | unlockDevice () Sblocca il dispositivo se il dispositivo è in uno stato crittografato. |
boolean | waitForBootComplete (long timeOut) Si blocca finché non viene impostato il flag di avvio completo del dispositivo. |
boolean | waitForDeviceAvailable () Attende che il dispositivo sia reattivo e disponibile per il test. |
boolean | waitForDeviceAvailable (long waitTime) Attende che il dispositivo sia reattivo e disponibile per il test. |
boolean | waitForDeviceAvailableInRecoverPath (long waitTime) Attende che il dispositivo sia reattivo e disponibile senza considerare il percorso di ripristino. |
void | waitForDeviceBootloader () Si blocca finché il dispositivo non è visibile tramite fastboot. |
boolean | waitForDeviceInRecovery (long waitTime) Blocchi affinché il dispositivo sia nello stato 'adb recovery' (si noti che questo è distinto da |
boolean | waitForDeviceInSideload (long waitTime) Blocchi affinché il dispositivo sia nello stato 'adb sideload' |
boolean | waitForDeviceNotAvailable (long waitTime) Blocchi affinché il dispositivo non sia disponibile, ovvero mancante da adb |
void | waitForDeviceOnline () Blocca finché il dispositivo non è visibile tramite adb. |
void | waitForDeviceOnline (long waitTime) Blocca finché il dispositivo non è visibile tramite adb. |
boolean | waitForDeviceShell (long waitTime) Attende che il dispositivo risponda a un comando shell adb di base. |
Metodi protetti | |
---|---|
void | addExtraConnectionBuilderArgs ( DefaultConnection.ConnectionBuilder builder) |
String[] | buildAdbShellCommand (String command, boolean forceExitStatusDetection) Crea il comando del sistema operativo per la sessione di comandi della shell adb e gli argomenti specificati |
void | checkApiLevelAgainst (String feature, int strictMinLevel) |
NativeDevice.RebootDeviceAction | createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason) Crea un |
IRunUtil | createRunUtil () |
void | doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason) Esegui un riavvio adb. |
void | ensureRuntimePermissionSupported () metodo helper per generare un'eccezione se l'autorizzazione di runtime non è supportata |
int | getApiLevelSafe () |
ITestLogger | getLogger () |
IRunUtil | getRunUtil () Ottenere l'istanza |
void | initializeConnection ( IBuildInfo info, MultiMap <String, String> attributes) |
String | internalGetProperty (String propName, String fastbootVar, String description) Recupera una proprietà del dispositivo, dalla cache ddmlib per impostazione predefinita, e torna a `adb shell getprop` o `fastboot getvar` a seconda che il dispositivo sia in Fastboot o meno. |
boolean | isInRebootCallback () Restituisce se i callback di riavvio sono attualmente in esecuzione o meno. |
boolean | isNewer (File localFile, IFileEntry entry) Restituisce |
void | notifyRebootEnded () Notifica a tutti |
void | notifyRebootStarted () Notifica a tutti |
boolean | performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts) Esegue un'azione su questo dispositivo. |
void | postAdbReboot () Possibili azioni extra che possono essere intraprese dopo un riavvio. |
void | prePostBootSetup () Consente a ogni tipo di dispositivo (AndroidNativeDevice, TestDevice) di eseguire l'override di questo metodo per una specifica configurazione post-avvio. |
boolean | pullFileInternal (String remoteFilePath, File localFile) |
void | setClock (Clock clock) Impostare l'istanza Clock da utilizzare. |
void | setMicrodroidProcess (Process process) Contrassegna il TestDevice come microdroid e ne imposta il CID. |
void | setTestDeviceOptions ( deviceOptions) setTestDeviceOptions ( deviceOptions) |
CommandResult | simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) Esegue un semplice comando fastboot con variabili di ambiente e segnala lo stato del comando. |
CommandResult | simpleFastbootCommand (long timeout, String[] fullCmd) Esegue un semplice comando fastboot e segnala lo stato del comando. |
boolean | waitForDeviceNotAvailable (String operationDesc, long time) Attendi che il dispositivo diventi non disponibile (interrompi la segnalazione ad adb). |
Costanti
INVALID_USER_ID
public static final int INVALID_USER_ID
Valore restituito per qualsiasi ID utente non valido/non trovato: UserHandle ha definito il valore -10000
Valore costante: -10000 (0xffffd8f0)
MAX_HOST_DEVICE_TIME_OFFSET
protected static final long MAX_HOST_DEVICE_TIME_OFFSET
Valore costante: 5000 (0x0000000000001388)
MAX_RETRY_ATTEMPTS
protected static final int MAX_RETRY_ATTEMPTS
il numero predefinito di tentativi di esecuzione del comando
Valore costante: 2 (0x00000002)
Campi
SCHEDA SD
protected static final String SD_CARD
STORAGE_EMULATO
protected static final String STORAGE_EMULATED
mOptions
protected TestDeviceOptions mOptions
Costruttori pubblici
NativeDevice
public NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
Crea un TestDevice
.
Parametri | |
---|---|
device | IDevice : l' IDevice associato |
stateMonitor | IDeviceStateMonitor : il meccanismo IDeviceStateMonitor da usare |
allocationMonitor | IDeviceMonitor : l' IDeviceMonitor per informare sui cambiamenti dello stato di allocazione. Può essere nullo |
Metodi pubblici
batchPrefetchStartupBuildProps
public void batchPrefetchStartupBuildProps ()
Micro ottimizzazione (circa 400 millis) precaricando tutti gli oggetti di scena di cui abbiamo bisogno anziché chiamare "adb getprop" per ciascuno di essi. vale a dire che è altrettanto veloce recuperare tutte le proprietà quanto recuperarne una. Cose come device.getApiLevel(), checkApiLevelAgainstNextRelease e getBuildAlias chiamano tutti `adb getprop` sotto il cofano. Li recuperiamo in una chiamata e chiamiamo NativeDevice.setProperty. Anche se non lo facciamo, NativeDevice chiamerà esso stesso setProperty e memorizzerà nella cache il risultato per chiamate future. Lo stiamo solo facendo un po' prima. Se il dispositivo è in ripristino o ci sono altri errori durante il recupero degli oggetti di scena, li ignoriamo semplicemente.
canSwitchToHeadlessSystemUser
public boolean canSwitchToHeadlessSystemUser ()
Restituisce se è consentito passare all'utente SYSTEM senza testa.
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
checkApiLevelAgainstNextRelease
public 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 | |
---|---|
DeviceNotAvailableException |
checkConnettività
public boolean checkConnectivity ()
Verificare che il dispositivo disponga di connettività di rete.
ritorna | |
---|---|
boolean | true se il dispositivo dispone di una connessione di rete funzionante, false overwise. |
Getta | |
---|---|
DeviceNotAvailableException |
clearErrorDialogs
public boolean clearErrorDialogs ()
Tentativo di eliminare eventuali finestre di dialogo di errore attualmente visualizzate sull'interfaccia utente del dispositivo.
ritorna | |
---|---|
boolean | true se non erano presenti finestre di dialogo o le finestre di dialogo sono state cancellate correttamente. false altrimenti. |
Getta | |
---|---|
DeviceNotAvailableException |
clearLastConnectedWifiNetwork
public void clearLastConnectedWifiNetwork ()
Cancella l'ultima rete Wi-Fi connessa. Questo dovrebbe essere chiamato quando si avvia una nuova chiamata per evitare di connettersi alla rete Wi-Fi utilizzata nel test precedente dopo il riavvio del dispositivo.
clearLogcat
public 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.). connectToWifiNetwork
public boolean connectToWifiNetwork (wifiSsidToPsk, boolean scanSsid)
Si connette a una rete Wi-Fi.
Attiva il wifi e si blocca fino a quando non viene stabilita una connessione con una delle reti wifi fornite nella mappa wifiSsidToPsk. Una volta stabilita una connessione, l'istanza proverà a ripristinarla dopo ogni riavvio finché non viene chiamato ITestDevice#disconnectFromWifi()
o ITestDevice#clearLastConnectedWifiNetwork()
.
Parametri | |
---|---|
wifiSsidToPsk | |
scanSsid | boolean : se cercare gli SSID nascosti per questa rete. |
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)
Si connette a una rete Wi-Fi.
Attiva il Wi-Fi e si blocca fino a quando non viene stabilita una connessione corretta alla rete Wi-Fi specificata. Una volta stabilita una connessione, l'istanza proverà a ripristinarla dopo ogni riavvio finché non viene chiamatoITestDevice#disconnectFromWifi()
o ITestDevice#clearLastConnectedWifiNetwork()
.Parametri | |
---|---|
wifiSsid | String : l'ssid wifi a cui connettersi |
wifiPsk | String : passphrase PSK o null se non crittografato |
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
public boolean connectToWifiNetwork (wifiSsidToPsk)
Si connette a una rete Wi-Fi.
Attiva il wifi e si blocca fino a quando non viene stabilita una connessione con una delle reti wifi fornite nella mappa wifiSsidToPsk. Una volta stabilita una connessione, l'istanza tenterà di ripristinare la connessione dopo ogni riavvio finché non viene chiamato ITestDevice#disconnectFromWifi()
o ITestDevice#clearLastConnectedWifiNetwork()
Parametri | |
---|---|
wifiSsidToPsk |
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)
Si connette a una rete Wi-Fi.
Attiva il Wi-Fi e si blocca fino a quando non viene stabilita una connessione corretta alla rete Wi-Fi specificata. Una volta stabilita una connessione, l'istanza proverà a ripristinarla dopo ogni riavvio finché non viene chiamatoITestDevice#disconnectFromWifi()
o ITestDevice#clearLastConnectedWifiNetwork()
.Parametri | |
---|---|
wifiSsid | String : l'ssid wifi a cui connettersi |
wifiPsk | String : passphrase PSK o null se non crittografato |
scanSsid | boolean : se cercare l'SSID nascosto per questa rete. |
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)
Una variante di connectToWifiNetwork(String, String)
che si connette solo se il dispositivo attualmente non dispone di connettività di rete.
Parametri | |
---|---|
scanSsid | boolean : se cercare l'SSID nascosto per questa rete |
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)
Una variante di connectToWifiNetwork(String, String)
che si connette solo se il dispositivo attualmente non dispone di connettività di rete.
ritorna | |
---|---|
boolean | true se connesso correttamente alla rete Wi-Fi. false altrimenti |
Getta | |
---|---|
DeviceNotAvailableException |
creare un utente
public int createUser (String name, boolean guest, boolean ephemeral)
Crea un utente con un determinato nome e i flag forniti
Parametri | |
---|---|
name | String : dell'utente da creare sul dispositivo |
guest | boolean : abilita il flag utente --guest durante la creazione |
ephemeral | boolean : abilita il flag utente --ephemeral durante la creazione |
ritorna | |
---|---|
int | id dell'utente creato |
Getta | |
---|---|
DeviceNotAvailableException |
creare un utente
public int createUser (String name, boolean guest, boolean ephemeral, boolean forTesting)
Crea un utente con un determinato nome e i flag forniti
Parametri | |
---|---|
name | String : dell'utente da creare sul dispositivo |
guest | boolean : abilita il flag utente --guest durante la creazione |
ephemeral | boolean : abilita il flag utente --ephemeral durante la creazione |
forTesting | boolean : abilita il flag di test --for-testing durante la creazione |
ritorna | |
---|---|
int | id dell'utente creato |
Getta | |
---|---|
DeviceNotAvailableException |
creare un utente
public int createUser (String name)
Crea un utente con un determinato nome e flag predefiniti 0.
Parametri | |
---|---|
name | String : dell'utente da creare sul dispositivo |
ritorna | |
---|---|
int | il numero intero per l'ID utente creato |
Getta | |
---|---|
DeviceNotAvailableException |
createUserNoThrow
public int createUserNoThrow (String name)
Crea un utente con un determinato nome e flag predefiniti 0.
Parametri | |
---|---|
name | String : dell'utente da creare sul dispositivo |
ritorna | |
---|---|
int | il numero intero per l'ID utente creato o -1 per errore. |
Getta | |
---|---|
DeviceNotAvailableException |
cancella il file
public 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 | |
---|---|
DeviceNotAvailableException |
deregistrareDeviceActionReceiver
public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)
Rimuove l' IDeviceActionReceiver
registrato.
Parametri | |
---|---|
deviceActionReceiver | IDeviceActionReceiver : un IDeviceActionReceiver che verrà rimosso. |
deviceSoftRiavviato
public 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 | |
---|---|
DeviceNotAvailableException |
deviceSoftRestartedSince
public 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 | |
---|---|
DeviceNotAvailableException |
disabilitaAdbRoot
public 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 |
disabilitareKeyguard
public void disableKeyguard ()
Tenta di disabilitare il blocco della tastiera.
Per prima cosa attendi che l'invio di input sia pronto, ciò accade più o meno nello stesso momento in cui il dispositivo segnala BOOT_COMPLETE, apparentemente in modo asincrono, perché l'attuale implementazione del framework ha condizioni di competizione occasionali. Quindi viene inviato il comando per eliminare il blocco della tastiera (funziona solo su quelli non sicuri)
Getta | |
---|---|
DeviceNotAvailableException |
disabilita NetworkMonitor
public boolean disableNetworkMonitor ()
Disabilita il monitoraggio della rete sul dispositivo.
ritorna | |
---|---|
boolean | true se il monitoraggio viene disabilitato correttamente. false se fallisce. |
Getta | |
---|---|
DeviceNotAvailableException |
disconnettiDaWifi
public boolean disconnectFromWifi ()
Si disconnette da una rete wifi.
Rimuove tutte le reti dall'elenco delle reti conosciute e disabilita il wifi.ritorna | |
---|---|
boolean | true se disconnesso correttamente dalla rete Wi-Fi. false se la disconnessione non è riuscita. |
Getta | |
---|---|
DeviceNotAvailableException |
doesFileExist
public boolean doesFileExist (String deviceFilePath, int userId)
Metodo di supporto per determinare se il file sul dispositivo esiste per un determinato utente.
Parametri | |
---|---|
deviceFilePath | String : il percorso assoluto del file sul dispositivo da controllare |
userId | int : l'ID utente rispetto al quale verificare l'esistenza del file |
ritorna | |
---|---|
boolean | true se il file esiste, false in caso contrario. |
Getta | |
---|---|
DeviceNotAvailableException |
doesFileExist
public 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 |
dumpHeap
public File dumpHeap (String process, String devicePath)
Tentativo di eseguire il dump dell'heap da system_server. È responsabilità del chiamante ripulire il file scaricato.
Parametri | |
---|---|
process | String : il nome del processo del dispositivo su cui eseguire il dumpheap. |
devicePath | String : il percorso sul dispositivo dove inserire il dump. Questa deve essere una posizione in cui le autorizzazioni lo consentono. |
ritorna | |
---|---|
File | l' ERROR(/File) contenente il report. Null se qualcosa fallisce. |
Getta | |
---|---|
DeviceNotAvailableException |
abilitaAdbRoot
public 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 |
abilitaNetworkMonitor
public boolean enableNetworkMonitor ()
Abilita il monitoraggio della rete sul dispositivo.
ritorna | |
---|---|
boolean | true se il monitoraggio è abilitato correttamente. false se fallisce. |
Getta | |
---|---|
DeviceNotAvailableException |
eseguiAdbComando
public String executeAdbCommand (long timeout, String... cmdArgs)
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 |
cmdArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException |
eseguiAdbComando
public String executeAdbCommand (long timeout,envMap, String... cmdArgs)
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 | |
cmdArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException |
eseguiAdbComando
public String executeAdbCommand (String... cmdArgs)
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 | |
---|---|
cmdArgs | String : il comando adb e gli argomenti da eseguire |
ritorna | |
---|---|
String | lo stdout dal comando. null se il comando non è stato eseguito. |
Getta | |
---|---|
DeviceNotAvailableException |
eseguiFastbootCommand
public CommandResult executeFastbootCommand (String... cmdArgs)
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 | |
---|---|
cmdArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException |
eseguiFastbootCommand
public CommandResult executeFastbootCommand (long timeout, String... cmdArgs)
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 |
cmdArgs | String : il comando fastboot e gli argomenti da eseguire |
ritorna | |
---|---|
CommandResult | il CommandResult contenente l'output del comando |
Getta | |
---|---|
DeviceNotAvailableException |
executeLongFastbootCommand
public CommandResult executeLongFastbootCommand (String... cmdArgs)
Helper method which executes a long running fastboot command as a system command.
Identical toexecuteFastbootCommand(String)
except uses a longer timeout.Parametri | |
---|---|
cmdArgs | String : the fastboot command and arguments to run |
ritorna | |
---|---|
CommandResult | the CommandResult containing output of command |
Getta | |
---|---|
DeviceNotAvailableException |
executeLongFastbootCommand
public CommandResult executeLongFastbootCommand (envVarMap, String... cmdArgs)
Helper method which executes a long running fastboot command as a system command with system environment variables.
Identical to executeFastbootCommand(String)
except uses a longer timeout.
Parametri | |
---|---|
envVarMap | |
cmdArgs | String : the fastboot command and arguments to run |
ritorna | |
---|---|
CommandResult | the CommandResult containing output of command |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public String executeShellCommand (String command)
Helper method which executes a adb shell command and returns output as a String
.
Parametri | |
---|---|
command | String : the adb shell command to run |
ritorna | |
---|---|
String | the shell output |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
command | String : the adb shell command to run |
receiver | IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
maxTimeToOutputShellResponse | long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
command | String : the adb shell command to run |
receiver | IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
maxTimeToOutputShellResponse | long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver)
Executes the given adb shell command, retrying multiple times if command fails.
A simpler form ofexecuteShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
with default values.Parametri | |
---|---|
command | String : the adb shell command to run |
receiver | IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd)
Helper method which executes a adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Parametri | |
---|---|
cmd | String : The command that should be run. |
ritorna | |
---|---|
CommandResult | The result in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output and stderr. stdout is directed to the specified stream.
Parametri | |
---|---|
cmd | String : The command that should be run. |
pipeToOutput | OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
ritorna | |
---|---|
CommandResult | The result in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Parametri | |
---|---|
cmd | String : The command that should be run. |
pipeAsInput | File : A ERROR(/File) that will be piped as input to the command, or null. |
ritorna | |
---|---|
CommandResult | The result in CommandResult . |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
cmd | String : the adb shell command to run |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
cmd | String : the adb shell command to run |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
cmd | String : the adb shell command to run |
pipeAsInput | File : A ERROR(/File) that will be piped as input to the command, or null. |
pipeToOutput | OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Parametri | |
---|---|
cmd | String : the adb shell command to run |
pipeAsInput | File : A ERROR(/File) that will be piped as input to the command, or null. |
pipeToOutput | OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
pipeToError | OutputStream : ERROR(/OutputStream) where the std error will be redirected, or null. |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
ritorna | |
---|---|
CommandResult |
Getta | |
---|---|
DeviceNotAvailableException |
fastbootWipePartition
public CommandResult fastbootWipePartition (String partition)
Helper method which wipes a partition for the device.
IfgetUseFastbootErase()
is true
, then fastboot erase will be used to wipe the partition. The device must then create a filesystem the next time the device boots. Otherwise, fastboot format is used which will create a new filesystem on the device. Expected to be used when device is already in fastboot mode.Parametri | |
---|---|
partition | String : the partition to wipe |
ritorna | |
---|---|
CommandResult | the CommandResult containing output of command |
Getta | |
---|---|
DeviceNotAvailableException |
getActiveApexes
publicgetActiveApexes ()
Fetch the information about APEXes activated on the device.
ritorna | |
---|---|
ERROR(/Set) of ApexInfo currently activated on the device |
Getta | |
---|---|
DeviceNotAvailableException |
getAllSettings
publicgetAllSettings (String namespace)
Return key value pairs of requested namespace.
Parametri | |
---|---|
namespace | String : must be one of {"system", "secure", "global"} |
ritorna | |
---|---|
the map of key value pairs. Null if namespace is not supported. |
Getta | |
---|---|
DeviceNotAvailableException |
getAllocationState
public DeviceAllocationState getAllocationState ()
Return the current allocation state of device
ritorna | |
---|---|
DeviceAllocationState |
getAndroidId
public String getAndroidId (int userId)
Find and return the android-id associated to a userId, null if not found.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
String |
Getta | |
---|---|
DeviceNotAvailableException |
getAndroidIds
publicgetAndroidIds ()
Create a Map of android ids found matching user ids. There is no insurance that each user id will found an android id associated in this function so some user ids may match null.
ritorna | |
---|---|
Map of android ids found matching user ids. |
Getta | |
---|---|
DeviceNotAvailableException |
getApiLevel
public int getApiLevel ()
Get the device API Level. Defaults to UNKNOWN_API_LEVEL
.
ritorna | |
---|---|
int | an integer indicating the API Level of device |
Getta | |
---|---|
DeviceNotAvailableException |
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Fetch information about a package installed on device.
Parametri | |
---|---|
packageName | String |
ritorna | |
---|---|
PackageInfo | the PackageInfo or null if information could not be retrieved |
Getta | |
---|---|
DeviceNotAvailableException |
getAppPackageInfos
publicgetAppPackageInfos ()
Fetch information of packages installed on the device.
ritorna | |
---|---|
ERROR(/List) of PackageInfo s installed on the device. |
Getta | |
---|---|
DeviceNotAvailableException |
getBasebandVersion
public String getBasebandVersion ()
Convenience method to get baseband (radio) version of this device. Getting the radio version is device specific, so it might not return the correct information for all devices. This method relies on the gsm.version.baseband propery to return the correct version information. This is not accurate for some CDMA devices and the version returned here might not match the version reported from fastboot and might not return the version for the CDMA radio. TL;DR this method only reports accurate version if the gsm.version.baseband property is the same as the version returned by fastboot getvar version-baseband
.
ritorna | |
---|---|
String | the String baseband version or null if it cannot be determined (device has no radio or version string cannot be read) |
Getta | |
---|---|
DeviceNotAvailableException |
getBattery
public Integer getBattery ()
Returns the current battery level of a device or Null if battery level unavailable.
ritorna | |
---|---|
Integer |
getBooleanProperty
public boolean getBooleanProperty (String name, boolean defaultValue)
Returns boolean value of the given property.
Parametri | |
---|---|
name | String : the property name |
defaultValue | boolean : default value to return if property is empty or doesn't exist. |
ritorna | |
---|---|
boolean | true if the property has value "1" , "y" , "yes" , "on" , or "true" , false if the property has value of "0" , "n" , "no" , "off" , "false" , or defaultValue otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
getBootHistory
publicgetBootHistory ()
Helper method collects the boot history map with boot time and boot reason.
ritorna | |
---|---|
Map of boot time (UTC time in second since Epoch) and boot reason |
Getta | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
publicgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
Helper method collects the boot history map with boot time and boot reason since the given time since epoch from device and the time unit specified. The current device utcEpochTime in Millisecond can be obtained by method getDeviceDate()
.
Parametri | |
---|---|
utcEpochTime | long : the device time since Epoch. |
timeUnit | TimeUnit : the time unit TimeUnit . |
ritorna | |
---|---|
Map of boot time (UTC time in second since Epoch) and boot reason |
Getta | |
---|---|
DeviceNotAvailableException |
getBootloaderVersion
public String getBootloaderVersion ()
Convenience method to get the bootloader version of this device.
Will attempt to retrieve bootloader version from the device's current state. (ie if device is in fastboot mode, it will attempt to retrieve version from fastboot)ritorna | |
---|---|
String | the String bootloader version or null if it cannot be found |
Getta | |
---|---|
DeviceNotAvailableException |
getBugreport
public InputStreamSource getBugreport ()
Retrieves a bugreport from the device.
The implementation of this is guaranteed to continue to work on a device without an sdcard (or where the sdcard is not yet mounted).
ritorna | |
---|---|
InputStreamSource | An InputStreamSource which will produce the bugreport contents on demand. In case of failure, the InputStreamSource will produce an empty ERROR(/InputStream) . |
getBugreportz
public InputStreamSource getBugreportz ()
Retrieves a bugreportz from the device. Zip format bugreport contains the main bugreport and other log files that are useful for debugging.
Only supported for 'adb version' > 1.0.36
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the zip file containing the bugreportz, return null in case of failure. |
getBuildAlias
public String getBuildAlias ()
Retrieve the alias of the build that the device is currently running.
Build alias is usually a more readable string than build id (typically a number for Nexus builds). For example, final Android 4.2 release has build alias JDQ39, and build id 573038
ritorna | |
---|---|
String | the build alias or fall back to build id if it could not be retrieved |
Getta | |
---|---|
DeviceNotAvailableException |
getBuildFlavor
public String getBuildFlavor ()
Retrieve the build flavor for the device.
ritorna | |
---|---|
String | the build flavor or null if it could not be retrieved |
Getta | |
---|---|
DeviceNotAvailableException |
getBuildId
public String getBuildId ()
Retrieve the build the device is currently running.
ritorna | |
---|---|
String | the build id or IBuildInfo#UNKNOWN_BUILD_ID if it could not be retrieved |
Getta | |
---|---|
DeviceNotAvailableException |
getBuildSigningKeys
public String getBuildSigningKeys ()
Returns the key type used to sign the device image
Typically Android devices may be signed with test-keys (like in AOSP) or release-keys (controlled by individual device manufacturers)
ritorna | |
---|---|
String | The signing key if found, null otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
getCachedDeviceDescriptor
public DeviceDescriptor getCachedDeviceDescriptor ()
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the current DeviceDescriptor
.
ritorna | |
---|---|
DeviceDescriptor |
getCachedDeviceDescriptor
public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the current DeviceDescriptor
.
Parametri | |
---|---|
shortDescriptor | boolean : Whether or not to limit descriptor to bare minimum info |
ritorna | |
---|---|
DeviceDescriptor |
getChildren
public String[] getChildren (String path)
Alternative to using IFileEntry
that sometimes won't work because of permissions.
Parametri | |
---|---|
path | String : is the path on the device where to do the search |
ritorna | |
---|---|
String[] | Array of string containing all the file in a path on the device. |
Getta | |
---|---|
DeviceNotAvailableException |
getConnection
public AbstractConnection getConnection ()
The current connection associated with the device.
ritorna | |
---|---|
AbstractConnection |
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Returns the current foldable state of the device or null if some issues occurred.
ritorna | |
---|---|
DeviceFoldableState |
Getta | |
---|---|
DeviceNotAvailableException |
getCurrentUser
public int getCurrentUser ()
Return the id of the current running user. In case of error, return -10000.
ritorna | |
---|---|
int |
Getta | |
---|---|
DeviceNotAvailableException |
getDeviceClass
public String getDeviceClass ()
Get the device class.
ritorna | |
---|---|
String | the String device class. |
getDeviceDate
public long getDeviceDate ()
Return the date of the device in millisecond since epoch.
ritorna | |
---|---|
long | the date of the device in epoch format. |
Getta | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor ()
Return a DeviceDescriptor
from the device information to get info on it without passing the actual device object.
ritorna | |
---|---|
DeviceDescriptor |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
Return a DeviceDescriptor
from the device information to get info on it without passing the actual device object.
Parametri | |
---|---|
shortDescriptor | boolean : Whether or not to limit descriptor to bare minimum info |
ritorna | |
---|---|
DeviceDescriptor |
getDeviceState
public TestDeviceState getDeviceState ()
Get the device's state.
ritorna | |
---|---|
TestDeviceState |
getDeviceTimeOffset
public long getDeviceTimeOffset (Date date)
Helper to get the time difference between the device and a given ERROR(/Date)
. Use Epoch time internally.
Parametri | |
---|---|
date | Date |
ritorna | |
---|---|
long | the difference in milliseconds |
Getta | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public InputStreamSource getEmulatorOutput ()
Get the stream of emulator stdout and stderr
ritorna | |
---|---|
InputStreamSource | emulator output |
getEmulatorProcess
public Process getEmulatorProcess ()
Return the Process
corresponding to this emulator.
ritorna | |
---|---|
Process | the Process or null |
getExecuteShellCommandLog
public final File getExecuteShellCommandLog ()
The log that contains all the executeShellCommand(String)
logs.
ritorna | |
---|---|
File |
getExternalStoreFreeSpace
public long getExternalStoreFreeSpace ()
Helper method to determine amount of free space on device external storage.
ritorna | |
---|---|
long | the amount of free space in KB |
Getta | |
---|---|
DeviceNotAvailableException |
getFastbootPath
public String getFastbootPath ()
Returns the path of the fastboot binary being used. Still requires isFastbootEnabled()
to be true, to have fastboot functions enabled.
ritorna | |
---|---|
String |
getFastbootProductType
public String getFastbootProductType ()
Convenience method to get the product type of this device when its in fastboot mode.
This method should only be used if device should be in fastboot. Its a bit safer variant than the genericgetProductType()
method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.ritorna | |
---|---|
String | the String product type name or null if it cannot be determined |
Getta | |
---|---|
DeviceNotAvailableException |
getFastbootProductVariant
public String getFastbootProductVariant ()
Convenience method to get the product type of this device when its in fastboot mode.
This method should only be used if device should be in fastboot. Its a bit safer variant than the genericgetProductType()
method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.ritorna | |
---|---|
String | the String product type name or null if it cannot be determined |
Getta | |
---|---|
DeviceNotAvailableException |
getFastbootSerialNumber
public String getFastbootSerialNumber ()
Returns the fastboot mode serial number.
ritorna | |
---|---|
String |
getFastbootVariable
public String getFastbootVariable (String variableName)
Retrieve the given fastboot variable value from the device.
Parametri | |
---|---|
variableName | String : the variable name |
ritorna | |
---|---|
String | the property value or null if it does not exist |
Getta | |
---|---|
DeviceNotAvailableException |
getFastbootVersion
public String getFastbootVersion ()
Returns the version string of the fastboot binary being used. Or null if something goes wrong.
ritorna | |
---|---|
String |
getFileEntry
public IFileEntry getFileEntry (String path)
Retrieve a reference to a remote file on device.
Parametri | |
---|---|
path | String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie both "/system" and "system" syntax is supported) |
ritorna | |
---|---|
IFileEntry | the IFileEntry or null if file at given path cannot be found |
Getta | |
---|---|
DeviceNotAvailableException |
getFileEntry
public IFileEntry getFileEntry (FileListingService.FileEntry entry)
Unofficial helper to get a FileEntry
from a non-root path. FIXME: Refactor the FileEntry system to have it available from any path. (even non root).
Parametri | |
---|---|
entry | FileListingService.FileEntry : a FileEntry not necessarily root as Ddmlib requires. |
ritorna | |
---|---|
IFileEntry | a FileEntryWrapper representing the FileEntry. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getFoldableStates
publicgetFoldableStates ()
Returns the list of foldable states on the device. Can be obtained with "cmd device_state print-states".
ritorna | |
---|---|
Getta | |
---|---|
DeviceNotAvailableException |
getIDevice
public 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.ritorna | |
---|---|
IDevice | the IDevice |
getInstalledPackageNames
publicgetInstalledPackageNames ()
Fetch the application package names present on the device.
ritorna | |
---|---|
ERROR(/Set) of String package names currently installed on the device. |
Getta | |
---|---|
DeviceNotAvailableException |
getIntProperty
public long getIntProperty (String name, long defaultValue)
Returns integer value of the given property from the device.
Parametri | |
---|---|
name | String : the property name |
defaultValue | long : default value to return if property is empty or doesn't exist. |
ritorna | |
---|---|
long | the property value or defaultValue if the property is empty, doesn't exist, or doesn't have an integer value. |
Getta | |
---|---|
DeviceNotAvailableException |
getIpAddress
public String getIpAddress ()
Gets the device's IP address.
ritorna | |
---|---|
String | the device's IP address, or null if device has no IP address |
Getta | |
---|---|
DeviceNotAvailableException |
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Return an object to get the current state of the keyguard or null if not supported.
ritorna | |
---|---|
KeyguardControllerState | a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported. |
Getta | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public long getLastExpectedRebootTimeMillis ()
Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by System.currentTimeMillis()
.
ritorna | |
---|---|
long |
getLaunchApiLevel
public int getLaunchApiLevel ()
Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL
.
ritorna | |
---|---|
int | an integer indicating the first launched API Level of device |
Getta | |
---|---|
DeviceNotAvailableException |
getLogcat
public 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 captureritorna | |
---|---|
InputStreamSource |
getLogcat
public 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.
Parametri | |
---|---|
maxBytes | int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory |
ritorna | |
---|---|
InputStreamSource |
getLogcatDump
public 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.
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the logcat data. An empty stream is returned if fail to capture logcat data. |
getLogcatSince
public 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()
.
Parametri | |
---|---|
date | long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s') |
ritorna | |
---|---|
InputStreamSource |
getMacAddress
public String getMacAddress ()
Returns the MAC address of the device, null if it fails to query from the device.
ritorna | |
---|---|
String |
getMainUserId
public Integer getMainUserId ()
Returns the main user id.
ritorna | |
---|---|
Integer | the userId of the main user if there is one, and null if there is no main user. |
Getta | |
---|---|
DeviceNotAvailableException |
getMainlineModuleInfo
publicgetMainlineModuleInfo ()
Get the information about the mainline modules installed on the device.
ritorna | |
---|---|
ERROR(/Set) of String mainline modules currently installed on the device. |
Getta | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfRunningUsersSupported
public int getMaxNumberOfRunningUsersSupported ()
Get the maximum number of supported simultaneously running users. Defaults to 0.
ritorna | |
---|---|
int | an integer indicating the number of simultaneously running users |
Getta | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
Get the maximum number of supported users. Defaults to 0.
ritorna | |
---|---|
int | an integer indicating the number of supported users |
Getta | |
---|---|
DeviceNotAvailableException |
getMicrodroidProcess
public Process getMicrodroidProcess ()
ritorna | |
---|---|
Process | Returns the Process of the Microdroid VM. If TestDevice is not a Microdroid, returns null. |
getMonitor
public IDeviceStateMonitor getMonitor ()
Return the IDeviceStateMonitor
associated with device.
ritorna | |
---|---|
IDeviceStateMonitor |
getMountPoint
public 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)
Parametri | |
---|---|
mountName | String : the name of the mount point |
ritorna | |
---|---|
String | the mount point or null |
getMountPointInfo
public 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.
Parametri | |
---|---|
mountpoint | String |
ritorna | |
---|---|
ITestDevice.MountPointInfo | A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Getta | |
---|---|
DeviceNotAvailableException |
getMountPointInfo
publicgetMountPointInfo ()
Returns a parsed version of the information in /proc/mounts on the device
ritorna | |
---|---|
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Getta | |
---|---|
DeviceNotAvailableException |
getOptions
public TestDeviceOptions getOptions ()
Fetch the test options for the device.
ritorna | |
---|---|
TestDeviceOptions | TestDeviceOptions related to the device under test. |
getPartitionFreeSpace
public long getPartitionFreeSpace (String partition)
Helper method to determine amount of free space on device partition.
Parametri | |
---|---|
partition | String |
ritorna | |
---|---|
long | the amount of free space in KB |
Getta | |
---|---|
DeviceNotAvailableException |
getPrimaryUserId
public Integer getPrimaryUserId ()
Returns the primary user id.
ritorna | |
---|---|
Integer | the userId of the primary user if there is one, and null if there is no primary user. |
Getta | |
---|---|
DeviceNotAvailableException |
getProcessByName
public 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.
Parametri | |
---|---|
processName | String : the proces name String. |
ritorna | |
---|---|
ProcessInfo | ProcessInfo of given processName |
Getta | |
---|---|
DeviceNotAvailableException |
getProcessPid
public String getProcessPid (String process)
Returns the pid of the service or null if something went wrong.
Parametri | |
---|---|
process | String : The proces name String. |
ritorna | |
---|---|
String |
Getta | |
---|---|
DeviceNotAvailableException |
getProductType
public 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.ritorna | |
---|---|
String | the String product type name. Will not be null |
Getta | |
---|---|
DeviceNotAvailableException |
getProductVariant
public 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.ritorna | |
---|---|
String | the String product variant name or null if it cannot be determined |
Getta | |
---|---|
DeviceNotAvailableException |
getProperty
public String getProperty (String name)
Retrieve the given property value from the device.
Parametri | |
---|---|
name | String : the property name |
ritorna | |
---|---|
String | the property value or null if it does not exist |
Getta | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public ITestDevice.RecoveryMode getRecoveryMode ()
Get the current recovery mode used for the device.
ritorna | |
---|---|
ITestDevice.RecoveryMode | the current recovery mode used for the device. |
getScreenshot
public InputStreamSource getScreenshot (String format)
Grabs a screenshot from the device. Recommended to use getScreenshot(format) instead with JPEG encoding for smaller size
Parametri | |
---|---|
format | String : supported PNG, JPEG |
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
Getta | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot (long displayId)
Grabs a screenshot from the device given display id. Format is PNG.
TODO: extend the implementations above to support 'format' and 'rescale'
Parametri | |
---|---|
displayId | long : the display id of the screen to get screenshot from. |
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
Getta | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot (String format, boolean rescale)
Grabs a screenshot from the device. Recommended to use getScreenshot(String)
instead with JPEG encoding for smaller size.
Parametri | |
---|---|
format | String : supported PNG, JPEG |
rescale | boolean : if screenshot should be rescaled to reduce the size of resulting image |
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
Getta | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot ()
Grabs a screenshot from the device.
ritorna | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in png format, or null if the screenshot was not successful. |
Getta | |
---|---|
DeviceNotAvailableException |
getSerialNumber
public String getSerialNumber ()
Convenience method to get serial number of this device.
ritorna | |
---|---|
String | the String serial number |
getSetting
public String getSetting (int userId, String namespace, String key)
Return the value of the requested setting. namespace must be one of: {"system", "secure", "global"}
Parametri | |
---|---|
userId | int |
namespace | String |
key | String |
ritorna | |
---|---|
String | the value associated with the namespace:key of a user. Null if not found. |
Getta | |
---|---|
DeviceNotAvailableException |
getSetting
public String getSetting (String namespace, String key)
See getSetting(int, String, String)
and performed on system user.
Parametri | |
---|---|
namespace | String |
key | String |
ritorna | |
---|---|
String |
Getta | |
---|---|
DeviceNotAvailableException |
getSimOperator
public String getSimOperator ()
Return the SIM card operator or null if not available or if device is not available.
ritorna | |
---|---|
String |
getSimState
public String getSimState ()
Return the SIM card state or null if not available or device is not available.
ritorna | |
---|---|
String |
getTombstones
publicgetTombstones ()
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.
ritorna | |
---|---|
A list of tombstone files, empty if no tombstone. |
Getta | |
---|---|
DeviceNotAvailableException |
getTotalMemory
public long getTotalMemory ()
Returns total physical memory size in bytes or -1 in case of internal error
ritorna | |
---|---|
long |
getUninstallablePackageNames
publicgetUninstallablePackageNames ()
Fetch the application package names that can be uninstalled. This is presently defined as non-system packages, and updated system packages.
ritorna | |
---|---|
ERROR(/Set) of uninstallable String package names currently installed on the device. |
Getta | |
---|---|
DeviceNotAvailableException |
getUseFastbootErase
public boolean getUseFastbootErase ()
Get whether to use fastboot erase or fastboot format to wipe a partition on the device.
ritorna | |
---|---|
boolean | true if fastboot erase will be used or false if fastboot format will be used. |
getUserFlags
public int getUserFlags (int userId)
Find and return the flags of a given user. Flags are defined in "android.content.pm.UserInfo" class in Android Open Source Project.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
int | the flags associated with the userId provided if found, -10000 in any other cases. |
Getta | |
---|---|
DeviceNotAvailableException |
getUserInfos
publicgetUserInfos ()
Gets the Map of useId to UserInfo
on the device. Will throw DeviceRuntimeException
if output from device is not as expected.
ritorna | |
---|---|
the list of UserInfo objects. |
Getta | |
---|---|
DeviceNotAvailableException |
getUserSerialNumber
public int getUserSerialNumber (int userId)
Return the serial number associated to the userId if found, -10000 in any other cases.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
int |
Getta | |
---|---|
DeviceNotAvailableException |
handleAllocationEvent
public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)
Process the given DeviceEvent. May transition device to new state. Will inform the IDeviceMonitor
of any state transitions.
Process the DeviceEvent, which may or may not transition this device to a new allocation state.
Parametri | |
---|---|
event | DeviceEvent |
ritorna | |
---|---|
IManagedTestDevice.DeviceEventResponse |
hasFeature
public boolean hasFeature (String feature)
Check if a feature is available on a device.
Parametri | |
---|---|
feature | String : which format should be "feature: |
ritorna | |
---|---|
boolean | True if feature is found, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
installPackage
public String installPackage (File packageFile, boolean reinstall, String... extraArgs)
Install an Android package on device.
Parametri | |
---|---|
packageFile | File : the apk file to install |
reinstall | boolean : true if a reinstall should be performed |
extraArgs | String : optional extra arguments to pass. See 'adb shell pm -h' for available options. |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
installPackage
public String installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)
Install an Android package on device.
Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.
Parametri | |
---|---|
packageFile | File : the apk file to install |
reinstall | boolean : true if a reinstall should be performed |
grantPermissions | boolean : if all runtime permissions should be granted at install time |
extraArgs | String : optional extra arguments to pass. See 'adb shell pm -h' for available options. |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
installPackageForUser
public String installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs)
Install an Android package on device for a given user.
Parametri | |
---|---|
packageFile | File : the apk file to install |
reinstall | boolean : true if a reinstall should be performed |
userId | int : the integer user id to install for. |
extraArgs | String : optional extra arguments to pass. See 'adb shell pm -h' for available options. |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
installPackageForUser
public String installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)
Install an Android package on device for a given user.
Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.
Parametri | |
---|---|
packageFile | File : the apk file to install |
reinstall | boolean : true if a reinstall should be performed |
grantPermissions | boolean : if all runtime permissions should be granted at install time |
userId | int : the integer user id to install for. |
extraArgs | String : optional extra arguments to pass. See 'adb shell pm -h' for available options. |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
invalidatePropertyCache
public void invalidatePropertyCache ()
isAdbTcp
public boolean isAdbTcp ()
ritorna | |
---|---|
boolean |
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Check whether platform on device supports app enumeration
ritorna | |
---|---|
boolean | True if app enumeration is supported, false otherwise |
Getta | |
---|---|
DeviceNotAvailableException |
isBypassLowTargetSdkBlockSupported
public boolean isBypassLowTargetSdkBlockSupported ()
Check whether platform on device supports bypassing low target sdk block on app installs
ritorna | |
---|---|
boolean | True if bypass low target sdk block is supported, false otherwise |
Getta | |
---|---|
DeviceNotAvailableException |
isDeviceEncrypted
public boolean isDeviceEncrypted ()
Returns if the device is encrypted.
ritorna | |
---|---|
boolean | true if the device is encrypted. |
Getta | |
---|---|
DeviceNotAvailableException |
isDirectory
public boolean isDirectory (String path)
Return True if the path on the device is a directory, false otherwise.
Parametri | |
---|---|
path | String |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isEnableAdbRoot
public boolean isEnableAdbRoot ()
ritorna | |
---|---|
boolean | true if adb root should be enabled on device |
isEncryptionSupported
public boolean isEncryptionSupported ()
Returns if encryption is supported on the device.
ritorna | |
---|---|
boolean | true if the device supports encryption. |
Getta | |
---|---|
DeviceNotAvailableException |
isExecutable
public boolean isExecutable (String fullPath)
Returns True if the file path on the device is an executable file, false otherwise.
Parametri | |
---|---|
fullPath | String |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isFastbootEnabled
public boolean isFastbootEnabled ()
Return if fastboot is available for the device.
ritorna | |
---|---|
boolean |
isHeadless
public boolean isHeadless ()
Return true if the device is headless (no screen), false otherwise.
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isHeadlessSystemUserMode
public boolean isHeadlessSystemUserMode ()
Returns whether the device uses headless system user mode.
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isMainUserPermanentAdmin
public boolean isMainUserPermanentAdmin ()
Returns whether the main user is a permanent admin and can't be deleted or downgraded to non-admin status.
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isMultiUserSupported
public boolean isMultiUserSupported ()
Determines if multi user is supported.
ritorna | |
---|---|
boolean | true if multi user is supported, false otherwise |
Getta | |
---|---|
DeviceNotAvailableException |
isPackageInstalled
public boolean isPackageInstalled (String packageName, String userId)
Query the device for a given package name and given user id to check if it's currently installed or not for that user.
Parametri | |
---|---|
packageName | String : the package we are checking if it's installed. |
userId | String : The user id we are checking the package is installed for. If null, primary user zero will be used. |
ritorna | |
---|---|
boolean | True if the package is reported as installed. False otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Query the device for a given package name to check if it's currently installed or not.
Parametri | |
---|---|
packageName | String |
ritorna | |
---|---|
boolean | True if the package is reported as installed. False otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public boolean isRuntimePermissionSupported ()
Check whether platform on device supports runtime permission granting
ritorna | |
---|---|
boolean | True if runtime permission are supported, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
isStateBootloaderOrFastbootd
public boolean isStateBootloaderOrFastbootd ()
Returns true if device is in TestDeviceState#FASTBOOT
or TestDeviceState.FASTBOOTD
.
ritorna | |
---|---|
boolean |
isUserRunning
public boolean isUserRunning (int userId)
Check if a given user is running.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
boolean | True if the user is running, false in every other cases. |
Getta | |
---|---|
DeviceNotAvailableException |
isUserSecondary
public boolean isUserSecondary (int userId)
Return whether the specified user is a secondary user according to it's flags.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
boolean | true if the user is secondary, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
isUserVisible
public boolean isUserVisible (int userId)
Checks if the given user is visible.
A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities (typically in the default display).
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isUserVisibleOnDisplay
public boolean isUserVisibleOnDisplay (int userId, int displayId)
Checks if the given user is visible in the given display.
A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities in that display.
Parametri | |
---|---|
userId | int |
displayId | int |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isVisibleBackgroundUsersOnDefaultDisplaySupported
public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()
Returns whether the device allow users to be started visible in the background in the ERROR(/java.android.view.Display#DEFAULT_DISPLAY)
.
If it does, you could call startVisibleBackgroundUser(int, int, boolean)
, passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers()
(which should include ERROR(/java.android.view.Display#DEFAULT_DISPLAY)
).
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isVisibleBackgroundUsersSupported
public boolean isVisibleBackgroundUsersSupported ()
Returns whether the device allow users to be started visible in the background.
If it does, you could call startVisibleBackgroundUser(int, int, boolean)
, passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers()
.
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
isWifiEnabled
public boolean isWifiEnabled ()
Test if wifi is enabled.
Checks if wifi is enabled on device. Useful for asserting wifi status before tests that shouldn't run with wifi, eg mobile data tests.ritorna | |
---|---|
boolean | true if wifi is enabled. false if disabled |
Getta | |
---|---|
DeviceNotAvailableException |
listDisplayIds
publiclistDisplayIds ()
Collect the list of available displays id on the device as reported by "dumpsys SurfaceFlinger".
ritorna | |
---|---|
The list of displays. Default always returns the default display 0. |
Getta | |
---|---|
DeviceNotAvailableException |
listDisplayIdsForStartingVisibleBackgroundUsers
publiclistDisplayIdsForStartingVisibleBackgroundUsers ()
Gets the list of displays that can be used to start a user visible in the background
.
ritorna | |
---|---|
Getta | |
---|---|
DeviceNotAvailableException |
listUsers
publiclistUsers ()
Gets the list of users on the device. Will throw DeviceRuntimeException
if output from device is not as expected.
ritorna | |
---|---|
the list of user ids. |
Getta | |
---|---|
DeviceNotAvailableException |
logAnrs
public boolean logAnrs (ITestLogger logger)
Collects and log ANRs from the device.
Parametri | |
---|---|
logger | ITestLogger : an ITestLogger to log the ANRs. |
ritorna | |
---|---|
boolean | True if the logging was successful, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
logBugreport
public boolean logBugreport (String dataName, ITestLogger listener)
Helper method to take a bugreport and log it to the reporters.
Parametri | |
---|---|
dataName | String : name under which the bugreport will be reported. |
listener | ITestLogger : an ITestLogger to log the bugreport. |
ritorna | |
---|---|
boolean | True if the logging was successful, false otherwise. |
logOnDevice
public 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.
Parametri | |
---|---|
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 void nonBlockingReboot ()
Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.
Getta | |
---|---|
DeviceNotAvailableException |
postAdbRootAction
public void postAdbRootAction ()
Override if the device needs some specific actions to be taken after adb root and before the device is back online. Default implementation doesn't include any addition actions. adb root is not guaranteed to be enabled at this stage.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
postAdbUnrootAction
public void postAdbUnrootAction ()
Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. Default implementation doesn't include any additional actions. adb root is not guaranteed to be disabled at this stage.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
postBootSetup
public 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)Getta | |
---|---|
DeviceNotAvailableException |
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Extra steps for device specific required clean up that will be executed after the invocation is done.
Parametri | |
---|---|
exception | 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.
Parametri | |
---|---|
info | IBuildInfo : The IBuildInfo of the device. |
attributes | MultiMap : The attributes stored in the invocation context |
Getta | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
pullDir
public boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
Parametri | |
---|---|
deviceFilePath | String : the absolute file path of the remote source |
localDir | File : the local directory to pull files into |
ritorna | |
---|---|
boolean | true if file was pulled successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pullFile
public boolean pullFile (String remoteFilePath, File localFile)
Retrieves a file off device.
Parametri | |
---|---|
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. |
ritorna | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pullFile
public File pullFile (String remoteFilePath, int userId)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
Parametri | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
userId | int : The user id to pull from |
ritorna | |
---|---|
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) |
Getta | |
---|---|
DeviceNotAvailableException |
pullFile
public File pullFile (String remoteFilePath)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
Parametri | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
ritorna | |
---|---|
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) |
Getta | |
---|---|
DeviceNotAvailableException |
pullFile
public boolean pullFile (String remoteFilePath, File localFile, int userId)
Retrieves a file off device.
Parametri | |
---|---|
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 |
ritorna | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pullFileContents
public String pullFileContents (String remoteFilePath)
Retrieves a file off device, and returns the contents.
Parametri | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
ritorna | |
---|---|
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) |
Getta | |
---|---|
DeviceNotAvailableException |
pullFileFromExternal
public 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
.
Parametri | |
---|---|
remoteFilePath | String : the path to file on device, relative to the device's external storage mountpoint |
ritorna | |
---|---|
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) |
Getta | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath,excludedDirectories)
Recursively push directory contents to device while excluding some directories that are filtered.
Parametri | |
---|---|
localFileDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
excludedDirectories |
ritorna | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath)
Recursively push directory contents to device.
Parametri | |
---|---|
localFileDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
ritorna | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pushFile
public boolean pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded)
Variant of pushFile(File, String)
which can optionally consider evaluating the need for the content provider.
Parametri | |
---|---|
localFile | File : the local file to push |
remoteFilePath | String : the remote destination absolute file path |
evaluateContentProviderNeeded | boolean : whether to check if we need the content provider |
ritorna | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pushFile
public boolean pushFile (File localFile, String remoteFilePath)
Push a file to device. By default using a content provider.
Parametri | |
---|---|
localFile | File : the local file to push |
remoteFilePath | String : the remote destination absolute file path |
ritorna | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
pushString
public boolean pushString (String contents, String remoteFilePath)
Push file created from a string to device
Parametri | |
---|---|
contents | String : the contents of the file to push |
remoteFilePath | String : the remote destination absolute file path |
ritorna | |
---|---|
boolean | true if string was pushed successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
reboot
public 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.
Parametri | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
Getta | |
---|---|
DeviceNotAvailableException |
reboot
public void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.Getta | |
---|---|
DeviceNotAvailableException |
rebootIntoBootloader
public void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.Getta | |
---|---|
DeviceNotAvailableException |
rebootIntoFastbootd
public void rebootIntoFastbootd ()
Reboots the device into fastbootd mode.
Blocks until device is in fastbootd mode.
Getta | |
---|---|
DeviceNotAvailableException |
rebootIntoRecovery
public void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryGetta | |
---|---|
DeviceNotAvailableException |
rebootIntoSideload
public void rebootIntoSideload ()
Reboots the device into adb sideload mode (note that this is a special mode under recovery)
Blocks until device enters sideload mode
Getta | |
---|---|
DeviceNotAvailableException |
rebootIntoSideload
public 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
Parametri | |
---|---|
autoReboot | boolean : whether to automatically reboot the device after sideload |
Getta | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Getta | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline (String reason)
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Parametri | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
Getta | |
---|---|
DeviceNotAvailableException |
rebootUserspace
public 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.
Getta | |
---|---|
DeviceNotAvailableException |
rebootUserspaceUntilOnline
public void rebootUserspaceUntilOnline ()
An alternate to rebootUserspace()
()} that only blocks until device is online ie visible to adb.
Getta | |
---|---|
DeviceNotAvailableException |
recoverDevice
public boolean recoverDevice ()
Attempts to recover device communication.
ritorna | |
---|---|
boolean | True if recovery attempted and successful, returns False if recovery was skipped |
Getta | |
---|---|
DeviceNotAvailableException | if device is no longer available |
registerDeviceActionReceiver
public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)
Registers a IDeviceActionReceiver
for this device.
All registered IDeviceActionReceiver
s will be notified before a device action starts and after the device action ends.
Parametri | |
---|---|
deviceActionReceiver | IDeviceActionReceiver : A IDeviceActionReceiver which will be registered. |
remountSystemReadOnly
public void remountSystemReadOnly ()
Make the system partition on the device read-only. May reboot the device.
Getta | |
---|---|
DeviceNotAvailableException |
remountSystemWritable
public void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
Getta | |
---|---|
DeviceNotAvailableException |
remountVendorReadOnly
public void remountVendorReadOnly ()
Make the vendor partition on the device read-only. May reboot the device.
Getta | |
---|---|
DeviceNotAvailableException |
remountVendorWritable
public void remountVendorWritable ()
Make the vendor partition on the device writable. May reboot the device.
Getta | |
---|---|
DeviceNotAvailableException |
removeAdmin
public boolean removeAdmin (String componentName, int userId)
Remove given device admin in given user and return true
if it is successful, false
otherwise.
Parametri | |
---|---|
componentName | String : of device admin to be removed. |
userId | int : of user that the device admin lives in. |
ritorna | |
---|---|
boolean | True if it is successful, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
removeOwners
public void removeOwners ()
Remove all existing device profile owners with the best effort.
Getta | |
---|---|
DeviceNotAvailableException |
removeUser
public boolean removeUser (int userId)
Remove a given user from the device.
Parametri | |
---|---|
userId | int : of the user to remove |
ritorna | |
---|---|
boolean | true if we were successful in removing the user, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
resetContentProviderSetup
public void resetContentProviderSetup ()
Reset the flag for content provider setup in order to trigger it again.
runInstrumentationTests
public 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.
Parametri | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners | ITestLifeCycleReceiver : the test result listener(s) |
ritorna | |
---|---|
boolean | true if test command completed. false if it failed to complete, but recovery succeeded |
Getta | |
---|---|
DeviceNotAvailableException |
runInstrumentationTests
public 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.
Parametri | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
ritorna | |
---|---|
boolean | true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded |
Getta | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public 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.
Parametri | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...)
but runs the test for a given user.
Parametri | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners | ITestLifeCycleReceiver |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
setConfiguration
public void setConfiguration (IConfiguration configuration)
Injects the IConfiguration
in use.
Parametri | |
---|---|
configuration | IConfiguration |
setConnectionAvdInfo
public final void setConnectionAvdInfo (GceAvdInfo avdInfo)
Parametri | |
---|---|
avdInfo | GceAvdInfo |
setDate
public void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
Parametri | |
---|---|
date | Date : specify a particular date; will use host date if null |
Getta | |
---|---|
DeviceNotAvailableException |
setDeviceOwner
public boolean setDeviceOwner (String componentName, int userId)
Set a device admin component as device owner in given user.
Parametri | |
---|---|
componentName | String : of device admin to be device owner. |
userId | int : of the user that the device owner lives in. |
ritorna | |
---|---|
boolean | True if it is successful, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
setDeviceState
public void setDeviceState (TestDeviceState deviceState)
Update the device's state.
Parametri | |
---|---|
deviceState | TestDeviceState : the TestDeviceState |
setEmulatorOutputStream
public void setEmulatorOutputStream (SizeLimitedOutputStream output)
For emulator set SizeLimitedOutputStream
to log output
Parametri | |
---|---|
output | SizeLimitedOutputStream : to log the output |
setEmulatorProcess
public void setEmulatorProcess (Process p)
Sets the Process
, when this device is an emulator.
Parametri | |
---|---|
p | Process |
setFastbootEnabled
public void setFastbootEnabled (boolean fastbootEnabled)
Set the fastboot option for the device. Should be set when device is first allocated.
Parametri | |
---|---|
fastbootEnabled | boolean : whether fastboot is available for the device or not |
setFastbootPath
public void setFastbootPath (String fastbootPath)
Sets the path to the fastboot binary that should be used. Still requires isFastbootEnabled()
to be true, to have fastboot functions enabled.
Parametri | |
---|---|
fastbootPath | String |
setIDevice
public void setIDevice (IDevice newDevice)
Update the IDevice associated with this ITestDevice.
The new IDevice must refer the same physical device as the current reference. This method will be called if DDMS has allocated a new IDeviceParametri | |
---|---|
newDevice | IDevice : the IDevice |
setLogStartDelay
public void setLogStartDelay (int delay)
Sets the time in ms to wait before starting logcat capture for a online device.
Parametri | |
---|---|
delay | int : the delay in ms |
setOptions
public void setOptions (TestDeviceOptions options)
Set the TestDeviceOptions
for the device
Parametri | |
---|---|
options | TestDeviceOptions |
setProperty
public boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
Parametri | |
---|---|
propKey | String : The key targeted to be set. |
propValue | String : The property value to be set. |
ritorna | |
---|---|
boolean | returns True if the setprop command was successful, False otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
setRecovery
public void setRecovery (IDeviceRecovery recovery)
Set the IDeviceRecovery
to use for this device. Should be set when device is first allocated.
Parametri | |
---|---|
recovery | IDeviceRecovery : the IDeviceRecovery |
setRecoveryMode
public 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, etcParametri | |
---|---|
mode | ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not. |
setSetting
public void setSetting (String namespace, String key, String value)
See setSetting(int, String, String, String)
and performed on system user.
Parametri | |
---|---|
namespace | String |
key | String |
value | String |
Getta | |
---|---|
DeviceNotAvailableException |
setSetting
public void setSetting (int userId, String namespace, String key, String value)
Add a setting value to the namespace of a given user. Some settings will only be available after a reboot. namespace must be one of: {"system", "secure", "global"}
Parametri | |
---|---|
userId | int |
namespace | String |
key | String |
value | String |
Getta | |
---|---|
DeviceNotAvailableException |
setTestLogger
public void setTestLogger (ITestLogger testLogger)
Injects the ITestLogger
instance
Parametri | |
---|---|
testLogger | ITestLogger |
setUseFastbootErase
public void setUseFastbootErase (boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device.
Parametri | |
---|---|
useFastbootErase | boolean : true if fastboot erase should be used or false if fastboot format should be used. |
startLogcat
public 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.startUser
public boolean startUser (int userId)
Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP.
Parametri | |
---|---|
userId | int : of the user to start in the background |
ritorna | |
---|---|
boolean | true if the user was successfully started in the background. |
Getta | |
---|---|
DeviceNotAvailableException |
startUser
public boolean startUser (int userId, boolean waitFlag)
Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP. Possible to provide extra flag to wait for the operation to have effect.
Parametri | |
---|---|
userId | int : of the user to start in the background |
waitFlag | boolean : will make the command wait until user is started and unlocked. |
ritorna | |
---|---|
boolean | true if the user was successfully started in the background. |
Getta | |
---|---|
DeviceNotAvailableException |
startVisibleBackgroundUser
public boolean startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag)
Starts a given user in the background, visible in the given display (ie, allowing the user to launch activities in that display).
NOTE: this command doesn't check if the user exists, display is available, device supports such feature
, etc.
Parametri | |
---|---|
userId | int : of the user to start in the background |
displayId | int : display to start user visible on |
waitFlag | boolean : will make the command wait until user is started and unlocked. |
ritorna | |
---|---|
boolean | true if the user was successfully started visible in the background. |
Getta | |
---|---|
DeviceNotAvailableException |
stopEmulatorOutput
public void stopEmulatorOutput ()
Close and delete the emulator output.
stopLogcat
public 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.stopUser
public boolean stopUser (int userId)
Stops a given user. If the user is already stopped, this method is a NOOP. Cannot stop current and system user.
Parametri | |
---|---|
userId | int : of the user to stop. |
ritorna | |
---|---|
boolean | true if the user was successfully stopped. |
Getta | |
---|---|
DeviceNotAvailableException |
stopUser
public boolean stopUser (int userId, boolean waitFlag, boolean forceFlag)
Stop a given user. Possible to provide extra flags to wait for the operation to have effect, and force terminate the user. Cannot stop current and system user.
Parametri | |
---|---|
userId | int : of the user to stop. |
waitFlag | boolean : will make the command wait until user is stopped. |
forceFlag | boolean : will force stop the user. |
ritorna | |
---|---|
boolean | true if the user was successfully stopped. |
Getta | |
---|---|
DeviceNotAvailableException |
switchToAdbTcp
public String switchToAdbTcp ()
Switch device to adb-over-tcp mode.
ritorna | |
---|---|
String | the tcp serial number or null if device could not be switched |
Getta | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public boolean switchToAdbUsb ()
Switch device to adb over usb mode.
ritorna | |
---|---|
boolean | true if switch was successful, false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
switchUser
public boolean switchUser (int userId)
Switch to another userId with a default timeout. switchUser(int, long)
.
Parametri | |
---|---|
userId | int |
ritorna | |
---|---|
boolean | True if the new userId matches the userId provider. False otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
switchUser
public boolean switchUser (int userId, long timeout)
Switch to another userId with the provided timeout as deadline. Attempt to disable keyguard after user change is successful.
Parametri | |
---|---|
userId | int |
timeout | long : to wait before returning false for switch-user failed. |
ritorna | |
---|---|
boolean | True if the new userId matches the userId provider. False otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
syncFiles
public 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.Parametri | |
---|---|
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 |
ritorna | |
---|---|
boolean | true if files were synced successfully. false otherwise. |
Getta | |
---|---|
DeviceNotAvailableException |
takeBugreport
public Bugreport takeBugreport ()
Take a bugreport and returns it inside a Bugreport
object to handle it. Return null in case of issue. File referenced in the Bugreport object need to be cleaned via Bugreport.close()
.
ritorna | |
---|---|
Bugreport |
uninstallPackage
public String uninstallPackage (String packageName)
Uninstall an Android package from device.
Parametri | |
---|---|
packageName | String : the Android package to uninstall |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
uninstallPackageForUser
public String uninstallPackageForUser (String packageName, int userId)
Uninstall an Android package from device for a given user.
Parametri | |
---|---|
packageName | String : the Android package to uninstall |
userId | int : the integer user id to uninstall for. |
ritorna | |
---|---|
String | a String with an error code, or null if success. |
Getta | |
---|---|
DeviceNotAvailableException |
unlockDevice
public 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.ritorna | |
---|---|
boolean | true if successful or if the device is unencrypted. |
Getta | |
---|---|
DeviceNotAvailableException |
waitForBootComplete
public boolean waitForBootComplete (long timeOut)
Blocks until the device's boot complete flag is set.
Parametri | |
---|---|
timeOut | long : time in msecs to wait for the flag to be set |
ritorna | |
---|---|
boolean | true if device's boot complete flag is set within the timeout |
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public boolean waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
ritorna | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public boolean waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
Parametri | |
---|---|
waitTime | long : the time in ms to wait |
ritorna | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailableInRecoverPath
public boolean waitForDeviceAvailableInRecoverPath (long waitTime)
Waits for the device to be responsive and available without considering recovery path.
Parametri | |
---|---|
waitTime | long |
ritorna | |
---|---|
boolean | True if device is available, False if unavailable. |
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceBootloader
public void waitForDeviceBootloader ()
Blocks until device is visible via fastboot. Use default timeout.
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceInRecovery
public boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery
).
Parametri | |
---|---|
waitTime | long : the time in ms to wait |
ritorna | |
---|---|
boolean | true if device boots into recovery before time expires. false otherwise |
waitForDeviceInSideload
public boolean waitForDeviceInSideload (long waitTime)
Blocks for the device to be in the 'adb sideload' state
Parametri | |
---|---|
waitTime | long : the time in ms to wait |
ritorna | |
---|---|
boolean | true if device boots into sideload before time expires. false otherwise |
waitForDeviceNotAvailable
public boolean waitForDeviceNotAvailable (long waitTime)
Blocks for the device to be not available ie missing from adb
Parametri | |
---|---|
waitTime | long : the time in ms to wait |
ritorna | |
---|---|
boolean | true if device becomes not available before time expires. false otherwise |
waitForDeviceOnline
public 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.Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceOnline
public 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.Parametri | |
---|---|
waitTime | long : the time in ms to wait |
Getta | |
---|---|
DeviceNotAvailableException |
waitForDeviceShell
public boolean waitForDeviceShell (long waitTime)
Waits for device to be responsive to a basic adb shell command.
Parametri | |
---|---|
waitTime | long : the time in ms to wait |
ritorna | |
---|---|
boolean | true if device becomes responsive before waitTime elapses. |
Protected methods
addExtraConnectionBuilderArgs
protected void addExtraConnectionBuilderArgs (DefaultConnection.ConnectionBuilder builder)
Parametri | |
---|---|
builder | DefaultConnection.ConnectionBuilder |
buildAdbShellCommand
protected String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)
Builds the OS command for the given adb shell command session and args
Parametri | |
---|---|
command | String |
forceExitStatusDetection | boolean |
ritorna | |
---|---|
String[] |
checkApiLevelAgainst
protected void checkApiLevelAgainst (String feature, int strictMinLevel)
Parametri | |
---|---|
feature | String |
strictMinLevel | int |
createRebootDeviceAction
protected NativeDevice.RebootDeviceAction createRebootDeviceAction (NativeDevice.RebootMode rebootMode, String reason)
Create a RebootDeviceAction
to be used when performing a reboot action.
Parametri | |
---|---|
rebootMode | NativeDevice.RebootMode : a mode of this reboot. |
reason | String : for this reboot. |
ritorna | |
---|---|
NativeDevice.RebootDeviceAction | the created RebootDeviceAction . |
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode, String reason)
Perform a adb reboot.
Parametri | |
---|---|
rebootMode | NativeDevice.RebootMode : a mode of this reboot. |
reason | String : for this reboot. |
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
ensureRuntimePermissionSupported
protected void ensureRuntimePermissionSupported ()
helper method to throw exception if runtime permission isn't supported
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getApiLevelSafe
protected int getApiLevelSafe ()
ritorna | |
---|---|
int |
initializeConnection
protected void initializeConnection (IBuildInfo info, MultiMap<String, String> attributes)
Parametri | |
---|---|
info | IBuildInfo |
attributes | MultiMap |
Getta | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
internalGetProperty
protected String internalGetProperty (String propName, String fastbootVar, String description)
Fetch a device property, from the ddmlib cache by default, and falling back to either `adb shell getprop` or `fastboot getvar` depending on whether the device is in Fastboot or not.
Parametri | |
---|---|
propName | String : The name of the device property as returned by `adb shell getprop` |
fastbootVar | String : The name of the equivalent fastboot variable to query. if null , fastboot query will not be attempted |
description | String : A simple description of the variable. First letter should be capitalized. |
ritorna | |
---|---|
String | A string, possibly null or empty, containing the value of the given property |
Getta | |
---|---|
DeviceNotAvailableException |
isInRebootCallback
protected boolean isInRebootCallback ()
Returns whether reboot callbacks is currently being executed or not. All public api's for reboot should be disabled if true.
ritorna | |
---|---|
boolean |
isNewer
protected boolean isNewer (File localFile, IFileEntry entry)
Return true
if local file is newer than remote file. IFileEntry
being accurate to the minute, in case of equal times, the file will be considered newer.
Parametri | |
---|---|
localFile | File |
entry | IFileEntry |
ritorna | |
---|---|
boolean |
notifyRebootEnded
protected void notifyRebootEnded ()
Notifies all IDeviceActionReceiver
about reboot end event.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
notifyRebootStarted
protected void notifyRebootStarted ()
Notifies all IDeviceActionReceiver
about reboot start event.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
performDeviceAction
protected boolean performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts)
Performs an action on this device. Attempts to recover device and optionally retry command if action fails.
Parametri | |
---|---|
actionDescription | String : a short description of action to be performed. Used for logging purposes only. |
action | NativeDevice.DeviceAction : the action to be performed |
retryAttempts | int : the retry attempts to make for action if it fails but recovery succeeds |
ritorna | |
---|---|
boolean | true if action was performed successfully |
Getta | |
---|---|
DeviceNotAvailableException | if recovery attempt fails or max attempts done without success |
postAdbReboot
protected void postAdbReboot ()
Possible extra actions that can be taken after a reboot.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
prePostBootSetup
protected void prePostBootSetup ()
Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.
Getta | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
pullFileInternal
protected boolean pullFileInternal (String remoteFilePath, File localFile)
Parametri | |
---|---|
remoteFilePath | String |
localFile | File |
ritorna | |
---|---|
boolean |
Getta | |
---|---|
DeviceNotAvailableException |
setClock
protected void setClock (Clock clock)
Set the Clock instance to use.
Parametri | |
---|---|
clock | Clock |
setMicrodroidProcess
protected void setMicrodroidProcess (Process process)
Marks the TestDevice as microdroid and sets its CID.
Parametri | |
---|---|
process | Process : Process of the Microdroid VM. |
setTestDeviceOptions
protected void setTestDeviceOptions (deviceOptions)
Parametri | |
---|---|
deviceOptions |
simpleFastbootCommand
protected CommandResult simpleFastbootCommand (long timeout,envVarMap, String[] fullCmd)
Executes a simple fastboot command with environment variables and report the status of the command.
Parametri | |
---|---|
timeout | long |
envVarMap | |
fullCmd | String |
ritorna | |
---|---|
CommandResult |
simpleFastbootCommand
protected CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)
Executes a simple fastboot command and report the status of the command.
Parametri | |
---|---|
timeout | long |
fullCmd | String |
ritorna | |
---|---|
CommandResult |
waitForDeviceNotAvailable
protected boolean waitForDeviceNotAvailable (String operationDesc, long time)
Wait to see the device going unavailable (stop reporting to adb).
Parametri | |
---|---|
operationDesc | String : The name of the operation that is waiting for unavailable. |
time | long : The time to wait for unavailable to occur. |
ritorna | |
---|---|
boolean | True if device did become unavailable. |
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2023-07-19 UTC.