Urządzenie natywne

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver

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


Domyślna implementacja urządzeń z systemem Android ITestDevice Non-full stack.

Streszczenie

Klasy zagnieżdżone

class NativeDevice.AdbAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) do uruchamiania polecenia „adb ....” systemu operacyjnego.

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) do ponownego uruchomienia urządzenia.

Stałe

int INVALID_USER_ID

Wartość zwrócona dla każdego nieprawidłowego/nieznalezionego identyfikatora użytkownika: UserHandle zdefiniował wartość -10000

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

domyślna liczba ponownych prób wykonania polecenia

Pola

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

Konstruktory publiczne

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

Tworzy TestDevice .

Metody publiczne

boolean canSwitchToHeadlessSystemUser ()

Zwraca, czy można przełączyć się na bezgłowego użytkownika SYSTEM.

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Sprawdź, czy funkcja jest obecnie obsługiwana przy minimalnym obsługiwanym poziomie.

boolean checkConnectivity ()

Sprawdź, czy urządzenie ma połączenie z siecią.

boolean clearErrorDialogs ()

Spróbuj odrzucić wszystkie okna dialogowe błędów wyświetlane obecnie w interfejsie urządzenia.

void clearLastConnectedWifiNetwork ()

Czyści ostatnio podłączoną sieć Wi-Fi.

void clearLogcat ()

Usuwa wszelkie zgromadzone dane logcat.

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

Łączy się z siecią Wi-Fi.

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

Łączy się z siecią Wi-Fi.

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

Łączy się z siecią Wi-Fi.f

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

Łączy się z siecią Wi-Fi.

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

Wariant connectToWifiNetwork(String, String) , który łączy się tylko wtedy, gdy urządzenie nie ma obecnie łączności sieciowej.

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

Wariant connectToWifiNetwork(String, String) , który łączy się tylko wtedy, gdy urządzenie nie ma obecnie łączności sieciowej.

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

Utwórz użytkownika o podanej nazwie i dostarczonych flagach

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

Utwórz użytkownika o podanej nazwie i dostarczonych flagach

int createUser (String name)

Utwórz użytkownika o podanej nazwie i domyślnych flagach 0.

int createUserNoThrow (String name)

Utwórz użytkownika o podanej nazwie i domyślnych flagach 0.

void deleteFile (String deviceFilePath)

Metoda pomocnika, aby usunąć plik lub katalog na urządzeniu.

void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

Usuwa zarejestrowany IDeviceActionReceiver .

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

Metoda pomocnika, aby sprawdzić, czy urządzenie zostało ponownie uruchomione, porównując bieżący system_server z poprzednim system_server ProcessInfo .

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

Metoda pomocnika, aby sprawdzić, czy urządzenie zostało ponownie uruchomione miękko od czasu UTC od epoki z urządzenia i jego ERROR(/TimeUnit) .

boolean disableAdbRoot ()

Wyłącza adb root.

void disableKeyguard ()

Próby wyłączenia blokady klawiatury.

boolean disableNetworkMonitor ()

Wyłącza monitorowanie sieci na urządzeniu.

boolean disconnectFromWifi ()

Rozłącza się z siecią Wi-Fi.

boolean doesFileExist (String deviceFilePath, int userId)

Metoda pomocnika w celu określenia, czy plik na urządzeniu istnieje dla danego użytkownika.

boolean doesFileExist (String deviceFilePath)

Metoda pomocnika w celu ustalenia, czy plik na urządzeniu istnieje.

File dumpHeap (String process, String devicePath)

Spróbuj zrzucić stertę z serwera system_server.

boolean enableAdbRoot ()

Włącza adb root.

boolean enableNetworkMonitor ()

Włącza monitorowanie sieci na urządzeniu.

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

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe z określonym limitem czasu.

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

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe z określonym limitem czasu.

String executeAdbCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe.

CommandResult executeFastbootCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje polecenie fastboot jako polecenie systemowe z domyślnym limitem czasu wynoszącym 2 minuty.

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

Metoda pomocnicza, która wykonuje polecenie fastboot jako polecenie systemowe.

CommandResult executeLongFastbootCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje długotrwałe polecenie fastboot jako polecenie systemowe.

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

Metoda pomocnicza, która wykonuje długotrwałe polecenie fastboot jako polecenie systemowe z systemowymi zmiennymi środowiskowymi.

String executeShellCommand (String command)

Metoda pomocnicza, która wykonuje polecenie powłoki adb i zwraca dane wyjściowe jako ERROR(/String) .

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

void executeShellCommand (String command, IShellOutputReceiver receiver)

Wykonuje podane polecenie powłoki adb, ponawiając wiele razy, jeśli polecenie się nie powiedzie.

CommandResult executeShellV2Command (String cmd)

Metoda pomocnicza, która wykonuje polecenie powłoki adb i zwraca wyniki jako CommandResult poprawnie wypełnione danymi wyjściowymi stanu polecenia, stdout i stderr.

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

Metoda pomocnicza, która wykonuje polecenie powłoki adb i zwraca wyniki jako CommandResult poprawnie wypełniony danymi wyjściowymi stanu polecenia i stderr.

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

Metoda pomocnicza, która wykonuje polecenie powłoki adb i zwraca wyniki jako CommandResult poprawnie wypełnione danymi wyjściowymi stanu polecenia, stdout i stderr.

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

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

Wykonuje polecenie powłoki adb, z większą liczbą parametrów do kontrolowania zachowania polecenia.

CommandResult fastbootWipePartition (String partition)

Metoda pomocnicza, która czyści partycję dla urządzenia.

getActiveApexes ()

Pobierz informacje o aktywowanych na urządzeniu APEXach.

getAllSettings (String namespace)

Zwróć pary klucz-wartość żądanej przestrzeni nazw.

DeviceAllocationState getAllocationState ()

Zwróć bieżący stan alokacji urządzenia

String getAndroidId (int userId)

Znajdź i zwróć identyfikator Androida powiązany z identyfikatorem użytkownika, null, jeśli nie został znaleziony.

getAndroidIds ()

Utwórz mapę znalezionych identyfikatorów Androida pasujących do identyfikatorów użytkowników.

int getApiLevel ()

Uzyskaj poziom interfejsu API urządzenia.

PackageInfo getAppPackageInfo (String packageName)

Pobierz informacje o pakiecie zainstalowanym na urządzeniu.

getAppPackageInfos ()

Pobierz informacje o pakietach zainstalowanych na urządzeniu.

String getBasebandVersion ()

Wygodna metoda uzyskania wersji pasma podstawowego (radiowego) tego urządzenia.

Integer getBattery ()

Zwraca bieżący poziom naładowania baterii urządzenia lub wartość Null, jeśli poziom naładowania baterii jest niedostępny.

boolean getBooleanProperty (String name, boolean defaultValue)

Zwraca wartość logiczną podanej właściwości.

getBootHistory ()

Metoda pomocnicza zbiera mapę historii rozruchu z czasem rozruchu i przyczyną rozruchu.

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

Metoda pomocnicza zbiera mapę historii rozruchu z czasem rozruchu i przyczyną rozruchu od podanego czasu od epoki z urządzenia i określonej jednostki czasu.

String getBootloaderVersion ()

Wygodny sposób na uzyskanie wersji bootloadera tego urządzenia.

InputStreamSource getBugreport ()

Pobiera raport o błędzie z urządzenia.

InputStreamSource getBugreportz ()

Pobiera raport o błędzie z urządzenia.

String getBuildAlias ()

Pobierz alias kompilacji, która jest aktualnie uruchomiona na urządzeniu.

String getBuildFlavor ()

Pobierz smak kompilacji dla urządzenia.

String getBuildId ()

Pobierz kompilację aktualnie uruchomioną na urządzeniu.

String getBuildSigningKeys ()

Zwraca typ klucza używany do podpisania obrazu urządzenia

Zazwyczaj urządzenia z Androidem mogą być podpisywane za pomocą kluczy testowych (jak w AOSP) lub kluczy zwalniających (kontrolowanych przez poszczególnych producentów urządzeń)

DeviceDescriptor getCachedDeviceDescriptor ()

Zwraca buforowany DeviceDescriptor jeśli urządzenie jest przydzielone, w przeciwnym razie zwraca bieżący DeviceDescriptor .

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

Zwraca buforowany DeviceDescriptor jeśli urządzenie jest przydzielone, w przeciwnym razie zwraca bieżący DeviceDescriptor .

String[] getChildren (String path)

Alternatywa dla używania IFileEntry , która czasami nie działa z powodu uprawnień.

AbstractConnection getConnection ()

Bieżące połączenie skojarzone z urządzeniem.

DeviceFoldableState getCurrentFoldableState ()

Zwraca bieżący stan składania urządzenia lub wartość null, jeśli wystąpiły problemy.

int getCurrentUser ()

Zwróć identyfikator bieżącego uruchomionego użytkownika.

String getDeviceClass ()

Pobierz klasę urządzenia.

