Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.

NativeDevice

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver

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


Standardimplementierung eines ITestDevice Non-Full-Stack-Android-Geräte.

Zusammenfassung

Verschachtelte Klassen

class NativeDevice.AdbAction

Eine DeviceAction zum Ausführen eines OS-'adb ....'-Befehls.

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

DeviceAction zum Neustarten eines Geräts.

enum NativeDevice.RebootMode

Ein Modus eines Neustarts.

Konstanten

int INVALID_USER_ID

Wert, der für jede ungültige/nicht gefundene Benutzer-ID zurückgegeben wird: UserHandle hat den Wert -10000 definiert

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

die Standardanzahl der auszuführenden Befehlswiederholungsversuche

Felder

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

Öffentliche Konstrukteure

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

Erstellt ein TestDevice .

Öffentliche Methoden

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Überprüfen Sie, ob eine Funktion bei einem minimal unterstützten Level derzeit unterstützt wird oder nicht.

boolean checkConnectivity ()

Überprüfen Sie, ob das Gerät über eine Netzwerkverbindung verfügt.

boolean clearErrorDialogs ()

Versuchen Sie, alle Fehlerdialoge zu schließen, die derzeit auf der Geräte-UI angezeigt werden.

void clearLastConnectedWifiNetwork ()

Löscht das zuletzt verbundene WLAN-Netzwerk.

void clearLogcat ()

Löscht alle angesammelten Logcat-Daten.

boolean connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.f

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

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

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

Eine Variante von connectToWifiNetwork(String, String) , die nur eine Verbindung herstellt, wenn das Gerät derzeit keine Netzwerkverbindung hat.

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

Eine Variante von connectToWifiNetwork(String, String) , die nur eine Verbindung herstellt, wenn das Gerät derzeit keine Netzwerkverbindung hat.

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

Erstellen Sie einen Benutzer mit einem bestimmten Namen und den bereitgestellten Flags

int createUser (String name)

Erstellen Sie einen Benutzer mit einem bestimmten Namen und Standard-Flags 0.

int createUserNoThrow (String name)

Erstellen Sie einen Benutzer mit einem bestimmten Namen und Standard-Flags 0.

void deleteFile (String deviceFilePath)

Hilfsmethode zum Löschen einer Datei oder eines Verzeichnisses auf dem Gerät.

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

Hilfsmethode zum Überprüfen, ob das Gerät weich neu gestartet wurde, indem der aktuelle system_server mit dem vorherigen system_server ProcessInfo verglichen wird.

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

Hilfsmethode, um zu überprüfen, ob das Gerät seit der UTC-Zeit seit der Epoche vom Gerät und seiner ERROR(/TimeUnit) neu gestartet wurde.

boolean disableAdbRoot ()

Deaktiviert Adb-Root.

void disableKeyguard ()

Versucht, die Tastensperre zu deaktivieren.

boolean disableNetworkMonitor ()

Deaktiviert die Netzwerküberwachung auf dem Gerät.

boolean disconnectFromWifi ()

Trennt die Verbindung zu einem WLAN-Netzwerk.

boolean doesFileExist (String deviceFilePath, int userId)

Hilfsmethode, um festzustellen, ob eine Datei auf dem Gerät für einen bestimmten Benutzer vorhanden ist.

boolean doesFileExist (String deviceFilePath)

Hilfsmethode, um festzustellen, ob eine Datei auf dem Gerät vorhanden ist.

File dumpHeap (String process, String devicePath)

Versuchen Sie, den Heap vom system_server auszugeben.

boolean enableAdbRoot ()

Aktiviert Adb-Root.

boolean enableNetworkMonitor ()

Aktiviert die Netzwerküberwachung auf dem Gerät.

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

Hilfsmethode, die einen adb-Befehl als Systembefehl mit einem angegebenen Timeout ausführt.

String executeAdbCommand (String... cmdArgs)

Hilfsmethode, die einen adb-Befehl als Systembefehl ausführt.

CommandResult executeFastbootCommand (String... cmdArgs)

Hilfsmethode, die einen Fastboot-Befehl als Systembefehl mit einem Standard-Timeout von 2 Minuten ausführt.

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

Hilfsmethode, die einen Fastboot-Befehl als Systembefehl ausführt.

CommandResult executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs)

Hilfsmethode, die einen lange laufenden Fastboot-Befehl als Systembefehl mit Systemumgebungsvariablen ausführt.

CommandResult executeLongFastbootCommand (String... cmdArgs)

Hilfsmethode, die einen lange laufenden Fastboot-Befehl als Systembefehl ausführt.

String executeShellCommand (String command)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ausgabe als String zurückgibt.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

void executeShellCommand (String command, IShellOutputReceiver receiver)

Führt den angegebenen Adb-Shell-Befehl aus und versucht es mehrmals, wenn der Befehl fehlschlägt.

CommandResult executeShellV2Command (String cmd)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe, stdout und stderr gefüllt ist.

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe und stderr gefüllt ist.

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe, stdout und stderr gefüllt ist.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

CommandResult fastbootWipePartition (String partition)

Hilfsmethode, die eine Partition für das Gerät löscht.

getActiveApexes ()

Rufen Sie die Informationen zu APEXs ab, die auf dem Gerät aktiviert sind.

getAllSettings (String namespace)

Geben Sie Schlüsselwertpaare des angeforderten Namespace zurück.

DeviceAllocationState getAllocationState ()

Gibt den aktuellen Zuordnungsstatus des Geräts zurück

String getAndroidId (int userId)

Suchen Sie die Android-ID, die einer Benutzer-ID zugeordnet ist, und geben Sie sie zurück, null, wenn sie nicht gefunden wird.

getAndroidIds ()

Erstellen Sie eine Karte mit Android-IDs, die übereinstimmende Benutzer-IDs gefunden haben.

int getApiLevel ()

Rufen Sie die API-Ebene des Geräts ab.

PackageInfo getAppPackageInfo (String packageName)

Abrufen von Informationen zu einem auf dem Gerät installierten Paket.

getAppPackageInfos ()

Abrufen von Informationen zu Paketen, die auf dem Gerät installiert sind.

String getBasebandVersion ()

Komfortmethode zum Abrufen der Basisband-(Funk-)Version dieses Geräts.

Integer getBattery ()

Gibt den aktuellen Batteriestand eines Geräts oder Null zurück, wenn der Batteriestand nicht verfügbar ist.

boolean getBooleanProperty (String name, boolean defaultValue)

Gibt den booleschen Wert der angegebenen Eigenschaft zurück.

getBootHistory ()

Die Hilfsmethode sammelt die Startverlaufskarte mit Startzeit und Startgrund.

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

Die Hilfsmethode erfasst die Startverlaufskarte mit der Startzeit und dem Startgrund seit der angegebenen Zeit seit der Epoche vom Gerät und der angegebenen Zeiteinheit.

String getBootloaderVersion ()

Komfortmethode zum Abrufen der Bootloader-Version dieses Geräts.

InputStreamSource getBugreport ()

Ruft einen Fehlerbericht vom Gerät ab.

InputStreamSource getBugreportz ()

Ruft einen Fehlerbericht vom Gerät ab.

String getBuildAlias ()

Rufen Sie den Alias ​​des Builds ab, den das Gerät derzeit ausführt.

String getBuildFlavor ()

Rufen Sie die Build-Variante für das Gerät ab.

String getBuildId ()

Rufen Sie den Build ab, den das Gerät derzeit ausführt.

String getBuildSigningKeys ()

Gibt den Schlüsseltyp zurück, der zum Signieren des Geräteabbilds verwendet wird

Typischerweise können Android-Geräte mit Testschlüsseln (wie in AOSP) oder Freigabeschlüsseln (kontrolliert durch einzelne Gerätehersteller) signiert werden.

DeviceDescriptor getCachedDeviceDescriptor ()

Gibt einen zwischengespeicherten DeviceDescriptor , wenn das Gerät zugewiesen ist, ansonsten den aktuellen DeviceDescriptor .

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

Gibt einen zwischengespeicherten DeviceDescriptor , wenn das Gerät zugewiesen ist, ansonsten den aktuellen DeviceDescriptor .

String[] getChildren (String path)

Alternative zur Verwendung von IFileEntry , die aufgrund von Berechtigungen manchmal nicht funktioniert.

DeviceFoldableState getCurrentFoldableState ()

Gibt den aktuellen faltbaren Zustand des Geräts oder null zurück, wenn einige Probleme aufgetreten sind.

int getCurrentUser ()

Gibt die ID des aktuell ausgeführten Benutzers zurück.

String getDeviceClass ()

Rufen Sie die Geräteklasse ab.

long getDeviceDate ()

Gibt das Datum des Geräts in Millisekunden seit der Epoche zurück.

DeviceDescriptor getDeviceDescriptor ()

Geben Sie einen DeviceDescriptor aus den Geräteinformationen zurück, um Informationen darüber zu erhalten, ohne das eigentliche Geräteobjekt zu übergeben.

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

Geben Sie einen DeviceDescriptor aus den Geräteinformationen zurück, um Informationen darüber zu erhalten, ohne das eigentliche Geräteobjekt zu übergeben.

TestDeviceState getDeviceState ()

Rufen Sie den Zustand des Geräts ab.

long getDeviceTimeOffset (Date date)

Helfer, um die Zeitdifferenz zwischen dem Gerät und einem bestimmten ERROR(/Date) zu erhalten.

InputStreamSource getEmulatorOutput ()

Holen Sie sich den Stream von Emulator stdout und stderr

Process getEmulatorProcess ()

Gibt den diesem Emulator entsprechenden Process zurück.

final File getExecuteShellCommandLog ()

Das Protokoll, das alle executeShellCommand(String) enthält.

long getExternalStoreFreeSpace ()

Hilfsmethode zum Bestimmen des freien Speicherplatzes auf dem externen Speicher des Geräts.

String getFastbootPath ()

Gibt den Pfad der verwendeten Fastboot-Binärdatei zurück.

String getFastbootProductType ()

Komfortmethode zum Abrufen des Produkttyps dieses Geräts im Fastboot-Modus.

String getFastbootProductVariant ()

Komfortmethode zum Abrufen des Produkttyps dieses Geräts im Fastboot-Modus.

String getFastbootSerialNumber ()

Gibt die Fastboot-Modus-Seriennummer zurück.

String getFastbootVariable (String variableName)

Rufen Sie den angegebenen Fastboot-Variablenwert vom Gerät ab.

String getFastbootVersion ()

Gibt die Versionszeichenfolge der verwendeten Fastboot-Binärdatei zurück.

IFileEntry getFileEntry (String path)

Rufen Sie einen Verweis auf eine Remote-Datei auf dem Gerät ab.

IFileEntry getFileEntry (FileListingService.FileEntry entry)

Inoffizieller Helfer, um einen FileEntry von einem Nicht-Root-Pfad zu erhalten.

getFoldableStates ()