long getDeviceDate ()

Zwróć datę urządzenia w milisekundach od epoki.

DeviceDescriptor getDeviceDescriptor ()

Zwróć DeviceDescriptor z informacji o urządzeniu, aby uzyskać informacje na jego temat bez przekazywania rzeczywistego obiektu urządzenia.

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

Zwróć DeviceDescriptor z informacji o urządzeniu, aby uzyskać informacje na jego temat bez przekazywania rzeczywistego obiektu urządzenia.

TestDeviceState getDeviceState ()

Pobierz stan urządzenia.

long getDeviceTimeOffset (Date date)

Pomocnik, aby uzyskać różnicę czasu między urządzeniem a danym ERROR(/Date) .

InputStreamSource getEmulatorOutput ()

Pobierz strumień emulatora stdout i stderr

Process getEmulatorProcess ()

Zwróć ERROR(/Process) odpowiadający temu emulatorowi.

final File getExecuteShellCommandLog ()

Dziennik zawierający wszystkie dzienniki executeShellCommand(String) .

long getExternalStoreFreeSpace ()

Metoda pomocnicza do określania ilości wolnego miejsca w pamięci zewnętrznej urządzenia.

String getFastbootPath ()

Zwraca ścieżkę używanego pliku binarnego fastboot.

String getFastbootProductType ()

Wygodna metoda uzyskiwania typu produktu tego urządzenia, gdy jest ono w trybie szybkiego uruchamiania.

String getFastbootProductVariant ()

Wygodna metoda uzyskiwania typu produktu tego urządzenia, gdy jest ono w trybie szybkiego uruchamiania.

String getFastbootSerialNumber ()

Zwraca numer seryjny trybu szybkiego uruchamiania.

String getFastbootVariable (String variableName)

Pobierz z urządzenia podaną wartość zmiennej fastboot.

String getFastbootVersion ()

Zwraca ciąg wersji używanego pliku binarnego fastboot.

IFileEntry getFileEntry (String path)

Pobierz odwołanie do zdalnego pliku na urządzeniu.

IFileEntry getFileEntry (FileListingService.FileEntry entry)

Nieoficjalny pomocnik, aby uzyskać FileEntry ze ścieżki innej niż root.

getFoldableStates ()

Zwraca listę składanych stanów na urządzeniu.

IDevice getIDevice ()

Zwraca odwołanie do powiązanego ddmlib IDevice .

getInstalledPackageNames ()

Pobierz nazwy pakietów aplikacji obecnych na urządzeniu.

long getIntProperty (String name, long defaultValue)

Zwraca wartość całkowitą podanej właściwości z urządzenia.

String getIpAddress ()

Pobiera adres IP urządzenia.

KeyguardControllerState getKeyguardState ()

Zwróć obiekt, aby uzyskać aktualny stan blokady klawiatury lub wartość null, jeśli nie jest obsługiwana.

long getLastExpectedRebootTimeMillis ()