Gibt die Liste der faltbaren Zustände auf dem Gerät zurück.

IDevice getIDevice ()

Gibt eine Referenz auf das zugeordnete ddmlib IDevice .

getInstalledPackageNames ()

Rufen Sie die auf dem Gerät vorhandenen Anwendungspaketnamen ab.

long getIntProperty (String name, long defaultValue)

Gibt den ganzzahligen Wert der angegebenen Eigenschaft vom Gerät zurück.

String getIpAddress ()

Ruft die IP-Adresse des Geräts ab.

KeyguardControllerState getKeyguardState ()

Geben Sie ein Objekt zurück, um den aktuellen Zustand des Keyguards abzurufen, oder null, wenn es nicht unterstützt wird.

long getLastExpectedRebootTimeMillis ()

Gibt zurück, wann Tradefed-APIs in Millisekunden seit EPOCH zuletzt einen Neustart ausgelöst haben, wie von System.currentTimeMillis() zurückgegeben.

int getLaunchApiLevel ()

Holen Sie sich das erste gestartete API-Level des Geräts.

InputStreamSource getLogcat ()

Erfasst einen Snapshot-Stream der Logcat-Daten.

InputStreamSource getLogcat (int maxBytes)

Erfasst einen Snapshot-Stream der letzten maxBytes erfasster Logcat-Daten.

InputStreamSource getLogcatDump ()

Holen Sie sich einen Speicherauszug des aktuellen Logcat für das Gerät.

InputStreamSource getLogcatSince (long date)

Ruft einen Snapshot-Stream erfasster Logcat-Daten ab dem angegebenen Datum ab.

String getMacAddress ()

Gibt die MAC-Adresse des Geräts zurück, null, wenn die Abfrage vom Gerät fehlschlägt.

getMainlineModuleInfo ()

Informieren Sie sich über die auf dem Gerät installierten Mainline-Module.

int getMaxNumberOfRunningUsersSupported ()

Holen Sie sich die maximale Anzahl unterstützter gleichzeitig laufender Benutzer.

int getMaxNumberOfUsersSupported ()

Holen Sie sich die maximale Anzahl unterstützter Benutzer.

IDeviceStateMonitor getMonitor ()

Gibt den dem Gerät zugeordneten IDeviceStateMonitor .

String getMountPoint (String mountName)

Gibt einen Einhängepunkt zurück.

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

Gibt eine MountPointInfo zurück, die dem angegebenen Mountpoint-Pfad entspricht, oder null , wenn dieser Pfad nichts gemountet hat oder anderweitig nicht in /proc/mounts als Mountpoint erscheint.

getMountPointInfo ()

Gibt eine geparste Version der Informationen in /proc/mounts auf dem Gerät zurück

TestDeviceOptions getOptions ()

Rufen Sie die Testoptionen für das Gerät ab.

long getPartitionFreeSpace (String partition)

Hilfsmethode zur Bestimmung des freien Speicherplatzes auf der Gerätepartition.

Integer getPrimaryUserId ()

Gibt die primäre Benutzer-ID zurück.

ProcessInfo getProcessByName (String processName)

Die Hilfsmethode führt die Befehle „pidof“ und „stat“ aus und gibt das ProcessInfo -Objekt mit der PID und der Prozessstartzeit des angegebenen Prozesses zurück.

String getProcessPid (String process)

Gibt die PID des Dienstes oder null zurück, wenn etwas schief gelaufen ist.

String getProductType ()

Praktische Methode, um den Produkttyp dieses Geräts zu erhalten.

String getProductVariant ()

Komfortmethode, um die Produktvariante dieses Geräts zu erhalten.

String getProperty (String name)

Rufen Sie den angegebenen Eigenschaftswert vom Gerät ab.

ITestDevice.RecoveryMode getRecoveryMode ()

Rufen Sie den aktuellen Wiederherstellungsmodus ab, der für das Gerät verwendet wird.

InputStreamSource getScreenshot (String format)

Schnappt sich einen Screenshot vom Gerät.

InputStreamSource getScreenshot (long displayId)

Erfasst einen Screenshot von dem Gerät mit der angegebenen Anzeige-ID.

InputStreamSource getScreenshot (String format, boolean rescale)

Schnappt sich einen Screenshot vom Gerät.

InputStreamSource getScreenshot ()

Schnappt sich einen Screenshot vom Gerät.

String getSerialNumber ()

Bequeme Methode, um die Seriennummer dieses Geräts zu erhalten.

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

Gibt den Wert der angeforderten Einstellung zurück.

String getSetting (String namespace, String key)

Siehe getSetting(int, String, String) und ausgeführt am Systembenutzer.

String getSimOperator ()

Geben Sie den Betreiber der SIM-Karte oder null zurück, wenn nicht verfügbar oder wenn das Gerät nicht verfügbar ist.

String getSimState ()

Gibt den Status der SIM-Karte oder null zurück, wenn nicht verfügbar oder das Gerät nicht verfügbar ist.

getTombstones ()

Rufen Sie die Tombstone-Liste von den Geräten ab und senden Sie sie zurück.

long getTotalMemory ()

Gibt die gesamte physische Speichergröße in Bytes oder -1 im Falle eines internen Fehlers zurück

getUninstallablePackageNames ()

Rufen Sie die Anwendungspaketnamen ab, die deinstalliert werden können.

boolean getUseFastbootErase ()

Finden Sie heraus, ob Fastboot Erase oder Fastboot Format verwendet werden soll, um eine Partition auf dem Gerät zu löschen.

int getUserFlags (int userId)

Suchen Sie die Flags eines bestimmten Benutzers und geben Sie sie zurück.

getUserInfos ()

Ruft die Zuordnung von useId zu UserInfo auf dem Gerät ab.

int getUserSerialNumber (int userId)

Gibt die Seriennummer zurück, die der Benutzer-ID zugeordnet ist, falls gefunden, -10000 in allen anderen Fällen.

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

Verarbeiten Sie das angegebene DeviceEvent .

Verarbeiten Sie das DeviceEvent, das dieses Gerät möglicherweise in einen neuen Zuordnungszustand überführt oder nicht.

boolean hasFeature (String feature)

Überprüfen Sie, ob eine Funktion auf einem Gerät verfügbar ist.

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

Installieren Sie ein Android-Paket auf dem Gerät.

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

Installieren Sie ein Android-Paket auf dem Gerät.

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

Installieren Sie ein Android-Paket auf dem Gerät für einen bestimmten Benutzer.

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

Installieren Sie ein Android-Paket auf dem Gerät für einen bestimmten Benutzer.

boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

Überprüfen Sie, ob die Plattform auf dem Gerät die App-Aufzählung unterstützt

boolean isDeviceEncrypted ()

Gibt zurück, ob das Gerät verschlüsselt ist.

boolean isDirectory (String path)

Geben Sie „True“ zurück, wenn der Pfad auf dem Gerät ein Verzeichnis ist, andernfalls „False“.

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

Gibt zurück, ob die Verschlüsselung auf dem Gerät unterstützt wird.

boolean isExecutable (String fullPath)

Gibt „True“ zurück, wenn der Dateipfad auf dem Gerät eine ausführbare Datei ist, andernfalls „False“.

boolean isFastbootEnabled ()

Zurückgeben, wenn Fastboot für das Gerät verfügbar ist.

boolean isHeadless ()

Geben Sie „true“ zurück, wenn das Gerät kopflos ist (kein Bildschirm), andernfalls „false“.

boolean isMultiUserSupported ()

Legt fest, ob mehrere Benutzer unterstützt werden.

boolean isPackageInstalled (String packageName, String userId)

Fragen Sie das Gerät nach einem bestimmten Paketnamen und einer bestimmten Benutzer-ID ab, um zu überprüfen, ob es derzeit für diesen Benutzer installiert ist oder nicht.

boolean isPackageInstalled (String packageName)

Fragen Sie das Gerät nach einem bestimmten Paketnamen ab, um zu überprüfen, ob es derzeit installiert ist oder nicht.

boolean isRuntimePermissionSupported ()

Überprüfen Sie, ob die Plattform auf dem Gerät die Gewährung von Laufzeitberechtigungen unterstützt

boolean isStateBootloaderOrFastbootd ()

Gibt true zurück, wenn sich das Gerät in TestDeviceState#FASTBOOT oder TestDeviceState.FASTBOOTD .

boolean isUserRunning (int userId)

Überprüfen Sie, ob ein bestimmter Benutzer ausgeführt wird.

boolean isUserSecondary (int userId)

Gibt zurück, ob der angegebene Benutzer gemäß seinen Flags ein sekundärer Benutzer ist.

boolean isWifiEnabled ()

Testen Sie, ob WLAN aktiviert ist.

listDisplayIds ()

Sammeln Sie die Liste der verfügbaren Display-IDs auf dem Gerät, wie von „dumpsys SurfaceFlinger“ gemeldet.

listUsers ()

Ruft die Liste der Benutzer auf dem Gerät ab.

boolean logAnrs ( ITestLogger logger)

Sammelt und protokolliert ANRs vom Gerät.

boolean logBugreport (String dataName, ITestLogger listener)

Hilfsmethode, um einen Fehlerbericht aufzunehmen und ihn den Meldern zu melden.

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

Protokollieren Sie eine Nachricht im Logcat des Geräts.

void nonBlockingReboot ()

Gibt einen Befehl zum Neustart des Geräts aus und kehrt zurück, wenn der Befehl abgeschlossen ist und das Gerät für adb nicht mehr sichtbar ist.

void postAdbRootAction ()

Überschreiben, wenn das Gerät bestimmte Aktionen nach dem ADB-Root ausführen muss und bevor das Gerät wieder online ist.

void postAdbUnrootAction ()

Überschreiben, wenn das Gerät bestimmte Aktionen nach dem Unroot von adb und bevor das Gerät wieder online ist, ausführen muss.

void postBootSetup ()

Führen Sie Anweisungen zum Konfigurieren des Geräts aus, um dies nach jedem Start zu testen.

void postInvocationTearDown (Throwable exception)

Zusätzliche Schritte für die gerätespezifische erforderliche Bereinigung, die nach Abschluss des Aufrufs ausgeführt werden.

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

Zusätzliche Schritte für die gerätespezifische erforderliche Einrichtung, die vor dem Aufruffluss auf dem Gerät ausgeführt werden.

boolean pullDir (String deviceFilePath, File localDir)

Verzeichnisinhalte rekursiv vom Gerät abrufen.

boolean pullFile (String remoteFilePath, File localFile)

Ruft eine Datei vom Gerät ab.

File pullFile (String remoteFilePath, int userId)

Ruft eine Datei vom Gerät ab, speichert sie in einem lokalen temporären ERROR(/File) und gibt diese File zurück.

File pullFile (String remoteFilePath)

Ruft eine Datei vom Gerät ab, speichert sie in einem lokalen temporären ERROR(/File) und gibt diese File zurück.