Zwraca ostatni raz, kiedy API Tradefed wyzwoliło ponowne uruchomienie w milisekundach od EPOCH, zgodnie z wartością zwróconą przez ERROR(/System#currentTimeMillis()) .

int getLaunchApiLevel ()

Uzyskaj pierwszy uruchomiony poziom API urządzenia.

InputStreamSource getLogcat ()

Przechwytuje strumień migawek danych logcat.

InputStreamSource getLogcat (int maxBytes)

Przechwytuje strumień migawek ostatnich maxBytes przechwyconych danych logcat.

InputStreamSource getLogcatDump ()

Uzyskaj zrzut bieżącego logcata dla urządzenia.

InputStreamSource getLogcatSince (long date)

Przechwytuje strumień migawek przechwyconych danych logcat począwszy od podanej daty.

String getMacAddress ()

Zwraca adres MAC urządzenia, null, jeśli zapytanie z urządzenia nie powiedzie się.

Integer getMainUserId ()

Zwraca główny identyfikator użytkownika.

getMainlineModuleInfo ()

Uzyskaj informacje o głównych modułach zainstalowanych na urządzeniu.

int getMaxNumberOfRunningUsersSupported ()

Uzyskaj maksymalną liczbę obsługiwanych jednocześnie działających użytkowników.

int getMaxNumberOfUsersSupported ()

Uzyskaj maksymalną liczbę obsługiwanych użytkowników.

Process getMicrodroidProcess ()
IDeviceStateMonitor getMonitor ()

Zwróć IDeviceStateMonitor skojarzony z urządzeniem.

String getMountPoint (String mountName)

Zwraca punkt montowania.

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

Zwraca wartość MountPointInfo odpowiadającą podanej ścieżce punktu montowania lub null , jeśli w tej ścieżce nic nie jest zamontowane lub w inny sposób nie pojawia się w /proc/mounts jako punkt montowania.

getMountPointInfo ()

Zwraca przeanalizowaną wersję informacji w /proc/mounts na urządzeniu

TestDeviceOptions getOptions ()

Pobierz opcje testowe dla urządzenia.

long getPartitionFreeSpace (String partition)

Metoda pomocnicza do określania ilości wolnego miejsca na partycji urządzenia.

Integer getPrimaryUserId ()

Zwraca główny identyfikator użytkownika.

ProcessInfo getProcessByName (String processName)

Metoda pomocnicza uruchamia polecenie „pidof” i „stat” i zwraca obiekt ProcessInfo z PID i czasem rozpoczęcia danego procesu.

String getProcessPid (String process)

Zwraca pid usługi lub null, jeśli coś poszło nie tak.

String getProductType ()

Wygodna metoda uzyskania typu produktu tego urządzenia.

String getProductVariant ()

Wygodna metoda uzyskania wariantu produktu tego urządzenia.

String getProperty (String name)

Pobierz daną wartość właściwości z urządzenia.

ITestDevice.RecoveryMode getRecoveryMode ()

Pobierz bieżący tryb odzyskiwania używany dla urządzenia.

InputStreamSource getScreenshot (String format)

Pobiera zrzut ekranu z urządzenia.

InputStreamSource getScreenshot (long displayId)

Przechwytuje zrzut ekranu z urządzenia o podanym identyfikatorze wyświetlacza.

InputStreamSource getScreenshot (String format, boolean rescale)

Pobiera zrzut ekranu z urządzenia.

InputStreamSource getScreenshot ()

Pobiera zrzut ekranu z urządzenia.

String getSerialNumber ()

Wygodna metoda uzyskania numeru seryjnego tego urządzenia.

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

Zwróć wartość żądanego ustawienia.

String getSetting (String namespace, String key)

Zobacz getSetting(int, String, String) i wykonaj na użytkowniku systemowym.

String getSimOperator ()

Zwróć operatora karty SIM lub null, jeśli nie jest dostępny lub urządzenie jest niedostępne.

String getSimState ()

Zwróć stan karty SIM lub null, jeśli nie jest dostępny lub urządzenie jest niedostępne.

getTombstones ()

Pobierz i zwróć listę nagrobków z urządzeń.

long getTotalMemory ()

Zwraca całkowity rozmiar pamięci fizycznej w bajtach lub -1 w przypadku błędu wewnętrznego

getUninstallablePackageNames ()

Pobierz nazwy pakietów aplikacji, które można odinstalować.

boolean getUseFastbootErase ()

Dowiedz się, czy użyć szybkiego kasowania lub formatu szybkiego rozruchu, aby wyczyścić partycję na urządzeniu.

int getUserFlags (int userId)

Znajdź i zwróć flagi danego użytkownika.

getUserInfos ()

Pobiera mapę useId do UserInfo na urządzeniu.

int getUserSerialNumber (int userId)

Zwróć numer seryjny powiązany z identyfikatorem użytkownika, jeśli został znaleziony, -10000 w innych przypadkach.

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

Przetwórz podane DeviceEvent .

Przetwórz zdarzenie DeviceEvent, które może, ale nie musi, przenieść to urządzenie do nowego stanu alokacji.

boolean hasFeature (String feature)

Sprawdź, czy funkcja jest dostępna na urządzeniu.

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

Zainstaluj pakiet Androida na urządzeniu.

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

Zainstaluj pakiet Androida na urządzeniu.

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

Zainstaluj pakiet Android na urządzeniu dla danego użytkownika.

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

Zainstaluj pakiet Android na urządzeniu dla danego użytkownika.

boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

Sprawdź, czy platforma na urządzeniu obsługuje wyliczanie aplikacji

boolean isBypassLowTargetSdkBlockSupported ()

Sprawdź, czy platforma na urządzeniu obsługuje pomijanie niskiego docelowego bloku SDK podczas instalacji aplikacji

boolean isDeviceEncrypted ()

Zwraca, jeśli urządzenie jest zaszyfrowane.

boolean isDirectory (String path)

Zwraca True, jeśli ścieżka na urządzeniu jest katalogiem, w przeciwnym razie zwraca false.

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

Zwraca, jeśli szyfrowanie jest obsługiwane na urządzeniu.

boolean isExecutable (String fullPath)

Zwraca wartość True, jeśli ścieżka pliku na urządzeniu jest plikiem wykonywalnym, w przeciwnym razie zwraca wartość False.

boolean isFastbootEnabled ()

Wróć, jeśli fastboot jest dostępny dla urządzenia.

boolean isHeadless ()

Zwróć wartość true, jeśli urządzenie jest bezgłowe (bez ekranu), w przeciwnym razie zwraca wartość false.

boolean isHeadlessSystemUserMode ()

Zwraca informację, czy urządzenie używa trybu użytkownika systemu bezobsługowego.

boolean isMainUserPermanentAdmin ()

Zwraca informację, czy główny użytkownik jest stałym administratorem i nie może zostać usunięty ani zdegradowany do statusu innego niż administrator.

boolean isMultiUserSupported ()

Określa, czy obsługiwany jest tryb wielu użytkowników.

boolean isPackageInstalled (String packageName, String userId)

Zapytaj urządzenie o daną nazwę pakietu i podany identyfikator użytkownika, aby sprawdzić, czy jest ono aktualnie zainstalowane dla tego użytkownika.

boolean isPackageInstalled (String packageName)

Zapytaj urządzenie o daną nazwę pakietu, aby sprawdzić, czy jest on aktualnie zainstalowany, czy nie.

boolean isRuntimePermissionSupported ()

Sprawdź, czy platforma na urządzeniu obsługuje nadawanie uprawnień w czasie wykonywania

boolean isStateBootloaderOrFastbootd ()

Zwraca wartość true, jeśli urządzenie znajduje się w TestDeviceState#FASTBOOT lub TestDeviceState.FASTBOOTD .

boolean isUserRunning (int userId)

Sprawdź, czy dany użytkownik jest uruchomiony.

boolean isUserSecondary (int userId)

Zwraca, czy określony użytkownik jest użytkownikiem drugorzędnym zgodnie z jego flagami.

boolean isUserVisible (int userId)

Sprawdza, czy dany użytkownik jest widoczny.

boolean isUserVisibleOnDisplay (int userId, int displayId)

Sprawdza, czy dany użytkownik jest widoczny na danym ekranie.

boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

Zwraca, czy urządzenie pozwala na uruchamianie użytkowników widocznych w tle w ERROR(/java.android.view.Display#DEFAULT_DISPLAY) .

boolean isVisibleBackgroundUsersSupported ()

Zwraca, czy urządzenie pozwala na uruchamianie użytkowników widocznych w tle.

boolean isWifiEnabled ()

Sprawdź, czy Wi-Fi jest włączone.

listDisplayIds ()

Zbierz listę dostępnych identyfikatorów wyświetlaczy na urządzeniu, zgłoszoną przez „dumpsys SurfaceFlinger”.

listDisplayIdsForStartingVisibleBackgroundUsers ()

Pobiera listę ekranów, których można użyć do start a user visible in the background .

listUsers ()

Pobiera listę użytkowników na urządzeniu.

boolean logAnrs ( ITestLogger logger)

Zbiera i rejestruje błędy ANR z urządzenia.

boolean logBugreport (String dataName, ITestLogger listener)

Metoda pomocnicza, aby zgłosić błąd i zalogować go do reporterów.

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

Zarejestruj wiadomość w logcat urządzenia.

void nonBlockingReboot ()

Wydaje polecenie ponownego uruchomienia urządzenia i powraca po zakończeniu polecenia i gdy urządzenie nie jest już widoczne dla adb.

void postAdbRootAction ()

Zastąp, jeśli urządzenie wymaga podjęcia określonych działań po adb root i zanim urządzenie wróci do trybu online.

void postAdbUnrootAction ()

Zastąp, jeśli urządzenie wymaga podjęcia określonych działań po adb unroot i zanim urządzenie wróci do trybu online.

void postBootSetup ()

Wykonaj instrukcje, aby skonfigurować urządzenie do testowania po każdym uruchomieniu.

void postInvocationTearDown (Throwable exception)

Dodatkowe kroki związane z wymaganym czyszczeniem urządzenia, które zostaną wykonane po zakończeniu wywołania.

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

Dodatkowe kroki dla wymaganej konfiguracji specyficznej dla urządzenia, które zostaną wykonane na urządzeniu przed przepływem wywołania.

boolean pullDir (String deviceFilePath, File localDir)

Rekursywnie ściągaj zawartość katalogu z urządzenia.

boolean pullFile (String remoteFilePath, File localFile)

Pobiera plik z urządzenia.

File pullFile (String remoteFilePath, int userId)

Pobiera plik z urządzenia, zapisuje go w lokalnym tymczasowym ERROR(/File) i zwraca ten File .

File pullFile (String remoteFilePath)

Pobiera plik z urządzenia, zapisuje go w lokalnym tymczasowym ERROR(/File) i zwraca ten File .

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

Pobiera plik z urządzenia.

String pullFileContents (String remoteFilePath)

Pobiera plik z urządzenia i zwraca zawartość.

File pullFileFromExternal (String remoteFilePath)

Wygodna metoda pobierania pliku z pamięci zewnętrznej urządzenia, zapisywania go w lokalnym tymczasowym ERROR(/File) i zwracania odwołania do tego File .

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

Rekursywnie wypychaj zawartość katalogu do urządzenia, wykluczając niektóre katalogi, które są filtrowane.

boolean pushDir (File localFileDir, String deviceFilePath)

Rekursywnie przesyłaj zawartość katalogu do urządzenia.

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

Wariant pushFile(File, String) , który może opcjonalnie rozważyć ocenę zapotrzebowania na dostawcę zawartości.

boolean pushFile (File localFile, String remoteFilePath)

Prześlij plik do urządzenia.

boolean pushString (String contents, String remoteFilePath)

Prześlij plik utworzony z ciągu znaków na urządzenie

void reboot (String reason)

Ponownie uruchamia urządzenie w trybie adb z podanym reason do utrwalenia podczas ponownego uruchamiania.

void reboot ()

Ponownie uruchamia urządzenie w trybie adb.

void rebootIntoBootloader ()

Ponownie uruchamia urządzenie w trybie programu ładującego.

void rebootIntoFastbootd ()

Ponownie uruchamia urządzenie w trybie fastbootd.

void rebootIntoRecovery ()

Ponownie uruchamia urządzenie w trybie odzyskiwania adb.

void rebootIntoSideload ()

Ponownie uruchamia urządzenie w trybie adb sideload (pamiętaj, że jest to specjalny tryb odzyskiwania)

Blokuje, dopóki urządzenie nie przejdzie w tryb ładowania bocznego

void rebootIntoSideload (boolean autoReboot)

Ponownie uruchamia urządzenie w trybie adb sideload (pamiętaj, że jest to specjalny tryb odzyskiwania)

Blokuje, dopóki urządzenie nie przejdzie w tryb ładowania bocznego

void rebootUntilOnline ()

Alternatywa dla reboot() , która blokuje tylko do momentu, gdy urządzenie jest online, tj. widoczne dla adb.

void rebootUntilOnline (String reason)

Alternatywa dla reboot() , która blokuje tylko do momentu, gdy urządzenie jest online, tj. widoczne dla adb.

void rebootUserspace ()

Restartuje tylko część przestrzeni użytkownika urządzenia.

void rebootUserspaceUntilOnline ()

Alternatywa dla rebootUserspace() ()}, która blokuje tylko do momentu, gdy urządzenie jest online, tj. widoczne dla adb.

boolean recoverDevice ()

Próby odzyskania komunikacji urządzenia.

void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

Rejestruje IDeviceActionReceiver dla tego urządzenia.

void remountSystemWritable ()

Ustaw partycję systemową na urządzeniu z możliwością zapisu.

void remountVendorWritable ()

Ustaw partycję dostawcy na urządzeniu z możliwością zapisu.

boolean removeAdmin (String componentName, int userId)

Usuń danego administratora urządzenia w danym użytkowniku i zwróć true , jeśli się powiedzie, w przeciwnym razie zwróć false .

void removeOwners ()

Jak najlepiej usuń wszystkich istniejących właścicieli profili urządzeń.

boolean removeUser (int userId)

Usuń danego użytkownika z urządzenia.

void resetContentProviderSetup ()

Zresetuj flagę konfiguracji dostawcy treści, aby uruchomić ją ponownie.

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

Wygodna metoda wykonywania ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) z co najmniej jednym odbiornikiem przekazanym jako parametry.

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

Uruchamia testy oprzyrządowania i zapewnia odzyskiwanie urządzeń.

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

To samo co ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) ale uruchamia test dla danego użytkownika.

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

To samo co ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) ale uruchamia test dla danego użytkownika.

void setConfiguration ( IConfiguration configuration)

Wstrzykuje używaną IConfiguration .

void setDate (Date date)

Ustawia datę na urządzeniu

Uwaga: ustawienie daty na urządzeniu wymaga roota

boolean setDeviceOwner (String componentName, int userId)