boolean pullFile (String remoteFilePath, File localFile, int userId)

Ruft eine Datei vom Gerät ab.

String pullFileContents (String remoteFilePath)

Ruft eine Datei vom Gerät ab und gibt den Inhalt zurück.

File pullFileFromExternal (String remoteFilePath)

Eine bequeme Methode, um eine Datei aus dem externen Speicher des Geräts abzurufen, sie in einem lokalen temporären ERROR(/File) zu speichern und einen Verweis auf diese File zurückzugeben.

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

Verzeichnisinhalte rekursiv auf das Gerät übertragen und dabei einige gefilterte Verzeichnisse ausschließen.

boolean pushDir (File localFileDir, String deviceFilePath)

Verzeichnisinhalte rekursiv auf das Gerät übertragen.

boolean pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded)

Variante von pushFile(File, String) , die optional die Notwendigkeit für den Inhaltsanbieter bewerten kann.

boolean pushFile (File localFile, String remoteFilePath)

Drücken Sie eine Datei auf das Gerät.

boolean pushString (String contents, String remoteFilePath)

Push-Datei, die aus einer Zeichenfolge erstellt wurde, an das Gerät

void reboot (String reason)

Startet das Gerät im ADB-Modus neu, wobei der reason angegeben wird, dass es über den Neustart hinweg bestehen bleibt.

void reboot ()

Startet das Gerät im Adb-Modus neu.

void rebootIntoBootloader ()

Startet das Gerät im Bootloader-Modus neu.

void rebootIntoFastbootd ()

Startet das Gerät im Fastbootd-Modus neu.

void rebootIntoRecovery ()

Startet das Gerät im ADB-Wiederherstellungsmodus neu.

void rebootIntoSideload ()

Startet das Gerät im ADB-Sideload-Modus neu (beachten Sie, dass dies ein spezieller Modus in der Wiederherstellung ist)

Blockiert, bis das Gerät in den Sideload-Modus wechselt

void rebootIntoSideload (boolean autoReboot)

Startet das Gerät im ADB-Sideload-Modus neu (beachten Sie, dass dies ein spezieller Modus in der Wiederherstellung ist)

Blockiert, bis das Gerät in den Sideload-Modus wechselt

void rebootUntilOnline ()

Eine Alternative zu reboot() , die nur blockiert, bis das Gerät online ist, dh für adb sichtbar ist.

void rebootUntilOnline (String reason)

Eine Alternative zu reboot() , die nur blockiert, bis das Gerät online ist, dh für adb sichtbar ist.

void rebootUserspace ()

Startet nur den Userspace-Teil des Geräts neu.

void rebootUserspaceUntilOnline ()

Eine Alternative zu rebootUserspace() ()}, die nur blockiert, bis das Gerät online ist, dh für adb sichtbar ist.

boolean recoverDevice ()

Versucht, die Gerätekommunikation wiederherzustellen.

void remountSystemWritable ()

Machen Sie die Systempartition auf dem Gerät beschreibbar.

void remountVendorWritable ()

Machen Sie die Herstellerpartition auf dem Gerät beschreibbar.

boolean removeAdmin (String componentName, int userId)

Entfernen Sie den angegebenen Geräteadministrator im angegebenen Benutzer und geben Sie „ true “ zurück, wenn dies erfolgreich war, andernfalls „ false “.

void removeOwners ()

Entfernen Sie alle vorhandenen Besitzer von Geräteprofilen nach besten Kräften.

boolean removeUser (int userId)

Entfernen Sie einen bestimmten Benutzer vom Gerät.

void resetContentProviderSetup ()

Setzen Sie das Flag für die Einrichtung des Inhaltsanbieters zurück, um es erneut auszulösen.

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

Praktische Methode zum Ausführen von ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) mit einem oder mehreren als Parameter übergebenen Listenern.

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

Führt Instrumentierungstests durch und bietet Gerätewiederherstellung.

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

ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) , führt aber den Test für einen bestimmten Benutzer aus.

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

Identisch mit ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) , führt aber den Test aus für den angegebenen Benutzer.

void setConfiguration ( IConfiguration configuration)

Fügt die verwendete IConfiguration ein.

void setDate (Date date)

Stellt das Datum auf dem Gerät ein

Hinweis: Zum Einstellen des Datums auf dem Gerät ist root erforderlich

boolean setDeviceOwner (String componentName, int userId)

Legen Sie eine Geräteverwaltungskomponente als Geräteeigentümer in einem bestimmten Benutzer fest.

void setDeviceState ( TestDeviceState deviceState)

Aktualisieren Sie den Status des Geräts.

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

Legen Sie für den Emulator SizeLimitedOutputStream , um die Ausgabe zu protokollieren

void setEmulatorProcess (Process p)

Legt den Process , wenn dieses Gerät ein Emulator ist.

void setFastbootEnabled (boolean fastbootEnabled)

Stellen Sie die Fastboot-Option für das Gerät ein.

void setFastbootPath (String fastbootPath)

Legt den Pfad zur Fastboot-Binärdatei fest, die verwendet werden soll.

void setIDevice (IDevice newDevice)

Aktualisieren Sie das diesem ITestDevice zugeordnete IDevice.

void setOptions ( TestDeviceOptions options)

Legen Sie die TestDeviceOptions für das Gerät fest

boolean setProperty (String propKey, String propValue)

Legt den angegebenen Eigenschaftswert auf dem Gerät fest.

void setRecovery ( IDeviceRecovery recovery)

Legen Sie die für dieses Gerät zu verwendende IDeviceRecovery .

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

Legen Sie den aktuellen Wiederherstellungsmodus fest, der für das Gerät verwendet werden soll.

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

Siehe setSetting(int, String, String, String) und wird vom Systembenutzer ausgeführt.

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

Fügen Sie dem Namespace eines bestimmten Benutzers einen Einstellungswert hinzu.

void setUseFastbootErase (boolean useFastbootErase)

Legen Sie fest, ob Fastboot Erase oder Fastboot Format verwendet werden soll, um eine Partition auf dem Gerät zu löschen.

void startLogcat ()

Starten Sie die Erfassung der Logcat-Ausgabe vom Gerät im Hintergrund.

boolean startUser (int userId)

Startet einen bestimmten Benutzer im Hintergrund, wenn er gerade gestoppt ist.

boolean startUser (int userId, boolean waitFlag)

Startet einen bestimmten Benutzer im Hintergrund, wenn er gerade gestoppt ist.

void stopEmulatorOutput ()

Schließen und löschen Sie die Emulatorausgabe.

void stopLogcat ()

Beenden Sie die Erfassung der Logcat-Ausgabe vom Gerät und verwerfen Sie die aktuell gespeicherten Logcat-Daten.

boolean stopUser (int userId)

Stoppt einen bestimmten Benutzer.

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

Stoppen Sie einen bestimmten Benutzer.

String switchToAdbTcp ()

Schalten Sie das Gerät in den Adb-over-TCP-Modus.

boolean switchToAdbUsb ()

Schalten Sie das Gerät in den ADB-über-USB-Modus.

boolean switchUser (int userId)

Wechseln Sie zu einer anderen Benutzer-ID mit einem Standardzeitlimit.

boolean switchUser (int userId, long timeout)

Wechseln Sie zu einer anderen Benutzer-ID mit dem angegebenen Timeout als Frist.

boolean syncFiles (File localFileDir, String deviceFilePath)

Synchronisiert inkrementell den Inhalt eines lokalen Dateiverzeichnisses mit dem Gerät.

Bugreport takeBugreport ()

Nehmen Sie einen Bugreport und geben Sie ihn innerhalb eines Bugreport Objekts zurück, um ihn zu behandeln.

String uninstallPackage (String packageName)

Deinstallieren Sie ein Android-Paket vom Gerät.

String uninstallPackageForUser (String packageName, int userId)

Deinstallieren Sie ein Android-Paket vom Gerät für einen bestimmten Benutzer.

boolean unlockDevice ()

Entsperrt das Gerät, wenn sich das Gerät in einem verschlüsselten Zustand befindet.

boolean waitForBootComplete (long timeOut)

Blockiert, bis das Boot-Complete-Flag des Geräts gesetzt ist.

boolean waitForDeviceAvailable ()

Wartet, bis das Gerät reagiert und zum Testen verfügbar ist.

boolean waitForDeviceAvailable (long waitTime)

Wartet, bis das Gerät reagiert und zum Testen verfügbar ist.

void waitForDeviceBootloader ()

Blockiert, bis das Gerät per Fastboot sichtbar ist.

boolean waitForDeviceInRecovery (long waitTime)

Blockiert, dass sich das Gerät im Zustand „adb recovery“ befindet (beachten Sie, dass sich dies von IDeviceRecovery unterscheidet).

boolean waitForDeviceInSideload (long waitTime)

Blockiert, damit sich das Gerät im Zustand „adb sideload“ befindet

boolean waitForDeviceNotAvailable (long waitTime)

Blöcke für das Gerät sind nicht verfügbar, dh fehlen in adb

void waitForDeviceOnline ()

Blockiert, bis das Gerät über adb sichtbar ist.

void waitForDeviceOnline (long waitTime)

Blockiert, bis das Gerät über adb sichtbar ist.

boolean waitForDeviceShell (long waitTime)

Wartet darauf, dass das Gerät auf einen einfachen Adb-Shell-Befehl reagiert.

Geschützte Methoden

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

Erstellen Sie eine RebootDeviceAction , die beim Ausführen einer Neustartaktion verwendet werden soll.

void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

Führen Sie einen adb-Neustart durch.

void ensureRuntimePermissionSupported ()

Hilfsmethode zum Auslösen einer Ausnahme, wenn die Laufzeitberechtigung nicht unterstützt wird

InputStreamSource getBugreportInternal ()
File getBugreportzInternal ()

Interne Hilfsmethode zum Abrufen der Bugreportz-Zip-Datei als ERROR(/File) .

IRunUtil getRunUtil ()

Rufen Sie die zu verwendende RunUtil Instanz ab.

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

Rufen Sie eine Geräteeigenschaft standardmäßig aus dem ddmlib-Cache ab und greifen Sie entweder auf „adb shell getprop“ oder „fastboot getvar“ zurück, je nachdem, ob sich das Gerät in Fastboot befindet oder nicht.

boolean isNewer (File localFile, IFileEntry entry)

Geben Sie „ true “ zurück, wenn die lokale Datei neuer ist als die entfernte Datei.

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

Führt eine Aktion auf diesem Gerät aus.

void postAdbReboot ()

Mögliche zusätzliche Aktionen, die nach einem Neustart durchgeführt werden können.

void prePostBootSetup ()

Ermöglicht jedem Gerätetyp (AndroidNativeDevice, TestDevice), diese Methode für ein bestimmtes Post-Boot-Setup zu überschreiben.

boolean pullFileInternal (String remoteFilePath, File localFile)
void setClock (Clock clock)

Legen Sie die zu verwendende Clock-Instanz fest.

void setLogStartDelay (int delay)

Legt die Zeit in ms fest, die gewartet werden soll, bevor die Logcat-Erfassung für ein Online-Gerät gestartet wird.

CommandResult simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd)

Führt einen einfachen Fastboot-Befehl mit Umgebungsvariablen aus und meldet den Status des Befehls.

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

Führt einen einfachen Fastboot-Befehl aus und meldet den Status des Befehls.

boolean waitForDeviceNotAvailable (String operationDesc, long time)

Warten Sie, bis das Gerät nicht mehr verfügbar ist (beenden Sie die Berichterstattung an adb).

Konstanten

UNGÜLTIGE BENUTZER-ID

public static final int INVALID_USER_ID

Wert, der für jede ungültige/nicht gefundene Benutzer-ID zurückgegeben wird: UserHandle hat den Wert -10000 definiert

Konstanter Wert: -10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

Konstanter Wert: 5000 (0x0000000000001388)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

die Standardanzahl der auszuführenden Befehlswiederholungsversuche

Konstanter Wert: 2 (0x00000002)

Felder

SD-KARTE

protected static final String SD_CARD

SPEICHER_EMULIERT

protected static final String STORAGE_EMULATED

mOptionen

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

Öffentliche Konstrukteure

NativeDevice

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

Erstellt ein TestDevice .

Parameter
device IDevice : das zugeordnete IDevice

stateMonitor IDeviceStateMonitor : der zu verwendende IDeviceStateMonitor Mechanismus

allocationMonitor IDeviceMonitor : der IDeviceMonitor , der über Änderungen des Zuordnungsstatus informiert. Kann null sein

Öffentliche Methoden

checkApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Überprüfen Sie, ob eine Funktion bei einem minimal unterstützten Level derzeit unterstützt wird oder nicht. Diese Methode berücksichtigt noch unveröffentlichte Funktionen, bevor die API-Ebene angehoben wird.

Parameter
strictMinLevel int : Die strenge minimal mögliche Ebene, die die Funktion unterstützt.

Kehrt zurück
boolean True, wenn die Ebene unterstützt wird. Sonst falsch.

Wirft
DeviceNotAvailableException

Konnektivität prüfen

public boolean checkConnectivity ()

Überprüfen Sie, ob das Gerät über eine Netzwerkverbindung verfügt.

Kehrt zurück
boolean true wenn das Gerät eine funktionierende Netzwerkverbindung hat, ansonsten false .

Wirft
DeviceNotAvailableException

clearErrorDialogs

public boolean clearErrorDialogs ()

Versuchen Sie, alle Fehlerdialoge zu schließen, die derzeit auf der Geräte-UI angezeigt werden.

Kehrt zurück
boolean true wenn keine Dialoge vorhanden waren oder Dialoge erfolgreich gelöscht wurden. false sonst.

Wirft
DeviceNotAvailableException

clearLastConnectedWifiNetwork

public void clearLastConnectedWifiNetwork ()

Löscht das zuletzt verbundene WLAN-Netzwerk. Dies sollte beim Starten eines neuen Aufrufs aufgerufen werden, um zu vermeiden, dass nach dem Neustart des Geräts eine Verbindung mit dem im vorherigen Test verwendeten WLAN-Netzwerk hergestellt wird.

clearLogcat

public void clearLogcat ()

Löscht alle angesammelten Logcat-Daten.

Dies ist nützlich, wenn Sie sicherstellen möchten, dass ITestDevice#getLogcat() nur Protokolldaten zurückgibt, die nach einem bestimmten Punkt erstellt wurden (z. B. nach dem Flashen eines neuen Geräteaufbaus usw.).

ConnectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

Schaltet WLAN ein und blockiert, bis eine erfolgreiche Verbindung mit einem der in der wifiSsidToPsk-Karte angegebenen WLAN-Netzwerke hergestellt wurde. Sobald eine Verbindung hergestellt ist, versucht die Instanz, die Verbindung nach jedem Neustart wiederherzustellen, bis ITestDevice#disconnectFromWifi() oder ITestDevice#clearLastConnectedWifiNetwork() aufgerufen wird.

Parameter
wifiSsidToPsk : Eine Zuordnung von WLAN-SSIDs zu Passwörtern.

scanSsid boolean : ob nach versteckten SSIDs für dieses Netzwerk gesucht werden soll.

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

ConnectToWifiNetwork

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

Schaltet WLAN ein und blockiert, bis eine erfolgreiche Verbindung zum angegebenen WLAN-Netzwerk hergestellt wurde. Sobald eine Verbindung hergestellt ist, versucht die Instanz, die Verbindung nach jedem Neustart wiederherzustellen, bis ITestDevice#disconnectFromWifi() oder ITestDevice#clearLastConnectedWifiNetwork() aufgerufen wird.

Parameter
wifiSsid String : die WLAN-SSID, mit der eine Verbindung hergestellt werden soll

wifiPsk String : PSK-Passphrase oder null, wenn unverschlüsselt

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

ConnectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk)

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

Schaltet WLAN ein und blockiert, bis eine erfolgreiche Verbindung mit einem der in der wifiSsidToPsk-Karte angegebenen WLAN-Netzwerke hergestellt wurde. Sobald eine Verbindung hergestellt ist, versucht die Instanz, die Verbindung nach jedem Neustart wiederherzustellen, bis ITestDevice#disconnectFromWifi() oder ITestDevice#clearLastConnectedWifiNetwork() aufgerufen wird.f

Parameter
wifiSsidToPsk : Eine Zuordnung von WLAN-SSIDs zu Passwörtern.

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

ConnectToWifiNetwork

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

Stellt eine Verbindung zu einem WLAN-Netzwerk her.

Schaltet WLAN ein und blockiert, bis eine erfolgreiche Verbindung zum angegebenen WLAN-Netzwerk hergestellt wurde. Sobald eine Verbindung hergestellt ist, versucht die Instanz, die Verbindung nach jedem Neustart wiederherzustellen, bis ITestDevice#disconnectFromWifi() oder ITestDevice#clearLastConnectedWifiNetwork() aufgerufen wird.

Parameter
wifiSsid String : die WLAN-SSID, mit der eine Verbindung hergestellt werden soll

wifiPsk String : PSK-Passphrase oder null, wenn unverschlüsselt

scanSsid boolean : ob nach versteckten SSIDs für dieses Netzwerk gesucht werden soll.

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

ConnectToWifiNetworkIfNeeded

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

Eine Variante von connectToWifiNetwork(String, String) , die nur eine Verbindung herstellt, wenn das Gerät derzeit keine Netzwerkverbindung hat.

Parameter
scanSsid boolean : ob nach versteckten SSIDs für dieses Netzwerk gesucht werden soll

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

ConnectToWifiNetworkIfNeeded

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

Eine Variante von connectToWifiNetwork(String, String) , die nur eine Verbindung herstellt, wenn das Gerät derzeit keine Netzwerkverbindung hat.

Kehrt zurück
boolean true wenn erfolgreich mit dem WLAN-Netzwerk verbunden. false sonst

Wirft
DeviceNotAvailableException

Benutzer erstellen

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

Erstellen Sie einen Benutzer mit einem bestimmten Namen und den bereitgestellten Flags

Parameter
name String : des Benutzers, der auf dem Gerät erstellt werden soll

guest boolean : Aktivieren Sie das Benutzer-Flag --guest während der Erstellung

ephemeral boolean : Aktivieren Sie das Benutzer-Flag --ephemeral während der Erstellung

Kehrt zurück
int ID des erstellten Benutzers

Wirft
DeviceNotAvailableException

Benutzer erstellen

public int createUser (String name)

Erstellen Sie einen Benutzer mit einem bestimmten Namen und Standard-Flags 0.

Parameter
name String : des Benutzers, der auf dem Gerät erstellt werden soll

Kehrt zurück
int die Ganzzahl für die erstellte Benutzer-ID

Wirft
DeviceNotAvailableException

createUserNoThrow

public int createUserNoThrow (String name)

Erstellen Sie einen Benutzer mit einem bestimmten Namen und Standard-Flags 0.

Parameter
name String : des Benutzers, der auf dem Gerät erstellt werden soll

Kehrt zurück
int die Ganzzahl für die erstellte Benutzer-ID oder -1 für Fehler.

Wirft
DeviceNotAvailableException

Datei löschen

public void deleteFile (String deviceFilePath)

Hilfsmethode zum Löschen einer Datei oder eines Verzeichnisses auf dem Gerät.

Parameter
deviceFilePath String : Der absolute Pfad der Datei auf dem Gerät.

Wirft
DeviceNotAvailableException

deviceSoftRestarted

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

Hilfsmethode zum Überprüfen, ob das Gerät weich neu gestartet wurde, indem der aktuelle system_server mit dem vorherigen system_server ProcessInfo verglichen wird. Verwenden Sie getProcessByName(String) , um ProcessInfo abzurufen.

Parameter
prevSystemServerProcess ProcessInfo : der vorherige system_server-Prozess ProcessInfo .

Kehrt zurück
boolean true wenn das Gerät weich neu gestartet wurde

Wirft
DeviceNotAvailableException

deviceSoftRestartedSince

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

Hilfsmethode, um zu überprüfen, ob das Gerät seit der UTC-Zeit seit der Epoche vom Gerät und seiner ERROR(/TimeUnit) neu gestartet wurde. Sanfter Neustart bezieht sich auf system_server, der außerhalb eines harten Geräteneustarts neu gestartet wurde (z. B.: angeforderter Neustart). Die aktuelle Device utcEpochTime in Millisekunden kann mit der Methode getDeviceDate() werden.

Parameter
utcEpochTime long : die Gerätezeit in Sekunden seit der Epoche.

timeUnit TimeUnit : die Zeiteinheit TimeUnit für die gegebene utcEpochTime.

Kehrt zurück
boolean true wenn das Gerät weich neu gestartet wurde

Wirft
DeviceNotAvailableException

AdbRoot deaktivieren

public boolean disableAdbRoot ()

Deaktiviert Adb-Root.

Das Deaktivieren von adb root kann dazu führen, dass das Gerät von adb getrennt wird. Diese Methode blockiert, bis das Gerät verfügbar ist.

Kehrt zurück
boolean true wenn erfolgreich.

Wirft
DeviceNotAvailableException

disableKeyguard

public void disableKeyguard ()

Versucht, die Tastensperre zu deaktivieren.

Warten Sie zunächst, bis der Input-Dispatch bereit ist. Dies geschieht ungefähr zur gleichen Zeit, wenn das Gerät BOOT_COMPLETE meldet, anscheinend asynchron, da die aktuelle Framework-Implementierung gelegentlich eine Race-Bedingung aufweist. Dann wird der Befehl gesendet, die Tastensperre zu schließen (funktioniert nur bei nicht sicheren).

Wirft
DeviceNotAvailableException