Ustaw komponent administratora urządzenia jako właściciela urządzenia dla danego użytkownika.

void setDeviceState ( TestDeviceState deviceState)

Zaktualizuj stan urządzenia.

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

Dla emulatora ustaw SizeLimitedOutputStream na dane wyjściowe dziennika

void setEmulatorProcess (Process p)

Ustawia ERROR(/Process) , gdy to urządzenie jest emulatorem.

void setFastbootEnabled (boolean fastbootEnabled)

Ustaw opcję fastboot dla urządzenia.

void setFastbootPath (String fastbootPath)

Ustawia ścieżkę do pliku binarnego fastboot, który powinien być używany.

void setIDevice (IDevice newDevice)

Zaktualizuj IDevice skojarzone z tym ITestDevice.

void setLogStartDelay (int delay)

Ustawia czas oczekiwania w ms przed rozpoczęciem przechwytywania logcat dla urządzenia online.

void setOptions ( TestDeviceOptions options)

Ustaw opcję TestDeviceOptions dla urządzenia

boolean setProperty (String propKey, String propValue)

Ustawia daną wartość właściwości na urządzeniu.

void setRecovery ( IDeviceRecovery recovery)

Ustaw IDeviceRecovery do użycia dla tego urządzenia.

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

Ustaw bieżący tryb odzyskiwania dla urządzenia.

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

Zobacz setSetting(int, String, String, String) i wykonaj na użytkowniku systemowym.

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

Dodaj wartość ustawienia do przestrzeni nazw danego użytkownika.

void setTestLogger ( ITestLogger testLogger)

Wstrzykuje instancję ITestLogger

void setUseFastbootErase (boolean useFastbootErase)

Zdecyduj, czy do wyczyszczenia partycji na urządzeniu chcesz użyć szybkiego kasowania lub formatu szybkiego rozruchu.

void startLogcat ()

Rozpocznij przechwytywanie danych wyjściowych logcat z urządzenia w tle.

boolean startUser (int userId)

Uruchamia danego użytkownika w tle, jeśli jest aktualnie zatrzymany.

boolean startUser (int userId, boolean waitFlag)

Uruchamia danego użytkownika w tle, jeśli jest aktualnie zatrzymany.

boolean startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag)

Uruchamia danego użytkownika w tle, widocznego na danym ekranie (tj. pozwalając użytkownikowi na uruchamianie działań na tym ekranie).

void stopEmulatorOutput ()

Zamknij i usuń dane wyjściowe emulatora.

void stopLogcat ()

Zatrzymaj przechwytywanie danych wyjściowych logcat z urządzenia i odrzuć aktualnie zapisane dane logcat.

boolean stopUser (int userId)

Zatrzymuje danego użytkownika.

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

Zatrzymaj danego użytkownika.

String switchToAdbTcp ()

Przełącz urządzenie w tryb adb-over-tcp.

boolean switchToAdbUsb ()

Przełącz urządzenie w tryb adb przez USB.

boolean switchUser (int userId)

Przełącz się na inny identyfikator użytkownika z domyślnym limitem czasu.

boolean switchUser (int userId, long timeout)

Przełącz się na inny identyfikator użytkownika z podanym limitem czasu jako terminem.

boolean syncFiles (File localFileDir, String deviceFilePath)

Przyrostowo synchronizuje zawartość lokalnego katalogu plików z urządzeniem.

Bugreport takeBugreport ()

Weź raport o błędzie i zwróć go do obiektu Bugreport , aby go obsłużyć.

String uninstallPackage (String packageName)

Odinstaluj pakiet Androida z urządzenia.

String uninstallPackageForUser (String packageName, int userId)

Odinstaluj pakiet Androida z urządzenia dla danego użytkownika.

boolean unlockDevice ()

Odblokowuje urządzenie, jeśli jest ono w stanie zaszyfrowanym.

boolean waitForBootComplete (long timeOut)

Blokuje do momentu ustawienia flagi ukończenia rozruchu urządzenia.

boolean waitForDeviceAvailable ()

Czeka, aż urządzenie zacznie reagować i będzie dostępne do testowania.

boolean waitForDeviceAvailable (long waitTime)

Czeka, aż urządzenie zacznie reagować i będzie dostępne do testowania.

boolean waitForDeviceAvailableInRecoverPath (long waitTime)

Czeka, aż urządzenie zacznie reagować i będzie dostępne bez uwzględniania ścieżki odzyskiwania.

void waitForDeviceBootloader ()

Blokuje, dopóki urządzenie nie będzie widoczne przez fastboot.

boolean waitForDeviceInRecovery (long waitTime)

Blokuje, aby urządzenie znajdowało się w stanie „odzyskiwanie adb” (należy pamiętać, że różni się to od IDeviceRecovery ).

boolean waitForDeviceInSideload (long waitTime)

Blokuje, aby urządzenie znajdowało się w stanie „adb sideload”.

boolean waitForDeviceNotAvailable (long waitTime)

Blokuje, aby urządzenie było niedostępne, tj. Brakujące w adb

void waitForDeviceOnline ()

Blokuje, dopóki urządzenie nie będzie widoczne przez adb.

void waitForDeviceOnline (long waitTime)

Blokuje, dopóki urządzenie nie będzie widoczne przez adb.

boolean waitForDeviceShell (long waitTime)

Czeka, aż urządzenie zareaguje na podstawowe polecenie powłoki adb.

Metody chronione

String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)

Tworzy polecenie systemu operacyjnego dla danej sesji i argumentów polecenia powłoki adb

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

Utwórz RebootDeviceAction , która będzie używana podczas wykonywania akcji ponownego uruchamiania.

IRunUtil createRunUtil ()
void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

Wykonaj ponowne uruchomienie adb.

void ensureRuntimePermissionSupported ()

pomocnika, aby zgłosić wyjątek, jeśli uprawnienie środowiska uruchomieniowego nie jest obsługiwane

int getApiLevelSafe ()
ITestLogger getLogger ()
IRunUtil getRunUtil ()

Pobierz instancję RunUtil do użycia.

void initializeConnection ( IBuildInfo info, MultiMap <String, String> attributes)
String internalGetProperty (String propName, String fastbootVar, String description)

Pobierz właściwość urządzenia, domyślnie z pamięci podręcznej ddmlib i powróć do `adb shell getprop` lub `fastboot getvar` w zależności od tego, czy urządzenie jest w trybie Fastboot, czy nie.

boolean isInRebootCallback ()

Zwraca, czy wywołania zwrotne restartu są aktualnie wykonywane, czy nie.

boolean isNewer (File localFile, IFileEntry entry)

Zwróć wartość true , jeśli plik lokalny jest nowszy niż plik zdalny.

void notifyRebootEnded ()

Powiadamia wszystkie IDeviceActionReceiver o zdarzeniu zakończenia ponownego uruchomienia.

void notifyRebootStarted ()

Powiadamia wszystkie IDeviceActionReceiver o zdarzeniu uruchomienia ponownego uruchomienia.

boolean performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts)

Wykonuje akcję na tym urządzeniu.

void postAdbReboot ()

Możliwe dodatkowe działania, które można wykonać po ponownym uruchomieniu.

void prePostBootSetup ()

Umożliwia każdemu typowi urządzenia (AndroidNativeDevice, TestDevice) zastąpienie tej metody w przypadku określonej konfiguracji po rozruchu.

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

Ustaw instancję Clock do użycia.

void setMicrodroidProcess (Process process)

Oznacza urządzenie testowe jako mikrodroid i ustawia jego CID.

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

Wykonuje proste polecenie fastboot ze zmiennymi środowiskowymi i zgłasza stan polecenia.

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

Wykonuje proste polecenie fastboot i zgłasza stan polecenia.

boolean waitForDeviceNotAvailable (String operationDesc, long time)

Poczekaj, aż urządzenie stanie się niedostępne (przestań raportować do adb).

Stałe

NIEPRAWIDŁOWY IDENTYFIKATOR UŻYTKOWNIKA

public static final int INVALID_USER_ID

Wartość zwrócona dla każdego nieprawidłowego/nieznalezionego identyfikatora użytkownika: UserHandle zdefiniował wartość -10000

Stała wartość: -10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

Stała wartość: 5000 (0x0000000000001388)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

domyślna liczba ponownych prób wykonania polecenia

Stała wartość: 2 (0x00000002)

Pola

SD_CARD

protected static final String SD_CARD

STORAGE_EMULOWANE

protected static final String STORAGE_EMULATED

mOpcje

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

Konstruktory publiczne

Urządzenie natywne

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

Tworzy TestDevice .

Parametry
device IDevice : skojarzony IDevice

stateMonitor IDeviceStateMonitor : mechanizm IDeviceStateMonitor do użycia

allocationMonitor IDeviceMonitor : IDeviceMonitor do informowania o zmianach stanu alokacji. Może być zerowy

Metody publiczne

canSwitchToHeadlessSystemUser

public boolean canSwitchToHeadlessSystemUser ()

Zwraca, czy można przełączyć się na bezgłowego użytkownika SYSTEM.

Zwroty
boolean

Rzuty
DeviceNotAvailableException

checkApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Sprawdź, czy funkcja jest obecnie obsługiwana przy minimalnym obsługiwanym poziomie. Ta metoda uwzględnia funkcje, które nie zostały jeszcze wydane, zanim zostanie podniesiony poziom API.

Parametry
strictMinLevel int : Ścisły minimalny możliwy poziom, który obsługuje tę funkcję.

Zwroty
boolean Prawda, jeśli poziom jest obsługiwany. Fałsz inaczej.

Rzuty
DeviceNotAvailableException

sprawdź Łączność

public boolean checkConnectivity ()

Sprawdź, czy urządzenie ma połączenie z siecią.

Zwroty
boolean true , jeśli urządzenie ma działające połączenie sieciowe, false overover.

Rzuty
DeviceNotAvailableException

wyczyść dialogi błędów

public boolean clearErrorDialogs ()

Spróbuj odrzucić wszystkie okna dialogowe błędów wyświetlane obecnie w interfejsie urządzenia.

Zwroty
boolean true Jeśli żadne okna dialogowe nie były obecne lub okna dialogowe zostały pomyślnie wyczyszczone. false inaczej.

Rzuty
DeviceNotAvailableException

wyczyść ostatnią połączoną sieć Wi-Fi

public void clearLastConnectedWifiNetwork ()

Czyści ostatnio podłączoną sieć Wi-Fi. Należy to wywołać podczas rozpoczynania nowego wywołania, aby uniknąć łączenia się z siecią Wi-Fi używaną w poprzednim teście po ponownym uruchomieniu urządzenia.

wyczyśćLogcat

public void clearLogcat ()

Usuwa wszelkie zgromadzone dane logcat.

Jest to przydatne w przypadkach, gdy chcesz mieć pewność, że ITestDevice#getLogcat() zwróci tylko dane dziennika utworzone po określonym punkcie (na przykład po flashowaniu nowej wersji urządzenia itp.).

połącz z siecią Wi-Fi

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

Łączy się z siecią Wi-Fi.

Włącza Wi-Fi i blokuje do momentu pomyślnego nawiązania połączenia z jedną z sieci Wi-Fi podanych na mapie wifiSsidToPsk. Po nawiązaniu połączenia instancja będzie próbowała przywrócić połączenie po każdym ponownym uruchomieniu, dopóki nie zostanie wywołana ITestDevice#disconnectFromWifi() lub ITestDevice#clearLastConnectedWifiNetwork() .

Parametry
wifiSsidToPsk : mapa identyfikatorów SSID Wi-Fi na hasła.

scanSsid boolean : czy skanować w poszukiwaniu ukrytych identyfikatorów SSID dla tej sieci.

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

połącz z siecią Wi-Fi

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

Łączy się z siecią Wi-Fi.

Włącza Wi-Fi i blokuje, dopóki nie zostanie pomyślnie nawiązane połączenie z określoną siecią Wi-Fi. Po nawiązaniu połączenia instancja będzie próbowała przywrócić połączenie po każdym ponownym uruchomieniu, dopóki nie zostanie wywołana ITestDevice#disconnectFromWifi() lub ITestDevice#clearLastConnectedWifiNetwork() .

Parametry
wifiSsid String : identyfikator SSID Wi-Fi, z którym należy się połączyć

wifiPsk String : hasło PSK lub wartość null, jeśli nie jest zaszyfrowana

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

połącz z siecią Wi-Fi

public boolean connectToWifiNetwork ( wifiSsidToPsk)

Łączy się z siecią Wi-Fi.

Włącza Wi-Fi i blokuje do momentu pomyślnego nawiązania połączenia z jedną z sieci Wi-Fi podanych na mapie wifiSsidToPsk. Po nawiązaniu połączenia instancja będzie próbowała przywrócić połączenie po każdym ponownym uruchomieniu, dopóki nie zostanie wywołana ITestDevice#disconnectFromWifi() lub ITestDevice#clearLastConnectedWifiNetwork()

Parametry
wifiSsidToPsk : mapa identyfikatorów SSID Wi-Fi na hasła.

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

połącz z siecią Wi-Fi

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

Łączy się z siecią Wi-Fi.

Włącza Wi-Fi i blokuje, dopóki nie zostanie pomyślnie nawiązane połączenie z określoną siecią Wi-Fi. Po nawiązaniu połączenia instancja będzie próbowała przywrócić połączenie po każdym ponownym uruchomieniu, dopóki nie zostanie wywołana ITestDevice#disconnectFromWifi() lub ITestDevice#clearLastConnectedWifiNetwork() .

Parametry
wifiSsid String : identyfikator SSID Wi-Fi, z którym należy się połączyć

wifiPsk String : hasło PSK lub wartość null, jeśli nie jest zaszyfrowana

scanSsid boolean : czy skanować w poszukiwaniu ukrytego identyfikatora SSID dla tej sieci.

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

Połącz z siecią Wi-Fi w razie potrzeby

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

Wariant connectToWifiNetwork(String, String) , który łączy się tylko wtedy, gdy urządzenie nie ma obecnie łączności sieciowej.

Parametry
scanSsid boolean : czy skanować w poszukiwaniu ukrytego identyfikatora SSID dla tej sieci

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

Połącz z siecią Wi-Fi w razie potrzeby

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

Wariant connectToWifiNetwork(String, String) , który łączy się tylko wtedy, gdy urządzenie nie ma obecnie łączności sieciowej.

Zwroty
boolean true , jeśli pomyślnie połączono z siecią Wi-Fi. false inaczej

Rzuty
DeviceNotAvailableException

Stwórz użytkownika

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

Utwórz użytkownika o podanej nazwie i dostarczonych flagach

Parametry
name String : użytkownika do utworzenia na urządzeniu

guest boolean : włącz flagę użytkownika --guest podczas tworzenia

ephemeral boolean : włącz flagę użytkownika --ephemeral podczas tworzenia

Zwroty
int identyfikator utworzonego użytkownika

Rzuty
DeviceNotAvailableException

Stwórz użytkownika

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

Utwórz użytkownika o podanej nazwie i dostarczonych flagach

Parametry
name String : użytkownika do utworzenia na urządzeniu

guest boolean : włącz flagę użytkownika --guest podczas tworzenia

ephemeral boolean : włącz flagę użytkownika --ephemeral podczas tworzenia

forTesting boolean : włącz flagę testową --for-testing podczas tworzenia

Zwroty
int identyfikator utworzonego użytkownika

Rzuty
DeviceNotAvailableException

Stwórz użytkownika

public int createUser (String name)

Utwórz użytkownika o podanej nazwie i domyślnych flagach 0.

Parametry
name String : użytkownika do utworzenia na urządzeniu

Zwroty
int liczba całkowita dla utworzonego identyfikatora użytkownika

Rzuty
DeviceNotAvailableException

utwórzUserNoThrow

public int createUserNoThrow (String name)

Utwórz użytkownika o podanej nazwie i domyślnych flagach 0.

Parametry
name String : użytkownika do utworzenia na urządzeniu

Zwroty
int liczba całkowita dla utworzonego identyfikatora użytkownika lub -1 w przypadku błędu.

Rzuty
DeviceNotAvailableException

usunąć plik

public void deleteFile (String deviceFilePath)

Metoda pomocnika, aby usunąć plik lub katalog na urządzeniu.

Parametry
deviceFilePath String : Bezwzględna ścieżka do pliku na urządzeniu.

Rzuty
DeviceNotAvailableException

wyrejestruj urządzenieDeviceActionReceiver

public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

Usuwa zarejestrowany IDeviceActionReceiver .

Parametry
deviceActionReceiver IDeviceActionReceiver : IDeviceActionReceiver , który zostanie usunięty.

Urządzenie zostało ponownie uruchomione

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

Metoda pomocnika, aby sprawdzić, czy urządzenie zostało ponownie uruchomione, porównując bieżący system_server z poprzednim system_server ProcessInfo . Użyj getProcessByName(String) , aby uzyskać ProcessInfo .

Parametry
prevSystemServerProcess ProcessInfo : poprzedni proces system_server ProcessInfo .

Zwroty
boolean true Jeśli urządzenie zostało ponownie uruchomione

Rzuty
DeviceNotAvailableException

deviceSoftRestartedSince

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

Metoda pomocnika, aby sprawdzić, czy urządzenie zostało ponownie uruchomione miękko od czasu UTC od epoki z urządzenia i jego ERROR(/TimeUnit) . Soft-Restart odnosi się do serwera system_server uruchomionego ponownie poza twardym ponownym uruchomieniem urządzenia (na przykład: wymagane ponowne uruchomienie). Bieżące urządzenie utcEpochTime w milisekundach można uzyskać za pomocą metody getDeviceDate() .

Parametry
utcEpochTime long : czas urządzenia w sekundach od epoki.