Netzwerkmonitor deaktivieren

public boolean disableNetworkMonitor ()

Deaktiviert die Netzwerküberwachung auf dem Gerät.

Kehrt zurück
boolean true wenn die Überwachung erfolgreich deaktiviert wurde. false , wenn es fehlgeschlagen ist.

Wirft
DeviceNotAvailableException

trennenVonWifi

public boolean disconnectFromWifi ()

Trennt die Verbindung zu einem WLAN-Netzwerk.

Entfernt alle Netzwerke aus der Liste bekannter Netzwerke und deaktiviert WLAN.

Kehrt zurück
boolean true wenn die Verbindung zum WLAN-Netzwerk erfolgreich getrennt wurde. false , wenn die Trennung fehlgeschlagen ist.

Wirft
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath, 
                int userId)

Hilfsmethode, um festzustellen, ob eine Datei auf dem Gerät für einen bestimmten Benutzer vorhanden ist.

Parameter
deviceFilePath String : Der absolute Pfad der Datei auf dem zu prüfenden Gerät

userId int : Die Benutzer-ID, anhand derer das Vorhandensein der Datei überprüft werden soll

Kehrt zurück
boolean true wenn die Datei existiert, andernfalls false .

Wirft
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath)

Hilfsmethode, um festzustellen, ob eine Datei auf dem Gerät vorhanden ist.

Parameter
deviceFilePath String : Der absolute Pfad der Datei auf dem zu prüfenden Gerät

Kehrt zurück
boolean true wenn die Datei existiert, andernfalls false .

Wirft
DeviceNotAvailableException

dumpHeap

public File dumpHeap (String process, 
                String devicePath)

Versuchen Sie, den Heap vom system_server auszugeben. Es liegt in der Verantwortung des Aufrufers, die ausgegebene Datei zu bereinigen.

Parameter
process String : Der Name des Geräteprozesses für den Dumpheap.

devicePath String : Der Pfad auf dem Gerät, wo der Dump abgelegt werden soll. Dies muss ein Ort sein, an dem die Berechtigungen dies zulassen.

Kehrt zurück
File die ERROR(/File) , die den Bericht enthält. Null, wenn etwas fehlgeschlagen ist.

Wirft
DeviceNotAvailableException

enableAdbRoot

public boolean enableAdbRoot ()

Aktiviert Adb-Root. Wenn die Einstellung „enable-root“ „false“ ist, wird eine Nachricht protokolliert und zurückgegeben, ohne root zu aktivieren.

Das Aktivieren von adb root kann dazu führen, dass das Gerät von adb getrennt wird. Diese Methode blockiert, bis das Gerät verfügbar ist.

Kehrt zurück
boolean true wenn erfolgreich.

Wirft
DeviceNotAvailableException

enableNetworkMonitor

public boolean enableNetworkMonitor ()

Aktiviert die Netzwerküberwachung auf dem Gerät.

Kehrt zurück
boolean true wenn die Überwachung erfolgreich aktiviert wurde. false , wenn es fehlgeschlagen ist.

Wirft
DeviceNotAvailableException

AusführenAdbCommand

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

Hilfsmethode, die einen adb-Befehl als Systembefehl mit einem angegebenen Timeout ausführt.

Wenn möglich, sollte stattdessen executeShellCommand(String) verwendet werden, da diese Methode eine bessere Fehlererkennung und Leistung bietet.

Parameter
timeout long : Die Zeit in Millisekunden, bevor das Gerät als nicht reagierend betrachtet wird, 0L für kein Timeout

cmdArgs String : der adb-Befehl und die auszuführenden Argumente

Kehrt zurück
String die Standardausgabe vom Befehl. null , wenn der Befehl nicht ausgeführt werden konnte.

Wirft
DeviceNotAvailableException

AusführenAdbCommand

public String executeAdbCommand (String... cmdArgs)

Hilfsmethode, die einen adb-Befehl als Systembefehl ausführt.

Wenn möglich, sollte stattdessen executeShellCommand(String) verwendet werden, da diese Methode eine bessere Fehlererkennung und Leistung bietet.

Parameter
cmdArgs String : der adb-Befehl und die auszuführenden Argumente

Kehrt zurück
String die Standardausgabe vom Befehl. null , wenn der Befehl nicht ausgeführt werden konnte.

Wirft
DeviceNotAvailableException

AusführenFastbootCommand

public CommandResult executeFastbootCommand (String... cmdArgs)

Hilfsmethode, die einen Fastboot-Befehl als Systembefehl mit einem Standard-Timeout von 2 Minuten ausführt.

Wird voraussichtlich verwendet, wenn sich das Gerät bereits im Fastboot-Modus befindet.

Parameter
cmdArgs String : der Fastboot-Befehl und die auszuführenden Argumente

Kehrt zurück
CommandResult das CommandResult, das die Ausgabe des Befehls enthält

Wirft
DeviceNotAvailableException

AusführenFastbootCommand

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

Hilfsmethode, die einen Fastboot-Befehl als Systembefehl ausführt.

Wird voraussichtlich verwendet, wenn sich das Gerät bereits im Fastboot-Modus befindet.

Parameter
timeout long : die Zeit in Millisekunden, bevor der Befehl abläuft

cmdArgs String : der Fastboot-Befehl und die auszuführenden Argumente

Kehrt zurück
CommandResult das CommandResult, das die Ausgabe des Befehls enthält

Wirft
DeviceNotAvailableException

AusführenLongFastbootCommand

public CommandResult executeLongFastbootCommand ( envVarMap, 
                String... cmdArgs)

Hilfsmethode, die einen lange laufenden Fastboot-Befehl als Systembefehl mit Systemumgebungsvariablen ausführt.

Identisch mit executeFastbootCommand(String) , außer dass ein längeres Timeout verwendet wird.

Parameter
envVarMap : die Systemumgebungsvariablen, mit denen der Fastboot-Befehl ausgeführt wird

cmdArgs String : der Fastboot-Befehl und die auszuführenden Argumente

Kehrt zurück
CommandResult das CommandResult, das die Ausgabe des Befehls enthält

Wirft
DeviceNotAvailableException

AusführenLongFastbootCommand

public CommandResult executeLongFastbootCommand (String... cmdArgs)

Hilfsmethode, die einen lange laufenden Fastboot-Befehl als Systembefehl ausführt.

Identisch mit executeFastbootCommand(String) , außer dass ein längeres Timeout verwendet wird.

Parameter
cmdArgs String : der Fastboot-Befehl und die auszuführenden Argumente

Kehrt zurück
CommandResult das CommandResult, das die Ausgabe des Befehls enthält

Wirft
DeviceNotAvailableException

ShellCommand ausführen

public String executeShellCommand (String command)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ausgabe als String zurückgibt.

Parameter
command String : der auszuführende Adb-Shell-Befehl

Kehrt zurück
String die Shell-Ausgabe

Wirft
DeviceNotAvailableException

ShellCommand ausführen

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

Parameter
command String : der auszuführende Adb-Shell-Befehl

receiver IShellOutputReceiver : der IShellOutputReceiver , an den die Shell-Ausgabe geleitet werden soll.

maxTimeToOutputShellResponse long : die maximale Zeitspanne, während der der Befehl keine Antwort ausgeben darf; Einheit wie in timeUnit angegeben

timeUnit TimeUnit : Einheit für maxTimeToOutputShellResponse

retryAttempts int : die maximale Anzahl von Wiederholungen des Befehls, wenn er aufgrund einer Ausnahme fehlschlägt. DeviceNotResponsiveException wird ausgelöst, wenn retryAttempts ohne Erfolg durchgeführt werden.

Wirft
DeviceNotAvailableException

ShellCommand ausführen

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

Parameter
command String : der auszuführende Adb-Shell-Befehl

receiver IShellOutputReceiver : der IShellOutputReceiver , an den die Shell-Ausgabe geleitet werden soll.

maxTimeoutForCommand long : die maximale Zeitüberschreitung für den Abschluss des Befehls; Einheit wie in timeUnit angegeben

maxTimeToOutputShellResponse long : die maximale Zeitspanne, während der der Befehl keine Antwort ausgeben darf; Einheit wie in timeUnit angegeben

timeUnit TimeUnit : Einheit für maxTimeToOutputShellResponse

retryAttempts int : die maximale Anzahl von Wiederholungen des Befehls, wenn er aufgrund einer Ausnahme fehlschlägt. DeviceNotResponsiveException wird ausgelöst, wenn retryAttempts ohne Erfolg durchgeführt werden.

Wirft
DeviceNotAvailableException

ShellCommand ausführen

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

Führt den angegebenen Adb-Shell-Befehl aus und versucht es mehrmals, wenn der Befehl fehlschlägt.

Eine einfachere Form von executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int) mit Standardwerten.

Parameter
command String : der auszuführende Adb-Shell-Befehl

receiver IShellOutputReceiver : der IShellOutputReceiver , an den die Shell-Ausgabe geleitet werden soll.

Wirft
DeviceNotAvailableException

AusführenShellV2Befehl

public CommandResult executeShellV2Command (String cmd)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe, stdout und stderr gefüllt ist.

Parameter
cmd String : Der Befehl, der ausgeführt werden soll.

Kehrt zurück
CommandResult Das Ergebnis in CommandResult .

Wirft
DeviceNotAvailableException

AusführenShellV2Befehl

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe und stderr gefüllt ist. stdout wird an den angegebenen Stream geleitet.

Parameter
cmd String : Der Befehl, der ausgeführt werden soll.

pipeToOutput OutputStream : ERROR(/OutputStream) wo die Standardausgabe umgeleitet wird, oder null.

Kehrt zurück
CommandResult Das Ergebnis in CommandResult .

Wirft
DeviceNotAvailableException

AusführenShellV2Befehl

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

Hilfsmethode, die einen Adb-Shell-Befehl ausführt und die Ergebnisse als CommandResult zurückgibt, das ordnungsgemäß mit der Befehlsstatusausgabe, stdout und stderr gefüllt ist.

Parameter
cmd String : Der Befehl, der ausgeführt werden soll.

pipeAsInput File : Ein ERROR(/File) , der als Eingabe an den Befehl weitergeleitet wird, oder null.

Kehrt zurück
CommandResult Das Ergebnis in CommandResult .

Wirft
DeviceNotAvailableException

AusführenShellV2Befehl

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

Führt einen Adb-Shell-Befehl mit weiteren Parametern zur Steuerung des Befehlsverhaltens aus.

Parameter
cmd String : der auszuführende Adb-Shell-Befehl

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.

Kehrt zurück
CommandResult

Throws
DeviceNotAvailableException

executeShellV2Command

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

Executes a adb shell command, with more parameters to control command behavior.

Parameter
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

Kehrt zurück
CommandResult

Throws
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.

Parameter
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.

Kehrt zurück
CommandResult

Throws
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.

Parameter
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.

Kehrt zurück
CommandResult

Throws
DeviceNotAvailableException