timeUnit TimeUnit : jednostka czasu TimeUnit dla danego utcEpochTime.

Zwroty
boolean true Jeśli urządzenie zostało ponownie uruchomione

Rzuty
DeviceNotAvailableException

wyłącz AdbRoot

public boolean disableAdbRoot ()

Wyłącza adb root.

Wyłączenie adb root może spowodować rozłączenie urządzenia z adb. Ta metoda będzie blokować, dopóki urządzenie nie będzie dostępne.

Zwroty
boolean true jeśli się powiedzie.

Rzuty
DeviceNotAvailableException

wyłącz ochronę klawiatury

public void disableKeyguard ()

Próby wyłączenia blokady klawiatury.

Najpierw poczekaj, aż wysyłka danych wejściowych będzie gotowa, dzieje się to mniej więcej w tym samym czasie, gdy urządzenie zgłasza BOOT_COMPLETE, najwyraźniej asynchronicznie, ponieważ obecna implementacja frameworka ma sporadyczne warunki wyścigu. Następnie wysyłane jest polecenie usunięcia blokady klawiatury (działa tylko na niezabezpieczonych)

Rzuty
DeviceNotAvailableException

wyłączMonitor sieci

public boolean disableNetworkMonitor ()

Wyłącza monitorowanie sieci na urządzeniu.

Zwroty
boolean true Jeśli monitorowanie zostało pomyślnie wyłączone. false , jeśli się nie powiodło.

Rzuty
DeviceNotAvailableException

odłącz od Wi-Fi

public boolean disconnectFromWifi ()

Rozłącza się z siecią Wi-Fi.

Usuwa wszystkie sieci z listy znanych sieci i wyłącza Wi-Fi.

Zwroty
boolean true , jeśli pomyślnie odłączono od sieci Wi-Fi. false , jeśli rozłączenie nie powiodło się.

Rzuty
DeviceNotAvailableException

czyPlikIstnieje

public boolean doesFileExist (String deviceFilePath, 
                int userId)

Metoda pomocnika w celu określenia, czy plik na urządzeniu istnieje dla danego użytkownika.

Parametry
deviceFilePath String : bezwzględna ścieżka do pliku na urządzeniu do sprawdzenia

userId int : Identyfikator użytkownika, względem którego należy sprawdzić istnienie pliku

Zwroty
boolean true , jeśli plik istnieje, false w przeciwnym razie.

Rzuty
DeviceNotAvailableException

czyPlikIstnieje

public boolean doesFileExist (String deviceFilePath)

Metoda pomocnika w celu ustalenia, czy plik na urządzeniu istnieje.

Parametry
deviceFilePath String : bezwzględna ścieżka do pliku na urządzeniu do sprawdzenia

Zwroty
boolean true , jeśli plik istnieje, false w przeciwnym razie.

Rzuty
DeviceNotAvailableException

sterta zrzutu

public File dumpHeap (String process, 
                String devicePath)

Spróbuj zrzucić stertę z serwera system_server. Wyczyszczenie zrzuconego pliku jest obowiązkiem dzwoniącego.

Parametry
process String : nazwa procesu urządzenia, na którym ma zostać zrzut.

devicePath String : ścieżka na urządzeniu, gdzie umieścić zrzut. Musi to być lokalizacja, w której zezwalają na to uprawnienia.

Zwroty
File ERROR(/File) zawierający raport. Null, jeśli coś się nie powiedzie.

Rzuty
DeviceNotAvailableException

włączAdbRoot

public boolean enableAdbRoot ()

Włącza adb root. Jeśli ustawienie „enable-root” ma wartość „false”, zarejestruje komunikat i zwróci bez włączania roota.

Włączenie adb root może spowodować rozłączenie urządzenia z adb. Ta metoda będzie blokować, dopóki urządzenie nie będzie dostępne.

Zwroty
boolean true jeśli się powiedzie.

Rzuty
DeviceNotAvailableException

włączMonitor sieci

public boolean enableNetworkMonitor ()

Włącza monitorowanie sieci na urządzeniu.

Zwroty
boolean true Jeśli monitorowanie zostało pomyślnie włączone. false , jeśli się nie powiodło.

Rzuty
DeviceNotAvailableException

wykonaćAdbCommand

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

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe z określonym limitem czasu.

executeShellCommand(String) powinno być używane zamiast tego, gdy tylko jest to możliwe, ponieważ ta metoda zapewnia lepsze wykrywanie awarii i lepszą wydajność.

Parametry
timeout long : czas w milisekundach, zanim urządzenie zostanie uznane za niereagujące, 0L oznacza brak limitu czasu

cmdArgs String : polecenie adb i argumenty do uruchomienia

Zwroty
String standardowe wyjście z polecenia. null , jeśli wykonanie polecenia nie powiodło się.

Rzuty
DeviceNotAvailableException

wykonaćAdbCommand

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

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe z określonym limitem czasu.

executeShellCommand(String) powinno być używane zamiast tego, gdy tylko jest to możliwe, ponieważ ta metoda zapewnia lepsze wykrywanie awarii i lepszą wydajność.

Parametry
timeout long : czas w milisekundach, zanim urządzenie zostanie uznane za niereagujące, 0L oznacza brak limitu czasu

envMap : środowisko do ustawienia dla polecenia

cmdArgs String : polecenie adb i argumenty do uruchomienia

Zwroty
String standardowe wyjście z polecenia. null , jeśli wykonanie polecenia nie powiodło się.

Rzuty
DeviceNotAvailableException

wykonaćAdbCommand

public String executeAdbCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje polecenie adb jako polecenie systemowe.

executeShellCommand(String) powinno być używane zamiast tego, gdy tylko jest to możliwe, ponieważ ta metoda zapewnia lepsze wykrywanie awarii i lepszą wydajność.

Parametry
cmdArgs String : polecenie adb i argumenty do uruchomienia

Zwroty
String standardowe wyjście z polecenia. null , jeśli wykonanie polecenia nie powiodło się.

Rzuty
DeviceNotAvailableException

wykonaj polecenie Fastboot

public CommandResult executeFastbootCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje polecenie fastboot jako polecenie systemowe z domyślnym limitem czasu wynoszącym 2 minuty.

Oczekuje się, że będzie używany, gdy urządzenie jest już w trybie szybkiego uruchamiania.

Parametry
cmdArgs String : polecenie fastboot i argumenty do uruchomienia

Zwroty
CommandResult CommandResult zawierający dane wyjściowe polecenia

Rzuty
DeviceNotAvailableException

wykonaj polecenie Fastboot

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

Metoda pomocnicza, która wykonuje polecenie fastboot jako polecenie systemowe.

Oczekuje się, że będzie używany, gdy urządzenie jest już w trybie szybkiego uruchamiania.

Parametry
timeout long : czas w milisekundach przed wygaśnięciem polecenia

cmdArgs String : polecenie fastboot i argumenty do uruchomienia

Zwroty
CommandResult CommandResult zawierający dane wyjściowe polecenia

Rzuty
DeviceNotAvailableException

wykonaj polecenie LongFastboot

public CommandResult executeLongFastbootCommand (String... cmdArgs)

Metoda pomocnicza, która wykonuje długotrwałe polecenie fastboot jako polecenie systemowe.

Identyczne z executeFastbootCommand(String) z wyjątkiem tego, że używa dłuższego limitu czasu.

Parametry
cmdArgs String : polecenie fastboot i argumenty do uruchomienia

Zwroty
CommandResult CommandResult zawierający dane wyjściowe polecenia

Rzuty
DeviceNotAvailableException

wykonaj polecenie LongFastboot

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

Metoda pomocnicza, która wykonuje długotrwałe polecenie fastboot jako polecenie systemowe z systemowymi zmiennymi środowiskowymi.

Identyczne z executeFastbootCommand(String) z wyjątkiem tego, że używa dłuższego limitu czasu.

Parametry
envVarMap : systemowe zmienne środowiskowe, z którymi uruchamiane jest polecenie fastboot

cmdArgs String : polecenie fastboot i argumenty do uruchomienia

Zwroty
CommandResult CommandResult zawierający dane wyjściowe polecenia

Rzuty
DeviceNotAvailableException

wykonaj polecenie powłoki

public String executeShellCommand (String command)

Helper method which executes a adb shell command and returns output as a ERROR(/String) .

Parametry
command String : the adb shell command to run

Zwroty
String the shell output

Throws
DeviceNotAvailableException

executeShellCommand

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

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

Parametry
command String : the adb shell command to run

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

maxTimeToOutputShellResponse long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

Throws
DeviceNotAvailableException

executeShellCommand

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

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

Parametry
command String : the adb shell command to run

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

maxTimeToOutputShellResponse long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

Throws
DeviceNotAvailableException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

Executes the given adb shell command, retrying multiple times if command fails.

A simpler form of executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int) with default values.

Parametry
command String : the adb shell command to run

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

Throws
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd)