fastbootWipePartition

public CommandResult fastbootWipePartition (String partition)

Helper method which wipes a partition for the device.

If getUseFastbootErase() 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.

Parameter
partition String : the partition to wipe

Kehrt zurück
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Fetch the information about APEXes activated on the device.

Kehrt zurück
ERROR(/Set) of ApexInfo currently activated on the device

Throws
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Return key value pairs of requested namespace.

Parameter
namespace String : must be one of {"system", "secure", "global"}

Kehrt zurück
the map of key value pairs. Null if namespace is not supported.

Throws
DeviceNotAvailableException

getAllocationState

public DeviceAllocationState getAllocationState ()

Return the current allocation state of device

Kehrt zurück
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

Find and return the android-id associated to a userId, null if not found.

Parameter
userId int

Kehrt zurück
String

Throws
DeviceNotAvailableException

getAndroidIds

public  getAndroidIds ()

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.

Kehrt zurück
Map of android ids found matching user ids.

Throws
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

Get the device API Level. Defaults to UNKNOWN_API_LEVEL .

Kehrt zurück
int an integer indicating the API Level of device

Throws
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

Fetch information about a package installed on device.

Parameter
packageName String

Kehrt zurück
PackageInfo the PackageInfo or null if information could not be retrieved

Throws
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Fetch information of packages installed on the device.

Kehrt zurück
ERROR(/List) of PackageInfo s installed on the device.

Throws
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 .

Kehrt zurück
String the String baseband version or null if it cannot be determined (device has no radio or version string cannot be read)

Throws
DeviceNotAvailableException

getBattery

public Integer getBattery ()

Returns the current battery level of a device or Null if battery level unavailable.

Kehrt zurück
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

Returns boolean value of the given property.

Parameter
name String : the property name

defaultValue boolean : default value to return if property is empty or doesn't exist.

Kehrt zurück
boolean true if the property has value "1" , "y" , "yes" , "on" , or "true" , false if the property has value of "0" , "n" , "no" , "off" , "false" , or defaultValue otherwise.

Throws
DeviceNotAvailableException

getBootHistory

public  getBootHistory ()

Helper method collects the boot history map with boot time and boot reason.

Kehrt zurück
Map of boot time (UTC time in second since Epoch) and boot reason

Throws
DeviceNotAvailableException

getBootHistorySince

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

Helper method collects the boot history map with boot time and boot reason since the given time since epoch from device and the time unit specified. The current device utcEpochTime in Millisecond can be obtained by method getDeviceDate() .

Parameter
utcEpochTime long : the device time since Epoch.

timeUnit TimeUnit : the time unit TimeUnit .

Kehrt zurück
Map of boot time (UTC time in second since Epoch) and boot reason

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

Kehrt zurück
String the String bootloader version or null if it cannot be found

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

Kehrt zurück
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

Kehrt zurück
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

Kehrt zurück
String the build alias or fall back to build id if it could not be retrieved

Throws
DeviceNotAvailableException

getBuildFlavor

public String getBuildFlavor ()

Retrieve the build flavor for the device.

Kehrt zurück
String the build flavor or null if it could not be retrieved

Throws
DeviceNotAvailableException

getBuildId

public String getBuildId ()

Retrieve the build the device is currently running.

Kehrt zurück
String the build id or IBuildInfo#UNKNOWN_BUILD_ID if it could not be retrieved

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

Kehrt zurück
String The signing key if found, null otherwise.

Throws
DeviceNotAvailableException

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor ()

Returns a cached DeviceDescriptor if the device is allocated, otherwise returns the current DeviceDescriptor .

Kehrt zurück
DeviceDescriptor

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

Returns a cached DeviceDescriptor if the device is allocated, otherwise returns the current DeviceDescriptor .

Parameter
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

Kehrt zurück
DeviceDescriptor

getChildren

public String[] getChildren (String path)

Alternative to using IFileEntry that sometimes won't work because of permissions.

Parameter
path String : is the path on the device where to do the search

Kehrt zurück
String[] Array of string containing all the file in a path on the device.

Throws
DeviceNotAvailableException

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

Returns the current foldable state of the device or null if some issues occurred.

Kehrt zurück
DeviceFoldableState

Throws
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

Return the id of the current running user. In case of error, return -10000.

Kehrt zurück
int

Throws
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

Get the device class.

Kehrt zurück
String the String device class.

getDeviceDate

public long getDeviceDate ()

Return the date of the device in millisecond since epoch.

Kehrt zurück
long the date of the device in epoch format.

Throws
DeviceNotAvailableException

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor ()

Return a DeviceDescriptor from the device information to get info on it without passing the actual device object.

Kehrt zurück
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.

Parameter
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

Kehrt zurück
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

Get the device's state.

Kehrt zurück
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.

Parameter
date Date

Kehrt zurück
long the difference in milliseconds

Throws
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

Get the stream of emulator stdout and stderr

Kehrt zurück
InputStreamSource emulator output

getEmulatorProcess

public Process getEmulatorProcess ()

Return the Process corresponding to this emulator.

Kehrt zurück
Process the Process or null

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

The log that contains all the executeShellCommand(String) logs.

Kehrt zurück
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

Helper method to determine amount of free space on device external storage.

Kehrt zurück
long the amount of free space in KB

Throws
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.

Kehrt zurück
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 generic getProductType() method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.

Kehrt zurück
String the String product type name or null if it cannot be determined

Throws
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 generic getProductType() method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.

Kehrt zurück
String the String product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootSerialNumber

public String getFastbootSerialNumber ()

Returns the fastboot mode serial number.

Kehrt zurück
String

getFastbootVariable

public String getFastbootVariable (String variableName)

Retrieve the given fastboot variable value from the device.

Parameter
variableName String : the variable name

Kehrt zurück
String the property value or null if it does not exist

Throws
DeviceNotAvailableException

getFastbootVersion

public String getFastbootVersion ()

Returns the version string of the fastboot binary being used. Or null if something goes wrong.

Kehrt zurück
String

getFileEntry

public IFileEntry getFileEntry (String path)

Retrieve a reference to a remote file on device.

Parameter
path String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie both "/system" and "system" syntax is supported)

Kehrt zurück
IFileEntry the IFileEntry or null if file at given path cannot be found

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

Parameter
entry FileListingService.FileEntry : a FileEntry not necessarily root as Ddmlib requires.

Kehrt zurück
IFileEntry a FileEntryWrapper representing the FileEntry.

Throws
DeviceNotAvailableException

getFoldableStates

public  getFoldableStates ()

Returns the list of foldable states on the device. Can be obtained with "cmd device_state print-states".

Kehrt zurück

Throws
DeviceNotAvailableException

getIDevice

public IDevice getIDevice ()

Returns a reference to the associated ddmlib IDevice .

A new 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.

Kehrt zurück
IDevice the IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

Fetch the application package names present on the device.

Kehrt zurück
ERROR(/Set) of String package names currently installed on the device.

Throws
DeviceNotAvailableException

getIntProperty

public long getIntProperty (String name, 
                long defaultValue)

Returns integer value of the given property from the device.

Parameter
name String : the property name

defaultValue long : default value to return if property is empty or doesn't exist.

Kehrt zurück
long the property value or defaultValue if the property is empty, doesn't exist, or doesn't have an integer value.

Throws
DeviceNotAvailableException

getIpAddress

public String getIpAddress ()

Gets the device's IP address.

Kehrt zurück
String the device's IP address, or null if device has no IP address

Throws
DeviceNotAvailableException

getKeyguardState

public KeyguardControllerState getKeyguardState ()

Return an object to get the current state of the keyguard or null if not supported.

Kehrt zurück
KeyguardControllerState a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported.

Throws
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by System.currentTimeMillis() .

Kehrt zurück
long

getLaunchApiLevel

public int getLaunchApiLevel ()

Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL .

Kehrt zurück
int an integer indicating the first launched API Level of device

Throws
DeviceNotAvailableException

getLogcat

public InputStreamSource getLogcat ()

Grabs a snapshot stream of the logcat data.