Helper method which executes a adb shell command and returns the results as a CommandResult properly populated with the command status output, stdout and stderr.

Parametry
cmd String : The command that should be run.

Zwroty
CommandResult The result in CommandResult .

Throws
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

Helper method which executes an adb shell command and returns the results as a CommandResult properly populated with the command status output and stderr. stdout is directed to the specified stream.

Parametry
cmd String : The command that should be run.

pipeToOutput OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null.

Zwroty
CommandResult The result in CommandResult .

Throws
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

Helper method which executes an adb shell command and returns the results as a CommandResult properly populated with the command status output, stdout and stderr.

Parametry
cmd String : The command that should be run.

pipeAsInput File : A ERROR(/File) that will be piped as input to the command, or null.

Zwroty
CommandResult The result in CommandResult .

Throws
DeviceNotAvailableException

executeShellV2Command

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

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

Parametry
cmd String : the adb shell command to run

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

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

Parametry
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

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

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

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

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

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

Parametry
partition String : the partition to wipe

Zwroty
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Fetch the information about APEXes activated on the device.

Zwroty
ERROR(/Set) of ApexInfo currently activated on the device

Throws
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Return key value pairs of requested namespace.

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

Zwroty
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

Zwroty
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

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

Parametry
userId int

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

Zwroty
Map of android ids found matching user ids.

Throws
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

Get the device API Level. Defaults to UNKNOWN_API_LEVEL .

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

Parametry
packageName String

Zwroty
PackageInfo the PackageInfo or null if information could not be retrieved

Throws
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Fetch information of packages installed on the device.

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