Works in two modes:

  • If the logcat is currently being captured in the background, will return up to TestDeviceOptions.getMaxLogcatDataSize() bytes of the current contents of the background logcat capture
  • Otherwise, will return a static dump of the logcat data if device is currently responding

    Kehrt zurück
    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.

    Parameter
    maxBytes int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory

    Kehrt zurück
    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.

    Kehrt zurück
    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() .

    Parameter
    date long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s')

    Kehrt zurück
    InputStreamSource

    getMacAddress

    public String getMacAddress ()

    Returns the MAC address of the device, null if it fails to query from the device.

    Kehrt zurück
    String

    getMainlineModuleInfo

    public  getMainlineModuleInfo ()

    Get the information about the mainline modules installed on the device.

    Kehrt zurück
    ERROR(/Set) of String mainline modules currently installed on the device.

    Throws
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

    Get the maximum number of supported simultaneously running users. Defaults to 0.

    Kehrt zurück
    int an integer indicating the number of simultaneously running users

    Throws
    DeviceNotAvailableException

    getMaxNumberOfUsersSupported

    public int getMaxNumberOfUsersSupported ()

    Get the maximum number of supported users. Defaults to 0.

    Kehrt zurück
    int an integer indicating the number of supported users

    Throws
    DeviceNotAvailableException

    getMonitor

    public IDeviceStateMonitor getMonitor ()

    Return the IDeviceStateMonitor associated with device.

    Kehrt zurück
    IDeviceStateMonitor

    getMountPoint

    public String getMountPoint (String mountName)

    Returns a mount point.

    Queries the device directly if the cached info in IDevice is not available.

    TODO: move this behavior to IDevice#getMountPoint(String)

    Parameter
    mountName String : the name of the mount point

    Kehrt zurück
    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.

    Parameter
    mountpoint String

    Kehrt zurück
    ITestDevice.MountPointInfo A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    Throws
    DeviceNotAvailableException

    getMountPointInfo

    public  getMountPointInfo ()

    Returns a parsed version of the information in /proc/mounts on the device

    Kehrt zurück
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    Throws
    DeviceNotAvailableException

    getOptions

    public TestDeviceOptions getOptions ()

    Fetch the test options for the device.

    Kehrt zurück
    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.

    Parameter
    partition String

    Kehrt zurück
    long the amount of free space in KB

    Throws
    DeviceNotAvailableException

    getPrimaryUserId

    public Integer getPrimaryUserId ()

    Returns the primary user id.

    Kehrt zurück
    Integer the userId of the primary user if there is one, and null if there is no primary user.

    Throws
    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.

    Parameter
    processName String : the proces name String.

    Kehrt zurück
    ProcessInfo ProcessInfo of given processName

    Throws
    DeviceNotAvailableException

    getProcessPid

    public String getProcessPid (String process)

    Returns the pid of the service or null if something went wrong.

    Parameter
    process String : The proces name String.

    Kehrt zurück
    String

    Throws
    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.

    Kehrt zurück
    String the String product type name. Will not be null

    Throws
    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.

    Kehrt zurück
    String the String product variant name or null if it cannot be determined

    Throws
    DeviceNotAvailableException

    getProperty

    public String getProperty (String name)

    Retrieve the given property value from the device.

    Parameter
    name String : the property name

    Kehrt zurück
    String the property value or null if it does not exist

    Throws
    DeviceNotAvailableException

    getRecoveryMode

    public ITestDevice.RecoveryMode getRecoveryMode ()

    Get the current recovery mode used for the device.

    Kehrt zurück
    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

    Parameter
    format String : supported PNG, JPEG

    Kehrt zurück
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    Throws
    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'

    Parameter
    displayId long : the display id of the screen to get screenshot from.

    Kehrt zurück
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    Throws
    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.

    Parameter
    format String : supported PNG, JPEG

    rescale boolean : if screenshot should be rescaled to reduce the size of resulting image

    Kehrt zurück
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    Throws
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot ()

    Grabs a screenshot from the device.

    Kehrt zurück
    InputStreamSource a InputStreamSource of the screenshot in png format, or null if the screenshot was not successful.

    Throws
    DeviceNotAvailableException

    getSerialNumber

    public String getSerialNumber ()

    Convenience method to get serial number of this device.

    Kehrt zurück
    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"}

    Parameter
    userId int

    namespace String

    key String

    Kehrt zurück
    String the value associated with the namespace:key of a user. Null if not found.

    Throws
    DeviceNotAvailableException

    getSetting

    public String getSetting (String namespace, 
                    String key)

    See getSetting(int, String, String) and performed on system user.

    Parameter
    namespace String

    key String

    Kehrt zurück
    String

    Throws
    DeviceNotAvailableException

    getSimOperator

    public String getSimOperator ()

    Return the SIM card operator or null if not available or if device is not available.

    Kehrt zurück
    String

    getSimState

    public String getSimState ()

    Return the SIM card state or null if not available or device is not available.

    Kehrt zurück
    String

    getTombstones

    public  getTombstones ()

    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.

    Kehrt zurück
    A list of tombstone files, empty if no tombstone.

    Throws
    DeviceNotAvailableException

    getTotalMemory

    public long getTotalMemory ()

    Returns total physical memory size in bytes or -1 in case of internal error

    Kehrt zurück
    long

    getUninstallablePackageNames

    public  getUninstallablePackageNames ()

    Fetch the application package names that can be uninstalled. This is presently defined as non-system packages, and updated system packages.

    Kehrt zurück
    ERROR(/Set) of uninstallable String package names currently installed on the device.

    Throws
    DeviceNotAvailableException

    getUseFastbootErase

    public boolean getUseFastbootErase ()

    Get whether to use fastboot erase or fastboot format to wipe a partition on the device.

    Kehrt zurück
    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.

    Parameter
    userId int

    Kehrt zurück
    int the flags associated with the userId provided if found, -10000 in any other cases.

    Throws
    DeviceNotAvailableException

    getUserInfos

    public  getUserInfos ()

    Gets the Map of useId to UserInfo on the device. Will throw DeviceRuntimeException if output from device is not as expected.

    Kehrt zurück
    the list of UserInfo objects.

    Throws
    DeviceNotAvailableException

    getUserSerialNumber

    public int getUserSerialNumber (int userId)

    Return the serial number associated to the userId if found, -10000 in any other cases.

    Parameter
    userId int

    Kehrt zurück
    int

    Throws
    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.

    Parameter
    event DeviceEvent

    Kehrt zurück
    IManagedTestDevice.DeviceEventResponse

    hasFeature

    public boolean hasFeature (String feature)

    Check if a feature is available on a device.

    Parameter
    feature String : which format should be "feature: " or " " directly.

    Kehrt zurück
    boolean True if feature is found, false otherwise.

    Throws
    DeviceNotAvailableException

    installPackage

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

    Install an Android package on device.

    Parameter
    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.

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    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.

    Parameter
    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.

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackageForUser

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

    Install an Android package on device for a given user.

    Parameter
    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.

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    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.

    Parameter
    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.

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    isAdbRoot

    public boolean isAdbRoot ()

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    isAdbTcp

    public boolean isAdbTcp ()

    Kehrt zurück
    boolean

    isAppEnumerationSupported

    public boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    Kehrt zurück
    boolean True if app enumeration is supported, false otherwise

    Throws
    DeviceNotAvailableException

    isDeviceEncrypted

    public boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    Kehrt zurück
    boolean true if the device is encrypted.

    Throws
    DeviceNotAvailableException

    isDirectory

    public boolean isDirectory (String path)

    Return True if the path on the device is a directory, false otherwise.

    Parameter
    path String

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    Kehrt zurück
    boolean true if adb root should be enabled on device

    isEncryptionSupported

    public boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    Kehrt zurück
    boolean true if the device supports encryption.

    Throws
    DeviceNotAvailableException

    isExecutable

    public boolean isExecutable (String fullPath)

    Returns True if the file path on the device is an executable file, false otherwise.

    Parameter
    fullPath String

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    isFastbootEnabled

    public boolean isFastbootEnabled ()

    Return if fastboot is available for the device.

    Kehrt zurück
    boolean

    isHeadless

    public boolean isHeadless ()

    Return true if the device is headless (no screen), false otherwise.

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    isMultiUserSupported

    public boolean isMultiUserSupported ()

    Determines if multi user is supported.

    Kehrt zurück
    boolean true if multi user is supported, false otherwise

    Throws
    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.

    Parameter
    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.

    Kehrt zurück
    boolean True if the package is reported as installed. False otherwise.

    Throws
    DeviceNotAvailableException

    isPackageInstalled

    public boolean isPackageInstalled (String packageName)

    Query the device for a given package name to check if it's currently installed or not.

    Parameter
    packageName String

    Kehrt zurück
    boolean True if the package is reported as installed. False otherwise.

    Throws
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public boolean isRuntimePermissionSupported ()

    Check whether platform on device supports runtime permission granting

    Kehrt zurück
    boolean True if runtime permission are supported, false otherwise.

    Throws
    DeviceNotAvailableException

    isStateBootloaderOrFastbootd

    public boolean isStateBootloaderOrFastbootd ()

    Returns true if device is in TestDeviceState#FASTBOOT or TestDeviceState.FASTBOOTD .

    Kehrt zurück
    boolean

    isUserRunning

    public boolean isUserRunning (int userId)

    Check if a given user is running.

    Parameter
    userId int

    Kehrt zurück
    boolean True if the user is running, false in every other cases.

    Throws
    DeviceNotAvailableException

    isUserSecondary

    public boolean isUserSecondary (int userId)

    Return whether the specified user is a secondary user according to it's flags.

    Parameter
    userId int

    Kehrt zurück
    boolean true if the user is secondary, false otherwise.

    Throws
    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.

    Kehrt zurück
    boolean true if wifi is enabled. false if disabled

    Throws
    DeviceNotAvailableException

    listDisplayIds

    public  listDisplayIds ()

    Collect the list of available displays id on the device as reported by "dumpsys SurfaceFlinger".

    Kehrt zurück
    The list of displays. Default always returns the default display 0.

    Throws
    DeviceNotAvailableException

    listUsers

    public  listUsers ()

    Gets the list of users on the device. Will throw DeviceRuntimeException if output from device is not as expected.

    Kehrt zurück
    the list of user ids.

    Throws
    DeviceNotAvailableException

    logAnrs

    public boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    Parameter
    logger ITestLogger : an ITestLogger to log the ANRs.

    Kehrt zurück
    boolean True if the logging was successful, false otherwise.

    Throws
    DeviceNotAvailableException

    logBugreport

    public boolean logBugreport (String dataName, 
                    ITestLogger listener)

    Helper method to take a bugreport and log it to the reporters.

    Parameter
    dataName String : name under which the bugreport will be reported.

    listener ITestLogger : an ITestLogger to log the bugreport.

    Kehrt zurück
    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.

    Parameter
    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.

    Throws
    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.

    Throws
    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.

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

    Throws
    DeviceNotAvailableException

    postInvocationTearDown

    public void postInvocationTearDown (Throwable exception)

    Extra steps for device specific required clean up that will be executed after the invocation is done.

    Parameter
    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.

    Parameter
    info IBuildInfo : The IBuildInfo of the device.

    attributes MultiMap : The attributes stored in the invocation context

    Throws
    DeviceNotAvailableException
    TargetSetupError

    pullDir

    public boolean pullDir (String deviceFilePath, 
                    File localDir)

    Recursively pull directory contents from device.

    Parameter
    deviceFilePath String : the absolute file path of the remote source

    localDir File : the local directory to pull files into

    Kehrt zurück
    boolean true if file was pulled successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    Retrieves a file off device.

    Parameter
    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.

    Kehrt zurück
    boolean true if file was retrieved successfully. false otherwise.

    Throws
    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 .

    Parameter
    remoteFilePath String : the absolute path to file on device.

    userId int : The user id to pull from

    Kehrt zurück
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    Throws
    DeviceNotAvailableException

    pullFile

    public File pullFile (String remoteFilePath)

    Retrieves a file off device, stores it in a local temporary ERROR(/File) , and returns that File .

    Parameter
    remoteFilePath String : the absolute path to file on device.

    Kehrt zurück
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    Throws
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile, 
                    int userId)

    Retrieves a file off device.

    Parameter
    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

    Kehrt zurück
    boolean true if file was retrieved successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFileContents

    public String pullFileContents (String remoteFilePath)

    Retrieves a file off device, and returns the contents.

    Parameter
    remoteFilePath String : the absolute path to file on device.

    Kehrt zurück
    String A String containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    Throws
    DeviceNotAvailableException

    pullFileFromExternal

    public 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 .

    Parameter
    remoteFilePath String : the path to file on device, relative to the device's external storage mountpoint

    Kehrt zurück
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    Throws
    DeviceNotAvailableException

    pushDir

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

    Recursively push directory contents to device while excluding some directories that are filtered.

    Parameter
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    excludedDirectories : Set of excluded directories names that shouldn't be pushed.

    Kehrt zurück
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushDir

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath)

    Recursively push directory contents to device.

    Parameter
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    Kehrt zurück
    boolean true if file was pushed successfully. false otherwise.

    Throws
    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.

    Parameter
    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

    Kehrt zurück
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushFile

    public boolean pushFile (File localFile, 
                    String remoteFilePath)

    Push a file to device. By default using a content provider.

    Parameter
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    Kehrt zurück
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushString

    public boolean pushString (String contents, 
                    String remoteFilePath)

    Push file created from a string to device

    Parameter
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

    Kehrt zurück
    boolean true if string was pushed successfully. false otherwise.

    Throws
    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.

    Parameter
    reason String : a reason for this reboot, or null if no reason is specified.

    Throws
    DeviceNotAvailableException

    reboot

    public void reboot ()

    Reboots the device into adb mode.

    Blocks until device becomes available.

    Throws
    DeviceNotAvailableException

    rebootIntoBootloader

    public void rebootIntoBootloader ()

    Reboots the device into bootloader mode.

    Blocks until device is in bootloader mode.

    Throws
    DeviceNotAvailableException

    rebootIntoFastbootd

    public void rebootIntoFastbootd ()

    Reboots the device into fastbootd mode.

    Blocks until device is in fastbootd mode.

    Throws
    DeviceNotAvailableException

    rebootIntoRecovery

    public void rebootIntoRecovery ()

    Reboots the device into adb recovery mode.

    Blocks until device enters recovery

    Throws
    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

    Throws
    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

    Parameter
    autoReboot boolean : whether to automatically reboot the device after sideload

    Throws
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline ()

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    Throws
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline (String reason)

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    Parameter
    reason String : a reason for this reboot, or null if no reason is specified.

    Throws
    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.

    Throws
    DeviceNotAvailableException

    rebootUserspaceUntilOnline

    public void rebootUserspaceUntilOnline ()

    An alternate to rebootUserspace() ()} that only blocks until device is online ie visible to adb.

    Throws
    DeviceNotAvailableException

    recoverDevice

    public boolean recoverDevice ()

    Attempts to recover device communication.

    Kehrt zurück
    boolean True if recovery attempted and successful, returns False if recovery was skipped

    Throws
    DeviceNotAvailableException if device is no longer available

    remountSystemWritable

    public void remountSystemWritable ()

    Make the system partition on the device writable. May reboot the device.

    Throws
    DeviceNotAvailableException

    remountVendorWritable

    public void remountVendorWritable ()

    Make the vendor partition on the device writable. May reboot the device.

    Throws
    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.

    Parameter
    componentName String : of device admin to be removed.

    userId int : of user that the device admin lives in.

    Kehrt zurück
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    removeOwners

    public void removeOwners ()

    Remove all existing device profile owners with the best effort.

    Throws
    DeviceNotAvailableException

    removeUser

    public boolean removeUser (int userId)

    Remove a given user from the device.

    Parameter
    userId int : of the user to remove

    Kehrt zurück
    boolean true if we were successful in removing the user, false otherwise.

    Throws
    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.

    Parameter
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

    Kehrt zurück
    boolean true if test command completed. false if it failed to complete, but recovery succeeded

    Throws
    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.

    Parameter
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

    Kehrt zurück
    boolean true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded

    Throws
    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.

    Parameter
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    Kehrt zurück
    boolean

    Throws
    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.

    Parameter
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    setConfiguration

    public void setConfiguration (IConfiguration configuration)

    Injects the IConfiguration in use.

    Parameter
    configuration IConfiguration

    setDate

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

    Parameter
    date Date : specify a particular date; will use host date if null

    Throws
    DeviceNotAvailableException

    setDeviceOwner

    public boolean setDeviceOwner (String componentName, 
                    int userId)

    Set a device admin component as device owner in given user.

    Parameter
    componentName String : of device admin to be device owner.

    userId int : of the user that the device owner lives in.

    Kehrt zurück
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    Parameter
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    Parameter
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

    Sets the Process , when this device is an emulator.

    Parameter
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

    Set the fastboot option for the device. Should be set when device is first allocated.

    Parameter
    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.

    Parameter
    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 IDevice

    Parameter
    newDevice IDevice : the IDevice

    setOptions

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    Parameter
    options TestDeviceOptions

    setProperty

    public boolean setProperty (String propKey, 
                    String propValue)

    Sets the given property value on the device. Requires adb root is true.

    Parameter
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    Kehrt zurück
    boolean returns True if the setprop command was successful, False otherwise.

    Throws
    DeviceNotAvailableException

    setRecovery

    public void setRecovery (IDeviceRecovery recovery)

    Set the IDeviceRecovery to use for this device. Should be set when device is first allocated.

    Parameter
    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, etc

    Parameter
    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.

    Parameter
    namespace String

    key String

    value String

    Throws
    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"}

    Parameter
    userId int

    namespace String

    key String

    value String

    Throws
    DeviceNotAvailableException

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

    Set whether to use fastboot erase or fastboot format to wipe a partition on the device.

    Parameter
    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.

    Parameter
    userId int : of the user to start in the background

    Kehrt zurück
    boolean true if the user was successfully started in the background.

    Throws
    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.

    Parameter
    userId int : of the user to start in the background

    waitFlag boolean : will make the command wait until user is started and unlocked.

    Kehrt zurück
    boolean true if the user was successfully started in the background.

    Throws
    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.

    Parameter
    userId int : of the user to stop.

    Kehrt zurück
    boolean true if the user was successfully stopped.

    Throws
    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.

    Parameter
    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.

    Kehrt zurück
    boolean true if the user was successfully stopped.

    Throws
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

    Kehrt zurück
    String the tcp serial number or null if device could not be switched

    Throws
    DeviceNotAvailableException

    switchToAdbUsb

    public boolean switchToAdbUsb ()

    Switch device to adb over usb mode.

    Kehrt zurück
    boolean true if switch was successful, false otherwise.

    Throws
    DeviceNotAvailableException

    switchUser

    public boolean switchUser (int userId)

    Switch to another userId with a default timeout. switchUser(int, long) .

    Parameter
    userId int

    Kehrt zurück
    boolean True if the new userId matches the userId provider. False otherwise.

    Throws
    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.

    Parameter
    userId int

    timeout long : to wait before returning false for switch-user failed.

    Kehrt zurück
    boolean True if the new userId matches the userId provider. False otherwise.

    Throws
    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.

    Parameter
    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

    Kehrt zurück
    boolean true if files were synced successfully. false otherwise.

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

    Kehrt zurück
    Bugreport

    uninstallPackage

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    Parameter
    packageName String : the Android package to uninstall

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    uninstallPackageForUser

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    Uninstall an Android package from device for a given user.

    Parameter
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    Kehrt zurück
    String a String with an error code, or null if success.

    Throws
    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 call postBootSetup() . Therefore, the device might not be fully ready to be tested when this method returns.

    Kehrt zurück
    boolean true if successful or if the device is unencrypted.

    Throws
    DeviceNotAvailableException

    waitForBootComplete

    public boolean waitForBootComplete (long timeOut)

    Blocks until the device's boot complete flag is set.

    Parameter
    timeOut long : time in msecs to wait for the flag to be set

    Kehrt zurück
    boolean true if device's boot complete flag is set within the timeout

    Throws
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable ()

    Waits for the device to be responsive and available for testing. Uses default timeout.

    Kehrt zurück
    boolean True if device is available, False if recovery is disabled and unavailable.

    Throws
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable (long waitTime)

    Waits for the device to be responsive and available for testing.

    Parameter
    waitTime long : the time in ms to wait

    Kehrt zurück
    boolean True if device is available, False if recovery is disabled and unavailable.

    Throws
    DeviceNotAvailableException

    waitForDeviceBootloader

    public void waitForDeviceBootloader ()

    Blocks until device is visible via fastboot. Use default timeout.

    Throws
    DeviceNotAvailableException

    waitForDeviceInRecovery

    public boolean waitForDeviceInRecovery (long waitTime)

    Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery ).

    Parameter
    waitTime long : the time in ms to wait

    Kehrt zurück
    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

    Parameter
    waitTime long : the time in ms to wait

    Kehrt zurück
    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

    Parameter
    waitTime long : the time in ms to wait

    Kehrt zurück
    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. Use waitForDeviceAvailable() instead.

    Throws
    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. Use waitForDeviceAvailable() instead.

    Parameter
    waitTime long : the time in ms to wait

    Throws
    DeviceNotAvailableException

    waitForDeviceShell

    public boolean waitForDeviceShell (long waitTime)

    Waits for device to be responsive to a basic adb shell command.

    Parameter
    waitTime long : the time in ms to wait

    Kehrt zurück
    boolean true if device becomes responsive before waitTime elapses.

    Protected methods

    checkApiLevelAgainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

    Parameter
    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.

    Parameter
    rebootMode NativeDevice.RebootMode : a mode of this reboot.

    reason String : for this reboot.

    Kehrt zurück
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    doAdbReboot

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

    Perform a adb reboot.

    Parameter
    rebootMode NativeDevice.RebootMode : a mode of this reboot.

    reason String : for this reboot.

    Throws
    DeviceNotAvailableException

    ensureRuntimePermissionSupported

    protected void ensureRuntimePermissionSupported ()

    helper method to throw exception if runtime permission isn't supported

    Throws
    DeviceNotAvailableException

    getBugreportInternal

    protected InputStreamSource getBugreportInternal ()

    Kehrt zurück
    InputStreamSource

    getBugreportzInternal

    protected File getBugreportzInternal ()

    Internal Helper method to get the bugreportz zip file as a ERROR(/File) .

    Kehrt zurück
    File

    getRunUtil

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    Kehrt zurück
    IRunUtil

    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.

    Parameter
    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.

    Kehrt zurück
    String A string, possibly null or empty, containing the value of the given property

    Throws
    DeviceNotAvailableException

    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.

    Parameter
    localFile File

    entry IFileEntry

    Kehrt zurück
    boolean

    performDeviceAction

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

    Performs an action on this device. Attempts to recover device and optionally retry command if action fails.

    Parameter
    actionDescription String : a short description of action to be performed. Used for logging purposes only.

    action com.android.tradefed.device.NativeDevice.DeviceAction : the action to be performed

    retryAttempts int : the retry attempts to make for action if it fails but recovery succeeds

    Kehrt zurück
    boolean true if action was performed successfully

    Throws
    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.

    Throws
    DeviceNotAvailableException

    prePostBootSetup

    protected void prePostBootSetup ()

    Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.

    Throws
    DeviceNotAvailableException

    pullFileInternal

    protected boolean pullFileInternal (String remoteFilePath, 
                    File localFile)

    Parameter
    remoteFilePath String

    localFile File

    Kehrt zurück
    boolean

    Throws
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    Set the Clock instance to use.

    Parameter
    clock Clock

    setLogStartDelay

    protected void setLogStartDelay (int delay)

    Sets the time in ms to wait before starting logcat capture for a online device.

    Parameter
    delay int : the delay in ms

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                     envVarMap, 
                    String[] fullCmd)

    Executes a simple fastboot command with environment variables and report the status of the command.

    Parameter
    timeout long

    envVarMap

    fullCmd String

    Kehrt zurück
    CommandResult

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                    String[] fullCmd)

    Executes a simple fastboot command and report the status of the command.

    Parameter
    timeout long

    fullCmd String

    Kehrt zurück
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

    Wait to see the device going unavailable (stop reporting to adb).

    Parameter
    operationDesc String : The name of the operation that is waiting for unavailable.

    time long : The time to wait for unavailable to occur.

    Kehrt zurück
    boolean True if device did become unavailable.