Zwroty
String the ERROR(/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.

Zwroty
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

Returns boolean value of the given property.

Parametry
name String : the property name

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

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

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

Parametry
utcEpochTime long : the device time since Epoch.

timeUnit TimeUnit : the time unit TimeUnit .

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

Zwroty
String the ERROR(/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).

Zwroty
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

Zwroty
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

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

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

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

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

Zwroty
DeviceDescriptor

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

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

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

Zwroty
DeviceDescriptor

getChildren

public String[] getChildren (String path)

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

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

Zwroty
String[] Array of string containing all the file in a path on the device.

Throws
DeviceNotAvailableException

getConnection

public AbstractConnection getConnection ()

The current connection associated with the device.

Zwroty
AbstractConnection

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

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

Zwroty
DeviceFoldableState

Throws
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

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

Zwroty
int

Throws
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

Get the device class.

Zwroty
String the ERROR(/String) device class.

getDeviceDate

public long getDeviceDate ()

Return the date of the device in millisecond since epoch.

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

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

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

Zwroty
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

Get the device's state.

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

Parametry
date Date

Zwroty
long the difference in milliseconds

Throws
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

Get the stream of emulator stdout and stderr

Zwroty
InputStreamSource emulator output

getEmulatorProcess

public Process getEmulatorProcess ()

Return the ERROR(/Process) corresponding to this emulator.

Zwroty
Process the ERROR(/Process) or null

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

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

Zwroty
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

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

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

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

Zwroty
String the ERROR(/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.

Zwroty
String the ERROR(/String) product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootSerialNumber

public String getFastbootSerialNumber ()

Returns the fastboot mode serial number.

Zwroty
String

getFastbootVariable

public String getFastbootVariable (String variableName)

Retrieve the given fastboot variable value from the device.

Parametry
variableName String : the variable name

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

Zwroty
String

getFileEntry

public IFileEntry getFileEntry (String path)

Retrieve a reference to a remote file on device.

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

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

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

Zwroty
IFileEntry a FileEntryWrapper representing the FileEntry.

Throws
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getFoldableStates

public  getFoldableStates ()

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

Zwroty

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.

Zwroty
IDevice the IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

Fetch the application package names present on the device.

Zwroty
ERROR(/Set) of ERROR(/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.

Parametry
name String : the property name

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

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

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

Zwroty
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 ERROR(/System#currentTimeMillis()) .

Zwroty
long

getLaunchApiLevel

public int getLaunchApiLevel ()

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

Zwroty
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

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

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

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

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

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

    Zwroty
    InputStreamSource

    getMacAddress

    public String getMacAddress ()

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

    Zwroty
    String

    getMainUserId

    public Integer getMainUserId ()

    Returns the main user id.

    Zwroty
    Integer the userId of the main user if there is one, and null if there is no main user.

    Throws
    DeviceNotAvailableException

    getMainlineModuleInfo

    public  getMainlineModuleInfo ()

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

    Zwroty
    ERROR(/Set) of ERROR(/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.

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

    Zwroty
    int an integer indicating the number of supported users

    Throws
    DeviceNotAvailableException

    getMicrodroidProcess

    public Process getMicrodroidProcess ()

    Zwroty
    Process Returns the Process of the Microdroid VM. If TestDevice is not a Microdroid, returns null.

    getMonitor

    public IDeviceStateMonitor getMonitor ()

    Return the IDeviceStateMonitor associated with device.

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

    Parametry
    mountName String : the name of the mount point

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

    Parametry
    mountpoint String

    Zwroty
    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

    Zwroty
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    Throws
    DeviceNotAvailableException

    getOptions

    public TestDeviceOptions getOptions ()

    Fetch the test options for the device.

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

    Parametry
    partition String

    Zwroty
    long the amount of free space in KB

    Throws
    DeviceNotAvailableException

    getPrimaryUserId

    public Integer getPrimaryUserId ()

    Returns the primary user id.

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

    Parametry
    processName String : the proces name String.

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

    Parametry
    process String : The proces name String.

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

    Zwroty
    String the ERROR(/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.

    Zwroty
    String the ERROR(/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.

    Parametry
    name String : the property name

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

    Zwroty
    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

    Parametry
    format String : supported PNG, JPEG

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

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

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

    Parametry
    format String : supported PNG, JPEG

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

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

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

    Zwroty
    String the ERROR(/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"}

    Parametry
    userId int

    namespace String

    key String

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

    Parametry
    namespace String

    key String

    Zwroty
    String

    Throws
    DeviceNotAvailableException

    getSimOperator

    public String getSimOperator ()

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

    Zwroty
    String

    getSimState

    public String getSimState ()

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

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

    Zwroty
    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

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

    Zwroty
    ERROR(/Set) of uninstallable ERROR(/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.

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

    Parametry
    userId int

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

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

    Parametry
    userId int

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

    Parametry
    event DeviceEvent

    Zwroty
    IManagedTestDevice.DeviceEventResponse

    hasFeature

    public boolean hasFeature (String feature)

    Check if a feature is available on a device.

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

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

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

    Zwroty
    String a ERROR(/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.

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

    Zwroty
    String a ERROR(/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.

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

    Zwroty
    String a ERROR(/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.

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

    Zwroty
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    isAdbRoot

    public boolean isAdbRoot ()

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isAdbTcp

    public boolean isAdbTcp ()

    Zwroty
    boolean

    isAppEnumerationSupported

    public boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    Zwroty
    boolean True if app enumeration is supported, false otherwise

    Throws
    DeviceNotAvailableException

    isBypassLowTargetSdkBlockSupported

    public boolean isBypassLowTargetSdkBlockSupported ()

    Check whether platform on device supports bypassing low target sdk block on app installs

    Zwroty
    boolean True if bypass low target sdk block is supported, false otherwise

    Throws
    DeviceNotAvailableException

    isDeviceEncrypted

    public boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

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

    Parametry
    path String

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    Zwroty
    boolean true if adb root should be enabled on device

    isEncryptionSupported

    public boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

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

    Parametry
    fullPath String

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isFastbootEnabled

    public boolean isFastbootEnabled ()

    Return if fastboot is available for the device.

    Zwroty
    boolean

    isHeadless

    public boolean isHeadless ()

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

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isHeadlessSystemUserMode

    public boolean isHeadlessSystemUserMode ()

    Returns whether the device uses headless system user mode.

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isMainUserPermanentAdmin

    public boolean isMainUserPermanentAdmin ()

    Returns whether the main user is a permanent admin and can't be deleted or downgraded to non-admin status.

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isMultiUserSupported

    public boolean isMultiUserSupported ()

    Determines if multi user is supported.

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

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

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

    Parametry
    packageName String

    Zwroty
    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

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

    Zwroty
    boolean

    isUserRunning

    public boolean isUserRunning (int userId)

    Check if a given user is running.

    Parametry
    userId int

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

    Parametry
    userId int

    Zwroty
    boolean true if the user is secondary, false otherwise.

    Throws
    DeviceNotAvailableException

    isUserVisible

    public boolean isUserVisible (int userId)

    Checks if the given user is visible.

    A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities (typically in the default display).

    Parametry
    userId int

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isUserVisibleOnDisplay

    public boolean isUserVisibleOnDisplay (int userId, 
                    int displayId)

    Checks if the given user is visible in the given display.

    A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities in that display.

    Parametry
    userId int

    displayId int

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isVisibleBackgroundUsersOnDefaultDisplaySupported

    public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

    Returns whether the device allow users to be started visible in the background in the ERROR(/java.android.view.Display#DEFAULT_DISPLAY) .

    If it does, you could call startVisibleBackgroundUser(int, int, boolean) , passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers() (which should include ERROR(/java.android.view.Display#DEFAULT_DISPLAY) ).

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    isVisibleBackgroundUsersSupported

    public boolean isVisibleBackgroundUsersSupported ()

    Returns whether the device allow users to be started visible in the background.

    If it does, you could call startVisibleBackgroundUser(int, int, boolean) , passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers() .

    Zwroty
    boolean

    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.

    Zwroty
    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".

    Zwroty
    The list of displays. Default always returns the default display 0.

    Throws
    DeviceNotAvailableException

    listDisplayIdsForStartingVisibleBackgroundUsers

    public  listDisplayIdsForStartingVisibleBackgroundUsers ()

    Gets the list of displays that can be used to start a user visible in the background .

    Zwroty

    Throws
    DeviceNotAvailableException

    listUsers

    public  listUsers ()

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

    Zwroty
    the list of user ids.

    Throws
    DeviceNotAvailableException

    logAnrs

    public boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    Parametry
    logger ITestLogger : an ITestLogger to log the ANRs.

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

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

    listener ITestLogger : an ITestLogger to log the bugreport.

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

    Parametry
    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
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    postAdbUnrootAction

    public void postAdbUnrootAction ()

    Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. Default implementation doesn't include any additional actions. adb root is not guaranteed to be disabled at this stage.

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    postBootSetup

    public void postBootSetup ()

    Perform instructions to configure device for testing that after every boot.

    Should be called after device is fully booted/available

    In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot.

    Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)

    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.

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

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

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

    localDir File : the local directory to pull files into

    Zwroty
    boolean true if file was pulled successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    Retrieves a file off device.

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

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

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

    userId int : The user id to pull from

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

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

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

    Parametry
    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

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

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

    Zwroty
    String A ERROR(/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 .

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

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

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

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

    Parametry
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

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

    Parametry
    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

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

    Parametry
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    Zwroty
    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

    Parametry
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

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

    Parametry
    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

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

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

    Zwroty
    boolean True if recovery attempted and successful, returns False if recovery was skipped

    Throws
    DeviceNotAvailableException if device is no longer available

    registerDeviceActionReceiver

    public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

    Registers a IDeviceActionReceiver for this device.

    All registered IDeviceActionReceiver s will be notified before a device action starts and after the device action ends.

    Parametry
    deviceActionReceiver IDeviceActionReceiver : A IDeviceActionReceiver which will be registered.

    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.

    Parametry
    componentName String : of device admin to be removed.

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

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

    Parametry
    userId int : of the user to remove

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

    Parametry
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

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

    Parametry
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

    Zwroty
    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, 
                     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.

    Parametry
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    Zwroty
    boolean

    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.

    Parametry
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    setConfiguration

    public void setConfiguration (IConfiguration configuration)

    Injects the IConfiguration in use.

    Parametry
    configuration IConfiguration

    setDate

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

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

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

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

    Zwroty
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    Parametry
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    Parametry
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

    Sets the ERROR(/Process) , when this device is an emulator.

    Parametry
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

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

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

    Parametry
    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

    Parametry
    newDevice IDevice : the IDevice

    setLogStartDelay

    public void setLogStartDelay (int delay)

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

    Parametry
    delay int : the delay in ms

    setOptions

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    Parametry
    options TestDeviceOptions

    setProperty

    public boolean setProperty (String propKey, 
                    String propValue)

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

    Parametry
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

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

    Parametry
    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

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

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

    Parametry
    userId int

    namespace String

    key String

    value String

    Throws
    DeviceNotAvailableException

    setTestLogger

    public void setTestLogger (ITestLogger testLogger)

    Injects the ITestLogger instance

    Parametry
    testLogger ITestLogger

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

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

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

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

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

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

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

    Zwroty
    boolean true if the user was successfully started in the background.

    Throws
    DeviceNotAvailableException

    startVisibleBackgroundUser

    public boolean startVisibleBackgroundUser (int userId, 
                    int displayId, 
                    boolean waitFlag)

    Starts a given user in the background, visible in the given display (ie, allowing the user to launch activities in that display).

    NOTE: this command doesn't check if the user exists, display is available, device supports such feature , etc.

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

    displayId int : display to start user visible on

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

    Zwroty
    boolean true if the user was successfully started visible 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.

    Parametry
    userId int : of the user to stop.

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

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

    Zwroty
    boolean true if the user was successfully stopped.

    Throws
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

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

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

    Parametry
    userId int

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

    Parametry
    userId int

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

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

    Parametry
    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

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

    Zwroty
    Bugreport

    uninstallPackage

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    Parametry
    packageName String : the Android package to uninstall

    Zwroty
    String a ERROR(/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.

    Parametry
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    Zwroty
    String a ERROR(/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.

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

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

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

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

    Parametry
    waitTime long : the time in ms to wait

    Zwroty
    boolean True if device is available, False if recovery is disabled and unavailable.

    Throws
    DeviceNotAvailableException

    waitForDeviceAvailableInRecoverPath

    public boolean waitForDeviceAvailableInRecoverPath (long waitTime)

    Waits for the device to be responsive and available without considering recovery path.

    Parametry
    waitTime long

    Zwroty
    boolean True if device is available, False if 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 ).

    Parametry
    waitTime long : the time in ms to wait

    Zwroty
    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

    Parametry
    waitTime long : the time in ms to wait

    Zwroty
    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

    Parametry
    waitTime long : the time in ms to wait

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

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

    Parametry
    waitTime long : the time in ms to wait

    Zwroty
    boolean true if device becomes responsive before waitTime elapses.

    Protected methods

    buildAdbShellCommand

    protected String[] buildAdbShellCommand (String command, 
                    boolean forceExitStatusDetection)

    Builds the OS command for the given adb shell command session and args

    Parametry
    command String

    forceExitStatusDetection boolean

    Zwroty
    String[]

    checkApiLevelAgainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

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

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

    reason String : for this reboot.

    Zwroty
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    createRunUtil

    protected IRunUtil createRunUtil ()

    Zwroty
    IRunUtil

    doAdbReboot

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

    Perform a adb reboot.

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

    reason String : for this reboot.

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    ensureRuntimePermissionSupported

    protected void ensureRuntimePermissionSupported ()

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

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    getApiLevelSafe

    protected int getApiLevelSafe ()

    Zwroty
    int

    getLogger

    protected ITestLogger getLogger ()

    Zwroty
    ITestLogger

    getRunUtil

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    Zwroty
    IRunUtil

    initializeConnection

    protected void initializeConnection (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    Parametry
    info IBuildInfo

    attributes MultiMap

    Throws
    DeviceNotAvailableException
    TargetSetupError

    internalGetProperty

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

    Fetch a device property, from the ddmlib cache by default, and falling back to either `adb shell getprop` or `fastboot getvar` depending on whether the device is in Fastboot or not.

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

    Zwroty
    String A string, possibly null or empty, containing the value of the given property

    Throws
    DeviceNotAvailableException

    isInRebootCallback

    protected boolean isInRebootCallback ()

    Returns whether reboot callbacks is currently being executed or not. All public api's for reboot should be disabled if true.

    Zwroty
    boolean

    isNewer

    protected boolean isNewer (File localFile, 
                    IFileEntry entry)

    Return true if local file is newer than remote file. IFileEntry being accurate to the minute, in case of equal times, the file will be considered newer.

    Parametry
    localFile File

    entry IFileEntry

    Zwroty
    boolean

    notifyRebootEnded

    protected void notifyRebootEnded ()

    Notifies all IDeviceActionReceiver about reboot end event.

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    notifyRebootStarted

    protected void notifyRebootStarted ()

    Notifies all IDeviceActionReceiver about reboot start event.

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    performDeviceAction

    protected boolean performDeviceAction (String actionDescription, 
                    NativeDevice.DeviceAction action, 
                    int retryAttempts)

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

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

    action NativeDevice.DeviceAction : the action to be performed

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

    Zwroty
    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
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    prePostBootSetup

    protected void prePostBootSetup ()

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

    Throws
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    pullFileInternal

    protected boolean pullFileInternal (String remoteFilePath, 
                    File localFile)

    Parametry
    remoteFilePath String

    localFile File

    Zwroty
    boolean

    Throws
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    Set the Clock instance to use.

    Parametry
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    Marks the TestDevice as microdroid and sets its CID.

    Parametry
    process Process : Process of the Microdroid VM.

    setTestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

    Parametry
    deviceOptions

    simpleFastbootCommand

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

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

    Parametry
    timeout long

    envVarMap

    fullCmd String

    Zwroty
    CommandResult

    simpleFastbootCommand

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

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

    Parametry
    timeout long

    fullCmd String

    Zwroty
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

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

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

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

    Zwroty
    boolean True if device did become unavailable.