Perangkat asli

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver

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


Implementasi default perangkat android ITestDevice Non-full stack.

Ringkasan

Kelas bersarang

class NativeDevice.AdbAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) untuk menjalankan perintah OS 'adb ....'.

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) untuk me-reboot perangkat.

Konstanta

int INVALID_USER_ID

Nilai dikembalikan untuk id pengguna yang tidak valid/tidak ditemukan: UserHandle menentukan nilai -10000

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

jumlah default perintah coba lagi mencoba untuk melakukan

Bidang

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

Konstruktor publik

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

Membuat TestDevice .

Metode publik

void batchPrefetchStartupBuildProps ()

Optimalisasi mikro (sekitar 400 mili) dengan mengambil semua alat peraga yang kita perlukan daripada memanggil 'adb getprop' untuk masing-masing alat peraga.

boolean canSwitchToHeadlessSystemUser ()

Mengembalikan apakah diizinkan untuk beralih ke pengguna SISTEM tanpa kepala.

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Periksa apakah suatu fitur saat ini didukung dengan tingkat dukungan minimal.

boolean checkConnectivity ()

Periksa apakah perangkat memiliki konektivitas jaringan.

boolean clearErrorDialogs ()

Coba abaikan semua dialog kesalahan yang saat ini ditampilkan di UI perangkat.

void clearLastConnectedWifiNetwork ()

Menghapus jaringan wifi yang terakhir terhubung.

void clearLogcat ()

Menghapus semua data logcat yang terakumulasi.

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

Menghubungkan ke jaringan wifi.

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

Menghubungkan ke jaringan wifi.

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

Menghubungkan ke jaringan wifi.f

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

Menghubungkan ke jaringan wifi.

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

Varian connectToWifiNetwork(String, String) yang hanya terhubung jika perangkat saat ini tidak memiliki konektivitas jaringan.

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

Varian connectToWifiNetwork(String, String) yang hanya terhubung jika perangkat saat ini tidak memiliki konektivitas jaringan.

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

Buat pengguna dengan nama tertentu dan bendera yang disediakan

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

Buat pengguna dengan nama tertentu dan bendera yang disediakan

int createUser (String name)

Buat pengguna dengan nama tertentu dan flag default 0.

int createUserNoThrow (String name)

Buat pengguna dengan nama tertentu dan flag default 0.

void deleteFile (String deviceFilePath)

Metode pembantu untuk menghapus file atau direktori di perangkat.

void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

Menghapus IDeviceActionReceiver yang terdaftar.

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

Metode pembantu untuk memeriksa apakah perangkat soft-restart dengan membandingkan system_server saat ini dengan system_server ProcessInfo sebelumnya.

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

Metode helper untuk memeriksa apakah perangkat soft-restart sejak waktu UTC sejak zaman dari perangkat dan ERROR(/TimeUnit) nya.

boolean disableAdbRoot ()

Mematikan adb root.

void disableKeyguard ()

Upaya untuk menonaktifkan pengaman tombol.

boolean disableNetworkMonitor ()

Menonaktifkan pemantauan jaringan pada perangkat.

boolean disconnectFromWifi ()

Terputus dari jaringan wifi.

boolean doesFileExist (String deviceFilePath, int userId)

Metode pembantu untuk menentukan apakah file di perangkat ada untuk pengguna tertentu.

boolean doesFileExist (String deviceFilePath)

Metode pembantu untuk menentukan apakah ada file di perangkat.

File dumpHeap (String process, String devicePath)

Mencoba untuk membuang heap dari system_server.

boolean enableAdbRoot ()

Mengaktifkan adb root.

boolean enableNetworkMonitor ()

Mengaktifkan pemantauan jaringan pada perangkat.

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

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem dengan waktu tunggu yang ditentukan.

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

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem dengan waktu tunggu yang ditentukan.

String executeAdbCommand (String... cmdArgs)

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem.

CommandResult executeFastbootCommand (String... cmdArgs)

Metode pembantu yang menjalankan perintah fastboot sebagai perintah sistem dengan batas waktu default 2 menit.

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

Metode pembantu yang menjalankan perintah fastboot sebagai perintah sistem.

CommandResult executeLongFastbootCommand (String... cmdArgs)

Metode pembantu yang menjalankan perintah fastboot yang berjalan lama sebagai perintah sistem.

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

Metode pembantu yang menjalankan perintah fastboot yang berjalan lama sebagai perintah sistem dengan variabel lingkungan sistem.

String executeShellCommand (String command)

Metode helper yang menjalankan perintah adb shell dan menampilkan output sebagai String .

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

void executeShellCommand (String command, IShellOutputReceiver receiver)

Mengeksekusi perintah adb shell yang diberikan, mencoba lagi beberapa kali jika perintah gagal.

CommandResult executeShellV2Command (String cmd)

Metode helper yang mengeksekusi perintah adb shell dan mengembalikan hasilnya sebagai CommandResult diisi dengan benar dengan output status perintah, stdout dan stderr.

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

Metode helper yang mengeksekusi perintah adb shell dan mengembalikan hasilnya sebagai CommandResult yang diisi dengan benar dengan output status perintah dan stderr.

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

Metode helper yang mengeksekusi perintah adb shell dan mengembalikan hasilnya sebagai CommandResult yang diisi dengan benar dengan output status perintah, stdout, dan stderr.

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

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

Menjalankan perintah shell adb, dengan lebih banyak parameter untuk mengontrol perilaku perintah.

CommandResult fastbootWipePartition (String partition)

Metode pembantu yang menghapus partisi untuk perangkat.

getActiveApexes ()

Ambil informasi tentang APEX yang diaktifkan di perangkat.

getAllSettings (String namespace)

Mengembalikan pasangan nilai kunci dari namespace yang diminta.

DeviceAllocationState getAllocationState ()

Kembalikan status alokasi perangkat saat ini

String getAndroidId (int userId)

Temukan dan kembalikan android-id yang terkait dengan userId, null jika tidak ditemukan.

getAndroidIds ()

Buat Peta id android yang ditemukan cocok dengan id pengguna.

int getApiLevel ()

Dapatkan Tingkat API perangkat.

PackageInfo getAppPackageInfo (String packageName)

Ambil informasi tentang paket yang diinstal pada perangkat.

getAppPackageInfos ()

Ambil informasi paket yang diinstal pada perangkat.

String getBasebandVersion ()

Metode kemudahan untuk mendapatkan versi baseband (radio) perangkat ini.

Integer getBattery ()

Mengembalikan level baterai perangkat saat ini atau Null jika level baterai tidak tersedia.

boolean getBooleanProperty (String name, boolean defaultValue)

Mengembalikan nilai boolean dari properti yang diberikan.

getBootHistory ()

Metode pembantu mengumpulkan peta riwayat boot dengan waktu boot dan alasan boot.

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

Metode pembantu mengumpulkan peta riwayat boot dengan waktu boot dan alasan boot sejak waktu yang diberikan sejak zaman dari perangkat dan satuan waktu yang ditentukan.

String getBootloaderVersion ()

Metode kenyamanan untuk mendapatkan versi bootloader perangkat ini.

InputStreamSource getBugreport ()

Mengambil laporan bug dari perangkat.

InputStreamSource getBugreportz ()

Mengambil laporan bug dari perangkat.

String getBuildAlias ()

Ambil alias build yang sedang dijalankan perangkat.

String getBuildFlavor ()

Ambil ragam build untuk perangkat.

String getBuildId ()

Ambil build perangkat yang sedang berjalan.

String getBuildSigningKeys ()

Mengembalikan jenis kunci yang digunakan untuk menandatangani gambar perangkat

Biasanya perangkat Android dapat ditandatangani dengan kunci uji (seperti di AOSP) atau kunci rilis (dikendalikan oleh masing-masing produsen perangkat)

DeviceDescriptor getCachedDeviceDescriptor ()

Mengembalikan DeviceDescriptor yang di-cache jika perangkat dialokasikan, jika tidak mengembalikan DeviceDescriptor saat ini.

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

Mengembalikan DeviceDescriptor yang di-cache jika perangkat dialokasikan, jika tidak mengembalikan DeviceDescriptor saat ini.

String[] getChildren (String path)

Alternatif untuk menggunakan IFileEntry yang terkadang tidak berfungsi karena izin.

AbstractConnection getConnection ()

Koneksi saat ini terkait dengan perangkat.

DeviceFoldableState getCurrentFoldableState ()

Mengembalikan status perangkat yang dapat dilipat saat ini atau null jika terjadi beberapa masalah.

int getCurrentUser ()

Kembalikan id dari pengguna yang sedang berjalan.

String getDeviceClass ()

Dapatkan kelas perangkat.

long getDeviceDate ()

Kembalikan tanggal perangkat dalam milidetik sejak Zaman.

DeviceDescriptor getDeviceDescriptor ()

Kembalikan DeviceDescriptor dari informasi perangkat untuk mendapatkan info tentangnya tanpa meneruskan objek perangkat yang sebenarnya.

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

Kembalikan DeviceDescriptor dari informasi perangkat untuk mendapatkan info tentangnya tanpa meneruskan objek perangkat yang sebenarnya.

TestDeviceState getDeviceState ()

Dapatkan status perangkat.

long getDeviceTimeOffset (Date date)

Helper untuk mendapatkan perbedaan waktu antara perangkat dan ERROR(/Date) yang diberikan.

InputStreamSource getEmulatorOutput ()

Dapatkan aliran emulator stdout dan stderr

Process getEmulatorProcess ()

Kembalikan Process yang sesuai dengan emulator ini.

final File getExecuteShellCommandLog ()

Log yang berisi semua log executeShellCommand(String) .

long getExternalStoreFreeSpace ()

Metode pembantu untuk menentukan jumlah ruang kosong pada penyimpanan eksternal perangkat.

String getFastbootPath ()

Mengembalikan jalur biner fastboot yang digunakan.

String getFastbootProductType ()

Metode kemudahan untuk mendapatkan jenis produk perangkat ini saat dalam mode fastboot.

String getFastbootProductVariant ()

Metode kemudahan untuk mendapatkan jenis produk perangkat ini saat dalam mode fastboot.

String getFastbootSerialNumber ()

Mengembalikan nomor seri mode fastboot.

String getFastbootVariable (String variableName)

Ambil nilai variabel fastboot yang diberikan dari perangkat.

String getFastbootVersion ()

Mengembalikan string versi biner fastboot yang digunakan.

IFileEntry getFileEntry (String path)

Ambil referensi ke file jarak jauh di perangkat.

IFileEntry getFileEntry (FileListingService.FileEntry entry)

Pembantu tidak resmi untuk mendapatkan FileEntry dari jalur non-root.

getFoldableStates ()

Mengembalikan daftar status foldable pada perangkat.

IDevice getIDevice ()

Mengembalikan referensi ke ddmlib IDevice terkait.

getInstalledPackageNames ()

Ambil nama paket aplikasi yang ada di perangkat.

long getIntProperty (String name, long defaultValue)

Mengembalikan nilai bilangan bulat dari properti yang diberikan dari perangkat.

String getIpAddress ()

Mendapatkan alamat IP perangkat.

KeyguardControllerState getKeyguardState ()

Kembalikan objek untuk mendapatkan status keyguard saat ini atau null jika tidak didukung.

long getLastExpectedRebootTimeMillis ()

Mengembalikan saat terakhir Tradefed API memicu reboot dalam milidetik sejak EPOCH sebagaimana dikembalikan oleh System.currentTimeMillis() .

int getLaunchApiLevel ()

Dapatkan API Level pertama yang diluncurkan perangkat.

InputStreamSource getLogcat ()

Mengambil aliran snapshot dari data logcat.

InputStreamSource getLogcat (int maxBytes)

Mengambil aliran snapshot dari maxBytes terakhir dari data logcat yang diambil.

InputStreamSource getLogcatDump ()

Dapatkan dump logcat saat ini untuk perangkat.

InputStreamSource getLogcatSince (long date)

Mengambil aliran snapshot dari data logcat yang diambil mulai dari tanggal yang diberikan.

String getMacAddress ()

Mengembalikan alamat MAC perangkat, null jika gagal melakukan kueri dari perangkat.

Integer getMainUserId ()

Mengembalikan id pengguna utama.

getMainlineModuleInfo ()

Dapatkan informasi tentang modul jalur utama yang terpasang di perangkat.

int getMaxNumberOfRunningUsersSupported ()

Dapatkan jumlah maksimum pengguna yang didukung secara bersamaan.

int getMaxNumberOfUsersSupported ()

Dapatkan jumlah maksimum pengguna yang didukung.

Process getMicrodroidProcess ()
IDeviceStateMonitor getMonitor ()

Kembalikan IDeviceStateMonitor yang terkait dengan perangkat.

String getMountPoint (String mountName)

Mengembalikan titik pemasangan.

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

Mengembalikan MountPointInfo yang sesuai dengan jalur mountpoint yang ditentukan, atau null jika jalur tersebut tidak memiliki apa-apa yang dipasang atau sebaliknya tidak muncul di /proc/mounts sebagai titik pemasangan.

getMountPointInfo ()

Mengembalikan versi informasi yang diurai di /proc/mounts pada perangkat

TestDeviceOptions getOptions ()

Ambil opsi pengujian untuk perangkat.

long getPartitionFreeSpace (String partition)

Metode pembantu untuk menentukan jumlah ruang kosong pada partisi perangkat.

Integer getPrimaryUserId ()

Mengembalikan id pengguna utama.

ProcessInfo getProcessByName (String processName)

Metode pembantu menjalankan perintah "pidof" dan "stat" dan mengembalikan objek ProcessInfo dengan PID dan waktu mulai proses dari proses yang diberikan.

String getProcessPid (String process)

Mengembalikan pid layanan atau nol jika terjadi kesalahan.

String getProductType ()

Metode kemudahan untuk mendapatkan jenis produk perangkat ini.

String getProductVariant ()

Metode kemudahan untuk mendapatkan varian produk perangkat ini.

String getProperty (String name)

Ambil nilai properti yang diberikan dari perangkat.

ITestDevice.RecoveryMode getRecoveryMode ()

Dapatkan mode pemulihan saat ini yang digunakan untuk perangkat.

InputStreamSource getScreenshot (String format)

Mengambil tangkapan layar dari perangkat.

InputStreamSource getScreenshot (long displayId)

Mengambil tangkapan layar dari perangkat yang diberi id tampilan.

InputStreamSource getScreenshot (String format, boolean rescale)

Mengambil tangkapan layar dari perangkat.

InputStreamSource getScreenshot ()

Mengambil tangkapan layar dari perangkat.

String getSerialNumber ()

Metode kemudahan untuk mendapatkan nomor seri perangkat ini.

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

Mengembalikan nilai setelan yang diminta.

String getSetting (String namespace, String key)

Lihat getSetting(int, String, String) dan dilakukan pada pengguna sistem.

String getSimOperator ()

Kembalikan operator kartu SIM atau null jika tidak tersedia atau jika perangkat tidak tersedia.

String getSimState ()

Kembalikan status kartu SIM atau null jika tidak tersedia atau perangkat tidak tersedia.

getTombstones ()

Ambil dan kembalikan daftar batu nisan dari perangkat.

long getTotalMemory ()

Mengembalikan total ukuran memori fisik dalam byte atau -1 jika terjadi kesalahan internal

getUninstallablePackageNames ()

Ambil nama paket aplikasi yang dapat dihapus instalasinya.

boolean getUseFastbootErase ()

Dapatkan apakah akan menggunakan fastboot erase atau format fastboot untuk menghapus partisi pada perangkat.

int getUserFlags (int userId)

Temukan dan kembalikan flag dari pengguna tertentu.

getUserInfos ()

Mendapatkan Peta useId ke UserInfo di perangkat.

int getUserSerialNumber (int userId)

Kembalikan nomor seri yang terkait dengan userId jika ditemukan, -10000 dalam kasus lainnya.

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

Memproses DeviceEvent yang diberikan.

Memproses DeviceEvent, yang mungkin atau mungkin tidak mentransisikan perangkat ini ke status alokasi baru.

boolean hasFeature (String feature)

Periksa apakah fitur tersedia di perangkat.

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

Instal paket Android di perangkat.

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

Instal paket Android di perangkat.

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

Instal paket Android di perangkat untuk pengguna tertentu.

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

Instal paket Android di perangkat untuk pengguna tertentu.

void invalidatePropertyCache ()
boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

Periksa apakah platform pada perangkat mendukung pencacahan aplikasi

boolean isBypassLowTargetSdkBlockSupported ()

Periksa apakah platform pada perangkat mendukung melewati blok sdk target rendah pada penginstalan aplikasi

boolean isDeviceEncrypted ()

Mengembalikan jika perangkat dienkripsi.

boolean isDirectory (String path)

Kembalikan True jika jalur pada perangkat adalah direktori, salah jika sebaliknya.

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

Mengembalikan jika enkripsi didukung pada perangkat.

boolean isExecutable (String fullPath)

Mengembalikan True jika jalur file pada perangkat adalah file yang dapat dieksekusi, salah jika sebaliknya.

boolean isFastbootEnabled ()

Kembalikan jika fastboot tersedia untuk perangkat.

boolean isHeadless ()

Kembalikan benar jika perangkat tanpa kepala (tanpa layar), salah jika sebaliknya.

boolean isHeadlessSystemUserMode ()

Mengembalikan apakah perangkat menggunakan mode pengguna sistem tanpa kepala.

boolean isMainUserPermanentAdmin ()

Mengembalikan apakah pengguna utama adalah admin permanen dan tidak dapat dihapus atau diturunkan ke status non-admin.

boolean isMultiUserSupported ()

Menentukan apakah multi-pengguna didukung.

boolean isPackageInstalled (String packageName, String userId)

Permintaan perangkat untuk nama paket yang diberikan dan id pengguna yang diberikan untuk memeriksa apakah saat ini diinstal atau tidak untuk pengguna tersebut.

boolean isPackageInstalled (String packageName)

Permintaan perangkat untuk nama paket yang diberikan untuk memeriksa apakah saat ini diinstal atau tidak.

boolean isRuntimePermissionSupported ()

Periksa apakah platform pada perangkat mendukung pemberian izin runtime

boolean isStateBootloaderOrFastbootd ()

Mengembalikan nilai true jika perangkat dalam TestDeviceState#FASTBOOT atau TestDeviceState.FASTBOOTD .

boolean isUserRunning (int userId)

Periksa apakah pengguna tertentu sedang berjalan.

boolean isUserSecondary (int userId)

Kembalikan apakah pengguna yang ditentukan adalah pengguna sekunder sesuai dengan benderanya.

boolean isUserVisible (int userId)

Memeriksa apakah pengguna tertentu terlihat.

boolean isUserVisibleOnDisplay (int userId, int displayId)

Memeriksa apakah pengguna tertentu terlihat di tampilan tertentu.

boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

Mengembalikan apakah perangkat mengizinkan pengguna untuk mulai terlihat di latar belakang di ERROR(/java.android.view.Display#DEFAULT_DISPLAY) .

boolean isVisibleBackgroundUsersSupported ()

Mengembalikan apakah perangkat mengizinkan pengguna untuk mulai terlihat di latar belakang.

boolean isWifiEnabled ()

Uji apakah wifi diaktifkan.

listDisplayIds ()

Kumpulkan daftar id tampilan yang tersedia di perangkat seperti yang dilaporkan oleh "dumpsys SurfaceFlinger".

listDisplayIdsForStartingVisibleBackgroundUsers ()

Mendapatkan daftar tampilan yang dapat digunakan untuk start a user visible in the background .

listUsers ()

Mendapatkan daftar pengguna di perangkat.

boolean logAnrs ( ITestLogger logger)

Mengumpulkan dan mencatat ANR dari perangkat.

boolean logBugreport (String dataName, ITestLogger listener)

Metode pembantu untuk mengambil laporan bug dan mencatatnya ke reporter.

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

Catat pesan di logcat perangkat.

void nonBlockingReboot ()

Mengeluarkan perintah untuk mem-boot ulang perangkat dan mengembalikan perintah selesai dan saat perangkat tidak lagi terlihat oleh adb.

void postAdbRootAction ()

Ganti jika perangkat memerlukan beberapa tindakan khusus untuk dilakukan setelah root adb dan sebelum perangkat kembali online.

void postAdbUnrootAction ()

Ganti jika perangkat memerlukan beberapa tindakan khusus untuk dilakukan setelah adb unroot dan sebelum perangkat kembali online.

void postBootSetup ()

Lakukan instruksi untuk mengonfigurasi perangkat untuk mengujinya setelah setiap boot.

void postInvocationTearDown (Throwable exception)

Langkah ekstra untuk pembersihan khusus perangkat yang diperlukan yang akan dijalankan setelah pemanggilan dilakukan.

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

Langkah ekstra untuk penyiapan khusus perangkat yang diperlukan yang akan dijalankan pada perangkat sebelum aliran permintaan.

boolean pullDir (String deviceFilePath, File localDir)

Tarik konten direktori secara rekursif dari perangkat.

boolean pullFile (String remoteFilePath, File localFile)

Mengambil file dari perangkat.

File pullFile (String remoteFilePath, int userId)

Mengambil file dari perangkat, menyimpannya di ERROR(/File) sementara lokal, dan mengembalikan File itu.

File pullFile (String remoteFilePath)

Mengambil file dari perangkat, menyimpannya di ERROR(/File) sementara lokal, dan mengembalikan File itu.

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

Mengambil file dari perangkat.

String pullFileContents (String remoteFilePath)

Mengambil file dari perangkat, dan mengembalikan isinya.

File pullFileFromExternal (String remoteFilePath)

Metode praktis untuk mengambil file dari penyimpanan eksternal perangkat, menyimpannya di ERROR(/File) sementara lokal, dan mengembalikan referensi ke File tersebut.

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

Dorong konten direktori secara rekursif ke perangkat sambil mengecualikan beberapa direktori yang difilter.

boolean pushDir (File localFileDir, String deviceFilePath)

Mendorong konten direktori secara rekursif ke perangkat.

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

Varian dari pushFile(File, String) yang secara opsional dapat mempertimbangkan untuk mengevaluasi kebutuhan penyedia materi.

boolean pushFile (File localFile, String remoteFilePath)

Dorong file ke perangkat.

boolean pushString (String contents, String remoteFilePath)

Dorong file yang dibuat dari string ke perangkat

void reboot (String reason)

Reboot perangkat ke mode adb dengan reason yang diberikan untuk bertahan selama reboot.

void reboot ()

Reboot perangkat ke mode adb.

void rebootIntoBootloader ()

Reboot perangkat ke mode bootloader.

void rebootIntoFastbootd ()

Nyalakan ulang perangkat ke mode fastbootd.

void rebootIntoRecovery ()

Nyalakan ulang perangkat ke mode pemulihan adb.

void rebootIntoSideload ()

Nyalakan ulang perangkat ke mode adb sideload (perhatikan bahwa ini adalah mode khusus dalam pemulihan)

Memblokir hingga perangkat memasuki mode sideload

void rebootIntoSideload (boolean autoReboot)

Nyalakan ulang perangkat ke mode adb sideload (perhatikan bahwa ini adalah mode khusus dalam pemulihan)

Memblokir hingga perangkat memasuki mode sideload

void rebootUntilOnline ()

Alternatif untuk reboot() yang hanya memblokir sampai perangkat online yaitu terlihat oleh adb.

void rebootUntilOnline (String reason)

Alternatif untuk reboot() yang hanya memblokir sampai perangkat online yaitu terlihat oleh adb.

void rebootUserspace ()

Reboot hanya bagian ruang pengguna dari perangkat.

void rebootUserspaceUntilOnline ()

Alternatif untuk rebootUserspace() ()} yang hanya memblokir sampai perangkat online yaitu terlihat oleh adb.

boolean recoverDevice ()

Upaya untuk memulihkan komunikasi perangkat.

void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

Mendaftarkan IDeviceActionReceiver untuk perangkat ini.

void remountSystemReadOnly ()

Jadikan partisi sistem pada perangkat hanya-baca.

void remountSystemWritable ()

Jadikan partisi sistem pada perangkat dapat ditulisi.

void remountVendorReadOnly ()

Jadikan partisi vendor pada perangkat hanya-baca.

void remountVendorWritable ()

Jadikan partisi vendor pada perangkat dapat ditulisi.

boolean removeAdmin (String componentName, int userId)

Hapus admin perangkat tertentu di pengguna tertentu dan kembalikan true jika berhasil, false jika sebaliknya.

void removeOwners ()

Hapus semua pemilik profil perangkat yang ada dengan upaya terbaik.

boolean removeUser (int userId)

Hapus pengguna tertentu dari perangkat.

void resetContentProviderSetup ()

Setel ulang bendera untuk penyiapan penyedia konten untuk memicunya lagi.

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

Metode praktis untuk melakukan ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) dengan satu atau beberapa pemroses yang diteruskan sebagai parameter.

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

Menjalankan uji instrumentasi, dan menyediakan pemulihan perangkat.

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

Sama seperti ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) tetapi menjalankan pengujian untuk pengguna yang diberikan.

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

Sama seperti ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) tetapi menjalankan pengujian untuk pengguna tertentu.

void setConfiguration ( IConfiguration configuration)

Menyuntikkan IConfiguration yang sedang digunakan.

final void setConnectionAvdInfo ( GceAvdInfo avdInfo)
void setDate (Date date)

Mengatur tanggal pada perangkat

Catatan: pengaturan tanggal pada perangkat memerlukan root

boolean setDeviceOwner (String componentName, int userId)

Tetapkan komponen admin perangkat sebagai pemilik perangkat di pengguna tertentu.

void setDeviceState ( TestDeviceState deviceState)

Perbarui status perangkat.

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

Untuk emulator, atur SizeLimitedOutputStream untuk mencatat output

void setEmulatorProcess (Process p)

Setel Process , saat perangkat ini adalah emulator.

void setFastbootEnabled (boolean fastbootEnabled)

Atur opsi fastboot untuk perangkat.

void setFastbootPath (String fastbootPath)

Setel jalur ke biner fastboot yang harus digunakan.

void setIDevice (IDevice newDevice)

Perbarui IDevice yang terkait dengan ITestDevice ini.

void setLogStartDelay (int delay)

Menyetel waktu dalam ms untuk menunggu sebelum memulai pengambilan logcat untuk perangkat online.

void setOptions ( TestDeviceOptions options)

Setel TestDeviceOptions untuk perangkat

boolean setProperty (String propKey, String propValue)

Menetapkan nilai properti yang diberikan pada perangkat.

void setRecovery ( IDeviceRecovery recovery)

Setel IDeviceRecovery yang akan digunakan untuk perangkat ini.

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

Atur mode pemulihan saat ini untuk digunakan pada perangkat.

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

Lihat setSetting(int, String, String, String) dan dilakukan pada pengguna sistem.

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

Tambahkan nilai pengaturan ke ruang nama pengguna tertentu.

void setTestLogger ( ITestLogger testLogger)

Memasukkan instance ITestLogger

void setUseFastbootErase (boolean useFastbootErase)

Setel apakah akan menggunakan penghapusan fastboot atau format fastboot untuk menghapus partisi pada perangkat.

void startLogcat ()

Mulai merekam keluaran logcat dari perangkat di latar belakang.

boolean startUser (int userId)

Memulai pengguna tertentu di latar belakang jika sedang dihentikan.

boolean startUser (int userId, boolean waitFlag)

Memulai pengguna tertentu di latar belakang jika sedang dihentikan.

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

Memulai pengguna tertentu di latar belakang, terlihat di tampilan tertentu (yaitu, mengizinkan pengguna meluncurkan aktivitas di tampilan itu).

void stopEmulatorOutput ()

Tutup dan hapus output emulator.

void stopLogcat ()

Berhenti mencatat output logcat dari perangkat, dan buang data logcat yang saat ini disimpan.

boolean stopUser (int userId)

Menghentikan pengguna tertentu.

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

Hentikan pengguna tertentu.

String switchToAdbTcp ()

Alihkan perangkat ke mode adb-over-tcp.

boolean switchToAdbUsb ()

Alihkan perangkat ke adb melalui mode usb.

boolean switchUser (int userId)

Beralih ke userId lain dengan batas waktu default.

boolean switchUser (int userId, long timeout)

Beralih ke userId lain dengan batas waktu yang disediakan sebagai tenggat waktu.

boolean syncFiles (File localFileDir, String deviceFilePath)

Menyinkronkan konten direktori file lokal ke perangkat secara bertahap.

Bugreport takeBugreport ()

Ambil laporan bug dan kembalikan ke dalam objek Bugreport untuk menanganinya.

String uninstallPackage (String packageName)

Copot pemasangan paket Android dari perangkat.

String uninstallPackageForUser (String packageName, int userId)

Copot pemasangan paket Android dari perangkat untuk pengguna tertentu.

boolean unlockDevice ()

Buka kunci perangkat jika perangkat dalam keadaan terenkripsi.

boolean waitForBootComplete (long timeOut)

Memblokir hingga bendera selesai booting perangkat disetel.

boolean waitForDeviceAvailable ()

Menunggu perangkat menjadi responsif dan tersedia untuk pengujian.

boolean waitForDeviceAvailable (long waitTime)

Menunggu perangkat menjadi responsif dan tersedia untuk pengujian.

boolean waitForDeviceAvailableInRecoverPath (long waitTime)

Menunggu perangkat menjadi responsif dan tersedia tanpa mempertimbangkan jalur pemulihan.

void waitForDeviceBootloader ()

Memblokir hingga perangkat terlihat melalui fastboot.

boolean waitForDeviceInRecovery (long waitTime)

Memblokir agar perangkat berada dalam status 'adb recovery' (perhatikan bahwa ini berbeda dari IDeviceRecovery ).

boolean waitForDeviceInSideload (long waitTime)

Memblokir agar perangkat berada dalam status 'adb sideload'

boolean waitForDeviceNotAvailable (long waitTime)

Blokir agar perangkat tidak tersedia yaitu hilang dari adb

void waitForDeviceOnline ()

Memblokir hingga perangkat terlihat melalui adb.

void waitForDeviceOnline (long waitTime)

Memblokir hingga perangkat terlihat melalui adb.

boolean waitForDeviceShell (long waitTime)

Menunggu perangkat responsif terhadap perintah dasar adb shell.

Metode yang dilindungi

void addExtraConnectionBuilderArgs ( DefaultConnection.ConnectionBuilder builder)
String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)

Membangun perintah OS untuk args dan sesi perintah adb shell tertentu

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

Buat RebootDeviceAction untuk digunakan saat melakukan tindakan reboot.

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

Lakukan reboot adb.

void ensureRuntimePermissionSupported ()

metode pembantu untuk membuang pengecualian jika izin runtime tidak didukung

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

Dapatkan instance RunUtil untuk digunakan.

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

Ambil properti perangkat, dari cache ddmlib secara default, dan kembali ke `adb shell getprop` atau `fastboot getvar` bergantung pada apakah perangkat tersebut dalam Fastboot atau tidak.

boolean isInRebootCallback ()

Mengembalikan apakah callback reboot sedang dijalankan atau tidak.

boolean isNewer (File localFile, IFileEntry entry)

Kembalikan nilai true jika file lokal lebih baru dari file jarak jauh.

void notifyRebootEnded ()

Memberitahu semua IDeviceActionReceiver tentang acara akhir reboot.

void notifyRebootStarted ()

Memberitahu semua IDeviceActionReceiver tentang acara mulai reboot.

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

Melakukan tindakan pada perangkat ini.

void postAdbReboot ()

Kemungkinan tindakan ekstra yang dapat diambil setelah reboot.

void prePostBootSetup ()

Mengizinkan setiap jenis perangkat (AndroidNativeDevice, TestDevice) mengganti metode ini untuk penyiapan pasca boot tertentu.

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

Setel instance Jam yang akan digunakan.

void setMicrodroidProcess (Process process)

Menandai TestDevice sebagai microdroid dan menyetel CID-nya.

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

Jalankan perintah fastboot sederhana dengan variabel lingkungan dan laporkan status perintah.

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

Jalankan perintah fastboot sederhana dan laporkan status perintah.

boolean waitForDeviceNotAvailable (String operationDesc, long time)

Tunggu hingga perangkat tidak tersedia (berhenti melaporkan ke adb).

Konstanta

INVALID_USER_ID

public static final int INVALID_USER_ID

Nilai dikembalikan untuk id pengguna yang tidak valid/tidak ditemukan: UserHandle menentukan nilai -10000

Nilai Konstan: -10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

Nilai Konstan: 5000 (0x0000000000001388)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

jumlah default perintah coba lagi mencoba untuk melakukan

Nilai Konstan: 2 (0x00000002)

Bidang

KARTU SD

protected static final String SD_CARD

PENYIMPANAN_EMULATED

protected static final String STORAGE_EMULATED

mOptions

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

Konstruktor publik

Perangkat Asli

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

Membuat TestDevice .

Parameter
device IDevice : IDevice terkait

stateMonitor IDeviceStateMonitor : mekanisme IDeviceStateMonitor yang akan digunakan

allocationMonitor IDeviceMonitor : IDeviceMonitor untuk menginformasikan perubahan status alokasi. Bisa nol

Metode publik

batchPrefetchStartupBuildProps

public void batchPrefetchStartupBuildProps ()

Optimalisasi mikro (sekitar 400 mili) dengan mengambil semua alat peraga yang kita perlukan daripada memanggil 'adb getprop' untuk masing-masing alat peraga. yaitu mengambil semua properti sama cepatnya dengan mengambil satu properti. Hal-hal seperti device.getApiLevel(), checkApiLevelAgainstNextRelease, dan getBuildAlias ​​semuanya memanggil `adb getprop` di bawah tenda. Kami mengambilnya dalam satu panggilan dan memanggil NativeDevice.setProperty. Bahkan jika kita tidak melakukan ini, NativeDevice sendiri akan memanggil setProperty dan meng-cache hasilnya untuk panggilan berikutnya. Kami hanya melakukannya sedikit lebih awal. Jika perangkat sedang dalam pemulihan atau ada kesalahan lain saat mengambil properti, kami abaikan saja.

canSwitchToHeadlessSystemUser

public boolean canSwitchToHeadlessSystemUser ()

Mengembalikan apakah diizinkan untuk beralih ke pengguna SISTEM tanpa kepala.

Pengembalian
boolean

Melempar
DeviceNotAvailableException

checkApiLevelAgainstNextRilis

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

Periksa apakah suatu fitur saat ini didukung dengan tingkat dukungan minimal. Metode ini memperhitungkan fitur yang belum dirilis, sebelum level API dinaikkan.

Parameter
strictMinLevel int : Tingkat kemungkinan min yang ketat yang mendukung fitur ini.

Pengembalian
boolean Benar jika level didukung. Salah sebaliknya.

Melempar
DeviceNotAvailableException

periksa Konektivitas

public boolean checkConnectivity ()

Periksa apakah perangkat memiliki konektivitas jaringan.

Pengembalian
boolean true jika perangkat memiliki koneksi jaringan yang berfungsi, false juga.

Melempar
DeviceNotAvailableException

clearErrorDialogs

public boolean clearErrorDialogs ()

Coba abaikan semua dialog kesalahan yang saat ini ditampilkan di UI perangkat.

Pengembalian
boolean true jika tidak ada dialog atau dialog berhasil dihapus. false sebaliknya.

Melempar
DeviceNotAvailableException

clearLastConnectedWifiNetwork

public void clearLastConnectedWifiNetwork ()

Menghapus jaringan wifi yang terakhir terhubung. Ini harus dipanggil saat memulai pemanggilan baru untuk menghindari koneksi ke jaringan wifi yang digunakan dalam pengujian sebelumnya setelah perangkat dinyalakan ulang.

clearLogcat

public void clearLogcat ()

Menghapus semua data logcat yang terakumulasi.

Ini berguna untuk kasus ketika Anda ingin memastikan ITestDevice#getLogcat() hanya mengembalikan data log yang dihasilkan setelah titik tertentu (seperti setelah mem-flash build perangkat baru, dll).

connectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

Menghubungkan ke jaringan wifi.

Nyalakan wifi dan blokir hingga koneksi berhasil dibuat dengan salah satu jaringan wifi yang diberikan di peta wifiSsidToPsk. Setelah koneksi dibuat, instance akan mencoba memulihkan koneksi setelah setiap reboot hingga ITestDevice#disconnectFromWifi() atau ITestDevice#clearLastConnectedWifiNetwork() dipanggil.

Parameter
wifiSsidToPsk : Peta SSID wifi ke kata sandi.

scanSsid boolean : apakah akan memindai SSID tersembunyi untuk jaringan ini.

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

connectToWifiNetwork

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

Menghubungkan ke jaringan wifi.

Nyalakan wifi dan blokir hingga koneksi berhasil dibuat ke jaringan wifi yang ditentukan. Setelah koneksi dibuat, instance akan mencoba memulihkan koneksi setelah setiap reboot hingga ITestDevice#disconnectFromWifi() atau ITestDevice#clearLastConnectedWifiNetwork() dipanggil.

Parameter
wifiSsid String : wifi ssid untuk terhubung

wifiPsk String : frasa sandi PSK atau null jika tidak terenkripsi

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

connectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk)

Menghubungkan ke jaringan wifi.

Nyalakan wifi dan blokir hingga koneksi berhasil dibuat dengan salah satu jaringan wifi yang diberikan di peta wifiSsidToPsk. Setelah koneksi dibuat, instance akan mencoba memulihkan koneksi setelah setiap reboot hingga ITestDevice#disconnectFromWifi() atau ITestDevice#clearLastConnectedWifiNetwork() dipanggil.f

Parameter
wifiSsidToPsk : Peta SSID wifi ke kata sandi.

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

connectToWifiNetwork

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

Menghubungkan ke jaringan wifi.

Nyalakan wifi dan blokir hingga koneksi berhasil dibuat ke jaringan wifi yang ditentukan. Setelah koneksi dibuat, instance akan mencoba memulihkan koneksi setelah setiap reboot hingga ITestDevice#disconnectFromWifi() atau ITestDevice#clearLastConnectedWifiNetwork() dipanggil.

Parameter
wifiSsid String : wifi ssid untuk terhubung

wifiPsk String : frasa sandi PSK atau null jika tidak terenkripsi

scanSsid boolean : apakah akan memindai SSID tersembunyi untuk jaringan ini.

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

connectToWifiNetworkIfNeeded

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

Varian connectToWifiNetwork(String, String) yang hanya terhubung jika perangkat saat ini tidak memiliki konektivitas jaringan.

Parameter
scanSsid boolean : apakah akan memindai SSID tersembunyi untuk jaringan ini

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

connectToWifiNetworkIfNeeded

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

Varian connectToWifiNetwork(String, String) yang hanya terhubung jika perangkat saat ini tidak memiliki konektivitas jaringan.

Pengembalian
boolean true jika terhubung ke jaringan wifi berhasil. false sebaliknya

Melempar
DeviceNotAvailableException

buat pengguna

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

Buat pengguna dengan nama tertentu dan bendera yang disediakan

Parameter
name String : pengguna yang akan dibuat di perangkat

guest boolean : aktifkan flag pengguna --guest selama pembuatan

ephemeral boolean : aktifkan flag pengguna --ephemeral selama pembuatan

Pengembalian
int id pengguna yang dibuat

Melempar
DeviceNotAvailableException

buat pengguna

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

Buat pengguna dengan nama tertentu dan bendera yang disediakan

Parameter
name String : pengguna yang akan dibuat di perangkat

guest boolean : aktifkan flag pengguna --guest selama pembuatan

ephemeral boolean : aktifkan flag pengguna --ephemeral selama pembuatan

forTesting boolean : mengaktifkan test flag --for-testing selama pembuatan

Pengembalian
int id pengguna yang dibuat

Melempar
DeviceNotAvailableException

buat pengguna

public int createUser (String name)

Buat pengguna dengan nama tertentu dan flag default 0.

Parameter
name String : pengguna yang akan dibuat di perangkat

Pengembalian
int bilangan bulat untuk id pengguna yang dibuat

Melempar
DeviceNotAvailableException

createUserNoThrow

public int createUserNoThrow (String name)

Buat pengguna dengan nama tertentu dan flag default 0.

Parameter
name String : pengguna yang akan dibuat di perangkat

Pengembalian
int bilangan bulat untuk id pengguna yang dibuat atau -1 untuk kesalahan.

Melempar
DeviceNotAvailableException

menghapus berkas

public void deleteFile (String deviceFilePath)

Metode pembantu untuk menghapus file atau direktori di perangkat.

Parameter
deviceFilePath String : Jalur absolut file di perangkat.

Melempar
DeviceNotAvailableException

deregisterDeviceActionReceiver

public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

Menghapus IDeviceActionReceiver yang terdaftar.

Parameter
deviceActionReceiver IDeviceActionReceiver : IDeviceActionReceiver yang akan dihapus.

deviceSoftRestarted

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

Metode pembantu untuk memeriksa apakah perangkat soft-restart dengan membandingkan system_server saat ini dengan system_server ProcessInfo sebelumnya. Gunakan getProcessByName(String) untuk mendapatkan ProcessInfo .

Parameter
prevSystemServerProcess ProcessInfo : proses system_server ProcessInfo sebelumnya.

Pengembalian
boolean true jika perangkat di-restart dengan lembut

Melempar
DeviceNotAvailableException

deviceSoftRestartedSince

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

Metode helper untuk memeriksa apakah perangkat soft-restart sejak waktu UTC sejak zaman dari perangkat dan ERROR(/TimeUnit) nya. Soft-Restart mengacu pada system_server yang dimulai ulang di luar hard reboot perangkat (misalnya: meminta reboot). Perangkat saat ini utcEpochTime dalam Milidetik dapat diperoleh dengan metode getDeviceDate() .

Parameter
utcEpochTime long : waktu perangkat dalam detik sejak zaman.

timeUnit TimeUnit : satuan waktu TimeUnit untuk utcEpochTime yang diberikan.

Pengembalian
boolean true jika perangkat di-restart dengan lembut

Melempar
DeviceNotAvailableException

nonaktifkan AdbRoot

public boolean disableAdbRoot ()

Mematikan adb root.

Menonaktifkan root adb dapat menyebabkan perangkat terputus dari adb. Metode ini akan memblokir hingga perangkat tersedia.

Pengembalian
boolean true jika berhasil.

Melempar
DeviceNotAvailableException

menonaktifkanKeyguard

public void disableKeyguard ()

Upaya untuk menonaktifkan pengaman tombol.

Pertama tunggu pengiriman input siap, ini terjadi sekitar waktu yang sama ketika perangkat melaporkan BOOT_COMPLETE, tampaknya tidak sinkron, karena implementasi kerangka kerja saat ini memiliki kondisi balapan sesekali. Kemudian perintah dikirim untuk mengabaikan keyguard (hanya berfungsi pada yang tidak aman)

Melempar
DeviceNotAvailableException

menonaktifkanNetworkMonitor

public boolean disableNetworkMonitor ()

Menonaktifkan pemantauan jaringan pada perangkat.

Pengembalian
boolean true jika pemantauan berhasil dinonaktifkan. false jika gagal.

Melempar
DeviceNotAvailableException

disconnectFromWifi

public boolean disconnectFromWifi ()

Terputus dari jaringan wifi.

Menghapus semua jaringan dari daftar jaringan yang dikenal dan menonaktifkan wifi.

Pengembalian
boolean true jika terputus dari jaringan wifi berhasil. false jika pemutusan gagal.

Melempar
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath, 
                int userId)

Metode pembantu untuk menentukan apakah file di perangkat ada untuk pengguna tertentu.

Parameter
deviceFilePath String : jalur absolut file pada perangkat untuk diperiksa

userId int : ID pengguna untuk memeriksa keberadaan file

Pengembalian
boolean true jika file ada, false jika tidak.

Melempar
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath)

Metode pembantu untuk menentukan apakah ada file di perangkat.

Parameter
deviceFilePath String : jalur absolut file pada perangkat untuk diperiksa

Pengembalian
boolean true jika file ada, false jika tidak.

Melempar
DeviceNotAvailableException

dumpHeap

public File dumpHeap (String process, 
                String devicePath)

Mencoba untuk membuang heap dari system_server. Ini adalah tanggung jawab penelepon untuk membersihkan file yang dibuang.

Parameter
process String : nama proses perangkat untuk dumpheap.

devicePath String : jalur pada perangkat tempat membuang sampah. Ini harus menjadi lokasi di mana izin mengizinkannya.

Pengembalian
File ERROR(/File) yang berisi laporan. Null jika sesuatu gagal.

Melempar
DeviceNotAvailableException

aktifkanAdbRoot

public boolean enableAdbRoot ()

Mengaktifkan adb root. Jika pengaturan "aktifkan-root" adalah "false", akan mencatat pesan dan kembali tanpa mengaktifkan root.

Mengaktifkan root adb dapat menyebabkan perangkat terputus dari adb. Metode ini akan memblokir hingga perangkat tersedia.

Pengembalian
boolean true jika berhasil.

Melempar
DeviceNotAvailableException

aktifkanNetworkMonitor

public boolean enableNetworkMonitor ()

Mengaktifkan pemantauan jaringan pada perangkat.

Pengembalian
boolean true jika pemantauan berhasil diaktifkan. false jika gagal.

Melempar
DeviceNotAvailableException

mengeksekusiAdbCommand

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

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem dengan waktu tunggu yang ditentukan.

executeShellCommand(String) harus digunakan sebagai gantinya sedapat mungkin, karena metode itu memberikan deteksi dan kinerja kegagalan yang lebih baik.

Parameter
timeout long : waktu dalam milidetik sebelum perangkat dianggap tidak responsif, 0L tanpa batas waktu

cmdArgs String : perintah dan argumen adb untuk dijalankan

Pengembalian
String stdout dari perintah. null jika perintah gagal dijalankan.

Melempar
DeviceNotAvailableException

mengeksekusiAdbCommand

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

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem dengan waktu tunggu yang ditentukan.

executeShellCommand(String) harus digunakan sebagai gantinya sedapat mungkin, karena metode itu memberikan deteksi dan kinerja kegagalan yang lebih baik.

Parameter
timeout long : waktu dalam milidetik sebelum perangkat dianggap tidak responsif, 0L tanpa batas waktu

envMap : lingkungan untuk mengatur perintah

cmdArgs String : perintah dan argumen adb untuk dijalankan

Pengembalian
String stdout dari perintah. null jika perintah gagal dijalankan.

Melempar
DeviceNotAvailableException

mengeksekusiAdbCommand

public String executeAdbCommand (String... cmdArgs)

Metode pembantu yang menjalankan perintah adb sebagai perintah sistem.

executeShellCommand(String) harus digunakan sebagai gantinya sedapat mungkin, karena metode itu memberikan deteksi dan kinerja kegagalan yang lebih baik.

Parameter
cmdArgs String : perintah dan argumen adb untuk dijalankan

Pengembalian
String stdout dari perintah. null jika perintah gagal dijalankan.

Melempar
DeviceNotAvailableException

jalankan Perintah Fastboot

public CommandResult executeFastbootCommand (String... cmdArgs)

Metode pembantu yang menjalankan perintah fastboot sebagai perintah sistem dengan batas waktu default 2 menit.

Diharapkan untuk digunakan saat perangkat sudah dalam mode fastboot.

Parameter
cmdArgs String : perintah fastboot dan argumen untuk dijalankan

Pengembalian
CommandResult CommandResult berisi output dari perintah

Melempar
DeviceNotAvailableException

jalankan Perintah Fastboot

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

Metode pembantu yang menjalankan perintah fastboot sebagai perintah sistem.

Diharapkan untuk digunakan saat perangkat sudah dalam mode fastboot.

Parameter
timeout long : waktu dalam milidetik sebelum perintah berakhir

cmdArgs String : perintah fastboot dan argumen untuk dijalankan

Pengembalian
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

executeLongFastbootCommand

public CommandResult executeLongFastbootCommand (String... cmdArgs)

Helper method which executes a long running fastboot command as a system command.

Identical to executeFastbootCommand(String) except uses a longer timeout.

Parameter
cmdArgs String : the fastboot command and arguments to run

Pengembalian
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

executeLongFastbootCommand

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

Helper method which executes a long running fastboot command as a system command with system environment variables.

Identical to executeFastbootCommand(String) except uses a longer timeout.

Parameter
envVarMap : the system environment variables that the fastboot command run with

cmdArgs String : the fastboot command and arguments to run

Pengembalian
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

executeShellCommand

public String executeShellCommand (String command)

Helper method which executes a adb shell command and returns output as a String .

Parameter
command String : the adb shell command to run

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

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

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

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

Parameter
cmd String : The command that should be run.

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

Parameter
cmd String : The command that should be run.

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

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

Parameter
cmd String : The command that should be run.

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

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

Parameter
cmd String : the adb shell command to run

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

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

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.

Pengembalian
CommandResult

Throws
DeviceNotAvailableException

executeShellV2Command

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

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

Parameter
cmd String : the adb shell command to run

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

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

Pengembalian
CommandResult

Throws
DeviceNotAvailableException

executeShellV2Command

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

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

Parameter
cmd String : the adb shell command to run

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

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

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

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

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

Pengembalian
CommandResult

Throws
DeviceNotAvailableException

executeShellV2Command

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

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

Parameter
cmd String : the adb shell command to run

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

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

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

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

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

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

Pengembalian
CommandResult

Throws
DeviceNotAvailableException

fastbootWipePartition

public CommandResult fastbootWipePartition (String partition)

Helper method which wipes a partition for the device.

If getUseFastbootErase() is true , then fastboot erase will be used to wipe the partition. The device must then create a filesystem the next time the device boots. Otherwise, fastboot format is used which will create a new filesystem on the device.

Expected to be used when device is already in fastboot mode.

Parameter
partition String : the partition to wipe

Pengembalian
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Fetch the information about APEXes activated on the device.

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

Throws
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Return key value pairs of requested namespace.

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

Pengembalian
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

Pengembalian
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

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

Parameter
userId int

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

Pengembalian
Map of android ids found matching user ids.

Throws
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

Get the device API Level. Defaults to UNKNOWN_API_LEVEL .

Pengembalian
int an integer indicating the API Level of device

Throws
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

Fetch information about a package installed on device.

Parameter
packageName String

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

Throws
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Fetch information of packages installed on the device.

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

Pengembalian
String the String baseband version or null if it cannot be determined (device has no radio or version string cannot be read)

Throws
DeviceNotAvailableException

getBattery

public Integer getBattery ()

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

Pengembalian
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

Returns boolean value of the given property.

Parameter
name String : the property name

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

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

Pengembalian
Map of boot time (UTC time in second since Epoch) and boot reason

Throws
DeviceNotAvailableException

getBootHistorySince

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

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

Parameter
utcEpochTime long : the device time since Epoch.

timeUnit TimeUnit : the time unit TimeUnit .

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

Pengembalian
String the String bootloader version or null if it cannot be found

Throws
DeviceNotAvailableException

getBugreport

public InputStreamSource getBugreport ()

Retrieves a bugreport from the device.

The implementation of this is guaranteed to continue to work on a device without an sdcard (or where the sdcard is not yet mounted).

Pengembalian
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

Pengembalian
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

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

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

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

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

Pengembalian
DeviceDescriptor

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

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

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

Pengembalian
DeviceDescriptor

getChildren

public String[] getChildren (String path)

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

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

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

Pengembalian
AbstractConnection

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

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

Pengembalian
DeviceFoldableState

Throws
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

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

Pengembalian
int

Throws
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

Get the device class.

Pengembalian
String the String device class.

getDeviceDate

public long getDeviceDate ()

Return the date of the device in millisecond since epoch.

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

Pengembalian
DeviceDescriptor

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

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

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

Pengembalian
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

Get the device's state.

Pengembalian
TestDeviceState

getDeviceTimeOffset

public long getDeviceTimeOffset (Date date)

Helper to get the time difference between the device and a given ERROR(/Date) . Use Epoch time internally.

Parameter
date Date

Pengembalian
long the difference in milliseconds

Throws
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

Get the stream of emulator stdout and stderr

Pengembalian
InputStreamSource emulator output

getEmulatorProcess

public Process getEmulatorProcess ()

Return the Process corresponding to this emulator.

Pengembalian
Process the Process or null

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

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

Pengembalian
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

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

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

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

Pengembalian
String the String product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootProductVariant

public String getFastbootProductVariant ()

Convenience method to get the product type of this device when its in fastboot mode.

This method should only be used if device should be in fastboot. Its a bit safer variant than the generic getProductType() method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.

Pengembalian
String the String product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootSerialNumber

public String getFastbootSerialNumber ()

Returns the fastboot mode serial number.

Pengembalian
String

getFastbootVariable

public String getFastbootVariable (String variableName)

Retrieve the given fastboot variable value from the device.

Parameter
variableName String : the variable name

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

Pengembalian
String

getFileEntry

public IFileEntry getFileEntry (String path)

Retrieve a reference to a remote file on device.

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

Pengembalian
IFileEntry the IFileEntry or null if file at given path cannot be found

Throws
DeviceNotAvailableException

getFileEntry

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

Unofficial helper to get a FileEntry from a non-root path. FIXME: Refactor the FileEntry system to have it available from any path. (even non root).

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

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

Pengembalian

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.

Pengembalian
IDevice the IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

Fetch the application package names present on the device.

Pengembalian
ERROR(/Set) of String package names currently installed on the device.

Throws
DeviceNotAvailableException

getIntProperty

public long getIntProperty (String name, 
                long defaultValue)

Returns integer value of the given property from the device.

Parameter
name String : the property name

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

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

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

Pengembalian
KeyguardControllerState a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported.

Throws
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

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

Pengembalian
long

getLaunchApiLevel

public int getLaunchApiLevel ()

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

Pengembalian
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

    Pengembalian
    InputStreamSource

  • getLogcat

    public InputStreamSource getLogcat (int maxBytes)

    Grabs a snapshot stream of the last maxBytes of captured logcat data.

    Useful for cases when you want to capture frequent snapshots of the captured logcat data without incurring the potentially big disk space penalty of getting the entire getLogcat() snapshot.

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

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

    Pengembalian
    InputStreamSource a InputStreamSource of the logcat data. An empty stream is returned if fail to capture logcat data.

    getLogcatSince

    public InputStreamSource getLogcatSince (long date)

    Grabs a snapshot stream of captured logcat data starting the date provided. The time on the device should be used getDeviceDate() .

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

    Pengembalian
    InputStreamSource

    getMacAddress

    public String getMacAddress ()

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

    Pengembalian
    String

    getMainUserId

    public Integer getMainUserId ()

    Returns the main user id.

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

    Pengembalian
    ERROR(/Set) of String mainline modules currently installed on the device.

    Throws
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

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

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

    Pengembalian
    int an integer indicating the number of supported users

    Throws
    DeviceNotAvailableException

    getMicrodroidProcess

    public Process getMicrodroidProcess ()

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

    Pengembalian
    IDeviceStateMonitor

    getMountPoint

    public String getMountPoint (String mountName)

    Returns a mount point.

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

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

    Parameter
    mountName String : the name of the mount point

    Pengembalian
    String the mount point or null

    getMountPointInfo

    public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

    Returns a MountPointInfo corresponding to the specified mountpoint path, or null if that path has nothing mounted or otherwise does not appear in /proc/mounts as a mountpoint.

    Parameter
    mountpoint String

    Pengembalian
    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

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

    Throws
    DeviceNotAvailableException

    getOptions

    public TestDeviceOptions getOptions ()

    Fetch the test options for the device.

    Pengembalian
    TestDeviceOptions TestDeviceOptions related to the device under test.

    getPartitionFreeSpace

    public long getPartitionFreeSpace (String partition)

    Helper method to determine amount of free space on device partition.

    Parameter
    partition String

    Pengembalian
    long the amount of free space in KB

    Throws
    DeviceNotAvailableException

    getPrimaryUserId

    public Integer getPrimaryUserId ()

    Returns the primary user id.

    Pengembalian
    Integer the userId of the primary user if there is one, and null if there is no primary user.

    Throws
    DeviceNotAvailableException

    getProcessByName

    public ProcessInfo getProcessByName (String processName)

    Helper method runs the "pidof" and "stat" command and returns ProcessInfo object with PID and process start time of the given process.

    Parameter
    processName String : the proces name String.

    Pengembalian
    ProcessInfo ProcessInfo of given processName

    Throws
    DeviceNotAvailableException

    getProcessPid

    public String getProcessPid (String process)

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

    Parameter
    process String : The proces name String.

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

    Pengembalian
    String the String product type name. Will not be null

    Throws
    DeviceNotAvailableException

    getProductVariant

    public String getProductVariant ()

    Convenience method to get the product variant of this device.

    This method will work if device is in either adb or fastboot mode.

    Pengembalian
    String the String product variant name or null if it cannot be determined

    Throws
    DeviceNotAvailableException

    getProperty

    public String getProperty (String name)

    Retrieve the given property value from the device.

    Parameter
    name String : the property name

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

    Pengembalian
    ITestDevice.RecoveryMode the current recovery mode used for the device.

    getScreenshot

    public InputStreamSource getScreenshot (String format)

    Grabs a screenshot from the device. Recommended to use getScreenshot(format) instead with JPEG encoding for smaller size

    Parameter
    format String : supported PNG, JPEG

    Pengembalian
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    Throws
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot (long displayId)

    Grabs a screenshot from the device given display id. Format is PNG.

    TODO: extend the implementations above to support 'format' and 'rescale'

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

    Pengembalian
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    Throws
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot (String format, 
                    boolean rescale)

    Grabs a screenshot from the device. Recommended to use getScreenshot(String) instead with JPEG encoding for smaller size.

    Parameter
    format String : supported PNG, JPEG

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

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

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

    Pengembalian
    String the String serial number

    getSetting

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

    Return the value of the requested setting. namespace must be one of: {"system", "secure", "global"}

    Parameter
    userId int

    namespace String

    key String

    Pengembalian
    String the value associated with the namespace:key of a user. Null if not found.

    Throws
    DeviceNotAvailableException

    getSetting

    public String getSetting (String namespace, 
                    String key)

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

    Parameter
    namespace String

    key String

    Pengembalian
    String

    Throws
    DeviceNotAvailableException

    getSimOperator

    public String getSimOperator ()

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

    Pengembalian
    String

    getSimState

    public String getSimState ()

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

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

    Pengembalian
    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

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

    Pengembalian
    ERROR(/Set) of uninstallable String package names currently installed on the device.

    Throws
    DeviceNotAvailableException

    getUseFastbootErase

    public boolean getUseFastbootErase ()

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

    Pengembalian
    boolean true if fastboot erase will be used or false if fastboot format will be used.

    getUserFlags

    public int getUserFlags (int userId)

    Find and return the flags of a given user. Flags are defined in "android.content.pm.UserInfo" class in Android Open Source Project.

    Parameter
    userId int

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

    Pengembalian
    the list of UserInfo objects.

    Throws
    DeviceNotAvailableException

    getUserSerialNumber

    public int getUserSerialNumber (int userId)

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

    Parameter
    userId int

    Pengembalian
    int

    Throws
    DeviceNotAvailableException

    handleAllocationEvent

    public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

    Process the given DeviceEvent. May transition device to new state. Will inform the IDeviceMonitor of any state transitions.

    Process the DeviceEvent, which may or may not transition this device to a new allocation state.

    Parameter
    event DeviceEvent

    Pengembalian
    IManagedTestDevice.DeviceEventResponse

    hasFeature

    public boolean hasFeature (String feature)

    Check if a feature is available on a device.

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

    Pengembalian
    boolean True if feature is found, false otherwise.

    Throws
    DeviceNotAvailableException

    installPackage

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

    Install an Android package on device.

    Parameter
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackage

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

    Install an Android package on device.

    Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.

    Parameter
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    grantPermissions boolean : if all runtime permissions should be granted at install time

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackageForUser

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

    Install an Android package on device for a given user.

    Parameter
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    userId int : the integer user id to install for.

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackageForUser

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

    Install an Android package on device for a given user.

    Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.

    Parameter
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    grantPermissions boolean : if all runtime permissions should be granted at install time

    userId int : the integer user id to install for.

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    invalidatePropertyCache

    public void invalidatePropertyCache ()

    isAdbRoot

    public boolean isAdbRoot ()

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    isAdbTcp

    public boolean isAdbTcp ()

    Pengembalian
    boolean

    isAppEnumerationSupported

    public boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    Pengembalian
    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

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

    Throws
    DeviceNotAvailableException

    isDeviceEncrypted

    public boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    Pengembalian
    boolean true if the device is encrypted.

    Throws
    DeviceNotAvailableException

    isDirectory

    public boolean isDirectory (String path)

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

    Parameter
    path String

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    Pengembalian
    boolean true if adb root should be enabled on device

    isEncryptionSupported

    public boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    Pengembalian
    boolean true if the device supports encryption.

    Throws
    DeviceNotAvailableException

    isExecutable

    public boolean isExecutable (String fullPath)

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

    Parameter
    fullPath String

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    isFastbootEnabled

    public boolean isFastbootEnabled ()

    Return if fastboot is available for the device.

    Pengembalian
    boolean

    isHeadless

    public boolean isHeadless ()

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

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    isHeadlessSystemUserMode

    public boolean isHeadlessSystemUserMode ()

    Returns whether the device uses headless system user mode.

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

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    isMultiUserSupported

    public boolean isMultiUserSupported ()

    Determines if multi user is supported.

    Pengembalian
    boolean true if multi user is supported, false otherwise

    Throws
    DeviceNotAvailableException

    isPackageInstalled

    public boolean isPackageInstalled (String packageName, 
                    String userId)

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

    Parameter
    packageName String : the package we are checking if it's installed.

    userId String : The user id we are checking the package is installed for. If null, primary user zero will be used.

    Pengembalian
    boolean True if the package is reported as installed. False otherwise.

    Throws
    DeviceNotAvailableException

    isPackageInstalled

    public boolean isPackageInstalled (String packageName)

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

    Parameter
    packageName String

    Pengembalian
    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

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

    Pengembalian
    boolean

    isUserRunning

    public boolean isUserRunning (int userId)

    Check if a given user is running.

    Parameter
    userId int

    Pengembalian
    boolean True if the user is running, false in every other cases.

    Throws
    DeviceNotAvailableException

    isUserSecondary

    public boolean isUserSecondary (int userId)

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

    Parameter
    userId int

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

    Parameter
    userId int

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

    Parameter
    userId int

    displayId int

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

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

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

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

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

    Pengembalian

    Throws
    DeviceNotAvailableException

    listUsers

    public  listUsers ()

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

    Pengembalian
    the list of user ids.

    Throws
    DeviceNotAvailableException

    logAnrs

    public boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    Parameter
    logger ITestLogger : an ITestLogger to log the ANRs.

    Pengembalian
    boolean True if the logging was successful, false otherwise.

    Throws
    DeviceNotAvailableException

    logBugreport

    public boolean logBugreport (String dataName, 
                    ITestLogger listener)

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

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

    listener ITestLogger : an ITestLogger to log the bugreport.

    Pengembalian
    boolean True if the logging was successful, false otherwise.

    logOnDevice

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

    Log a message in the logcat of the device. This is a safe call that will not throw even if the logging fails.

    Parameter
    tag String : The tag under which we log our message in the logcat.

    level Log.LogLevel : The debug level of the message in the logcat.

    format String : The message format.

    args Object : the args to be replaced via String.format().

    nonBlockingReboot

    public void nonBlockingReboot ()

    Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.

    Throws
    DeviceNotAvailableException

    postAdbRootAction

    public void postAdbRootAction ()

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

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

    Parameter
    exception Throwable : if any, the final exception raised by the invocation failure.

    preInvocationSetup

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

    Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.

    Parameter
    info IBuildInfo : The IBuildInfo of the device.

    attributes MultiMap : The attributes stored in the invocation context

    Throws
    DeviceNotAvailableException
    TargetSetupError

    pullDir

    public boolean pullDir (String deviceFilePath, 
                    File localDir)

    Recursively pull directory contents from device.

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

    localDir File : the local directory to pull files into

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

    Throws
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    Retrieves a file off device.

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

    localFile File : the local file to store contents in. If non-empty, contents will be replaced.

    Pengembalian
    boolean true if file was retrieved successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFile

    public File pullFile (String remoteFilePath, 
                    int userId)

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

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

    userId int : The user id to pull from

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

    Throws
    DeviceNotAvailableException

    pullFile

    public File pullFile (String remoteFilePath)

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

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

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

    Throws
    DeviceNotAvailableException

    pullFile

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

    Retrieves a file off device.

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

    localFile File : the local file to store contents in. If non-empty, contents will be replaced.

    userId int : The user id to pull from

    Pengembalian
    boolean true if file was retrieved successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFileContents

    public String pullFileContents (String remoteFilePath)

    Retrieves a file off device, and returns the contents.

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

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

    Throws
    DeviceNotAvailableException

    pullFileFromExternal

    public File pullFileFromExternal (String remoteFilePath)

    A convenience method to retrieve a file from the device's external storage, stores it in a local temporary ERROR(/File) , and return a reference to that File .

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

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

    Throws
    DeviceNotAvailableException

    pushDir

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

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

    Parameter
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

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

    Pengembalian
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushDir

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath)

    Recursively push directory contents to device.

    Parameter
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    Pengembalian
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushFile

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

    Variant of pushFile(File, String) which can optionally consider evaluating the need for the content provider.

    Parameter
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    evaluateContentProviderNeeded boolean : whether to check if we need the content provider

    Pengembalian
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushFile

    public boolean pushFile (File localFile, 
                    String remoteFilePath)

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

    Parameter
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    Pengembalian
    boolean true if file was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pushString

    public boolean pushString (String contents, 
                    String remoteFilePath)

    Push file created from a string to device

    Parameter
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

    Pengembalian
    boolean true if string was pushed successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    reboot

    public void reboot (String reason)

    Reboots the device into adb mode with given reason to be persisted across reboot.

    Blocks until device becomes available.

    Last reboot reason can be obtained by querying sys.boot.reason propety.

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

    Throws
    DeviceNotAvailableException

    reboot

    public void reboot ()

    Reboots the device into adb mode.

    Blocks until device becomes available.

    Throws
    DeviceNotAvailableException

    rebootIntoBootloader

    public void rebootIntoBootloader ()

    Reboots the device into bootloader mode.

    Blocks until device is in bootloader mode.

    Throws
    DeviceNotAvailableException

    rebootIntoFastbootd

    public void rebootIntoFastbootd ()

    Reboots the device into fastbootd mode.

    Blocks until device is in fastbootd mode.

    Throws
    DeviceNotAvailableException

    rebootIntoRecovery

    public void rebootIntoRecovery ()

    Reboots the device into adb recovery mode.

    Blocks until device enters recovery

    Throws
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload ()

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    Throws
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload (boolean autoReboot)

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

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

    Throws
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline ()

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

    Throws
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline (String reason)

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

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

    Throws
    DeviceNotAvailableException

    rebootUserspace

    public void rebootUserspace ()

    Reboots only userspace part of device.

    Blocks until device becomes available.

    WARNING. Userspace reboot is currently under active development, use it on your own risk.

    Throws
    DeviceNotAvailableException

    rebootUserspaceUntilOnline

    public void rebootUserspaceUntilOnline ()

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

    Throws
    DeviceNotAvailableException

    recoverDevice

    public boolean recoverDevice ()

    Attempts to recover device communication.

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

    Parameter
    deviceActionReceiver IDeviceActionReceiver : A IDeviceActionReceiver which will be registered.

    remountSystemReadOnly

    public void remountSystemReadOnly ()

    Make the system partition on the device read-only. May reboot the device.

    Throws
    DeviceNotAvailableException

    remountSystemWritable

    public void remountSystemWritable ()

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

    Throws
    DeviceNotAvailableException

    remountVendorReadOnly

    public void remountVendorReadOnly ()

    Make the vendor partition on the device read-only. May reboot the device.

    Throws
    DeviceNotAvailableException

    remountVendorWritable

    public void remountVendorWritable ()

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

    Throws
    DeviceNotAvailableException

    removeAdmin

    public boolean removeAdmin (String componentName, 
                    int userId)

    Remove given device admin in given user and return true if it is successful, false otherwise.

    Parameter
    componentName String : of device admin to be removed.

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

    Pengembalian
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    removeOwners

    public void removeOwners ()

    Remove all existing device profile owners with the best effort.

    Throws
    DeviceNotAvailableException

    removeUser

    public boolean removeUser (int userId)

    Remove a given user from the device.

    Parameter
    userId int : of the user to remove

    Pengembalian
    boolean true if we were successful in removing the user, false otherwise.

    Throws
    DeviceNotAvailableException

    resetContentProviderSetup

    public void resetContentProviderSetup ()

    Reset the flag for content provider setup in order to trigger it again.

    runInstrumentationTests

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

    Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) with one or more listeners passed as parameters.

    Parameter
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

    Pengembalian
    boolean true if test command completed. false if it failed to complete, but recovery succeeded

    Throws
    DeviceNotAvailableException

    runInstrumentationTests

    public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                     listeners)

    Runs instrumentation tests, and provides device recovery.

    If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.

    If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.

    Parameter
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

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

    Parameter
    runner IRemoteAndroidTestRunner

    userId int

    listeners

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

    Parameter
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    setConfiguration

    public void setConfiguration (IConfiguration configuration)

    Injects the IConfiguration in use.

    Parameter
    configuration IConfiguration

    setConnectionAvdInfo

    public final void setConnectionAvdInfo (GceAvdInfo avdInfo)

    Parameter
    avdInfo GceAvdInfo

    setDate

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

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

    Throws
    DeviceNotAvailableException

    setDeviceOwner

    public boolean setDeviceOwner (String componentName, 
                    int userId)

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

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

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

    Pengembalian
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    Parameter
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    Parameter
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

    Sets the Process , when this device is an emulator.

    Parameter
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

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

    Parameter
    fastbootEnabled boolean : whether fastboot is available for the device or not

    setFastbootPath

    public void setFastbootPath (String fastbootPath)

    Sets the path to the fastboot binary that should be used. Still requires isFastbootEnabled() to be true, to have fastboot functions enabled.

    Parameter
    fastbootPath String

    setIDevice

    public void setIDevice (IDevice newDevice)

    Update the IDevice associated with this ITestDevice.

    The new IDevice must refer the same physical device as the current reference. This method will be called if DDMS has allocated a new IDevice

    Parameter
    newDevice IDevice : the IDevice

    setLogStartDelay

    public void setLogStartDelay (int delay)

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

    Parameter
    delay int : the delay in ms

    setOptions

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    Parameter
    options TestDeviceOptions

    setProperty

    public boolean setProperty (String propKey, 
                    String propValue)

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

    Parameter
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    Pengembalian
    boolean returns True if the setprop command was successful, False otherwise.

    Throws
    DeviceNotAvailableException

    setRecovery

    public void setRecovery (IDeviceRecovery recovery)

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

    Parameter
    recovery IDeviceRecovery : the IDeviceRecovery

    setRecoveryMode

    public void setRecoveryMode (ITestDevice.RecoveryMode mode)

    Set the current recovery mode to use for the device.

    Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etc

    Parameter
    mode ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not.

    setSetting

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

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

    Parameter
    namespace String

    key String

    value String

    Throws
    DeviceNotAvailableException

    setSetting

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

    Add a setting value to the namespace of a given user. Some settings will only be available after a reboot. namespace must be one of: {"system", "secure", "global"}

    Parameter
    userId int

    namespace String

    key String

    value String

    Throws
    DeviceNotAvailableException

    setTestLogger

    public void setTestLogger (ITestLogger testLogger)

    Injects the ITestLogger instance

    Parameter
    testLogger ITestLogger

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

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

    Parameter
    useFastbootErase boolean : true if fastboot erase should be used or false if fastboot format should be used.

    startLogcat

    public void startLogcat ()

    Start capturing logcat output from device in the background.

    Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat.

    When the device is no longer in use, stopLogcat() must be called.

    startLogcat() and stopLogcat() do not normally need to be called when within a TF invocation context, as the TF framework will start and stop logcat.

    startUser

    public boolean startUser (int userId)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP.

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

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

    Throws
    DeviceNotAvailableException

    startUser

    public boolean startUser (int userId, 
                    boolean waitFlag)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP. Possible to provide extra flag to wait for the operation to have effect.

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

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

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

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

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

    Parameter
    userId int : of the user to stop.

    Pengembalian
    boolean true if the user was successfully stopped.

    Throws
    DeviceNotAvailableException

    stopUser

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

    Stop a given user. Possible to provide extra flags to wait for the operation to have effect, and force terminate the user. Cannot stop current and system user.

    Parameter
    userId int : of the user to stop.

    waitFlag boolean : will make the command wait until user is stopped.

    forceFlag boolean : will force stop the user.

    Pengembalian
    boolean true if the user was successfully stopped.

    Throws
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

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

    Pengembalian
    boolean true if switch was successful, false otherwise.

    Throws
    DeviceNotAvailableException

    switchUser

    public boolean switchUser (int userId)

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

    Parameter
    userId int

    Pengembalian
    boolean True if the new userId matches the userId provider. False otherwise.

    Throws
    DeviceNotAvailableException

    switchUser

    public boolean switchUser (int userId, 
                    long timeout)

    Switch to another userId with the provided timeout as deadline. Attempt to disable keyguard after user change is successful.

    Parameter
    userId int

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

    Pengembalian
    boolean True if the new userId matches the userId provider. False otherwise.

    Throws
    DeviceNotAvailableException

    syncFiles

    public boolean syncFiles (File localFileDir, 
                    String deviceFilePath)

    Incrementally syncs the contents of a local file directory to device.

    Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date.

    Hidden files (with names starting with ".") will be ignored.

    Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.

    Parameter
    localFileDir File : the local file directory containing files to recursively push.

    deviceFilePath String : the remote destination absolute file path root. All directories in thos file path must be readable. ie pushing to /data/local/tmp when adb is not root will fail

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

    Pengembalian
    Bugreport

    uninstallPackage

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    Parameter
    packageName String : the Android package to uninstall

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    uninstallPackageForUser

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    Uninstall an Android package from device for a given user.

    Parameter
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    Pengembalian
    String a String with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    unlockDevice

    public boolean unlockDevice ()

    Unlocks the device if the device is in an encrypted state.

    This method may restart the framework but will not call postBootSetup() . Therefore, the device might not be fully ready to be tested when this method returns.

    Pengembalian
    boolean true if successful or if the device is unencrypted.

    Throws
    DeviceNotAvailableException

    waitForBootComplete

    public boolean waitForBootComplete (long timeOut)

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

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

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

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

    Throws
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable (long waitTime)

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

    Parameter
    waitTime long : the time in ms to wait

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

    Parameter
    waitTime long

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

    Parameter
    waitTime long : the time in ms to wait

    Pengembalian
    boolean true if device boots into recovery before time expires. false otherwise

    waitForDeviceInSideload

    public boolean waitForDeviceInSideload (long waitTime)

    Blocks for the device to be in the 'adb sideload' state

    Parameter
    waitTime long : the time in ms to wait

    Pengembalian
    boolean true if device boots into sideload before time expires. false otherwise

    waitForDeviceNotAvailable

    public boolean waitForDeviceNotAvailable (long waitTime)

    Blocks for the device to be not available ie missing from adb

    Parameter
    waitTime long : the time in ms to wait

    Pengembalian
    boolean true if device becomes not available before time expires. false otherwise

    waitForDeviceOnline

    public void waitForDeviceOnline ()

    Blocks until device is visible via adb. Uses default timeout

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    Throws
    DeviceNotAvailableException

    waitForDeviceOnline

    public void waitForDeviceOnline (long waitTime)

    Blocks until device is visible via adb.

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    Parameter
    waitTime long : the time in ms to wait

    Throws
    DeviceNotAvailableException

    waitForDeviceShell

    public boolean waitForDeviceShell (long waitTime)

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

    Parameter
    waitTime long : the time in ms to wait

    Pengembalian
    boolean true if device becomes responsive before waitTime elapses.

    Protected methods

    addExtraConnectionBuilderArgs

    protected void addExtraConnectionBuilderArgs (DefaultConnection.ConnectionBuilder builder)

    Parameter
    builder DefaultConnection.ConnectionBuilder

    buildAdbShellCommand

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

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

    Parameter
    command String

    forceExitStatusDetection boolean

    Pengembalian
    String[]

    checkApiLevelAgainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

    Parameter
    feature String

    strictMinLevel int

    createRebootDeviceAction

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

    Create a RebootDeviceAction to be used when performing a reboot action.

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

    reason String : for this reboot.

    Pengembalian
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    createRunUtil

    protected IRunUtil createRunUtil ()

    Pengembalian
    IRunUtil

    doAdbReboot

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

    Perform a adb reboot.

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

    reason String : for this reboot.

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

    Pengembalian
    int

    getLogger

    protected ITestLogger getLogger ()

    Pengembalian
    ITestLogger

    getRunUtil

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    Pengembalian
    IRunUtil

    initializeConnection

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

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

    Parameter
    propName String : The name of the device property as returned by `adb shell getprop`

    fastbootVar String : The name of the equivalent fastboot variable to query. if null , fastboot query will not be attempted

    description String : A simple description of the variable. First letter should be capitalized.

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

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

    Parameter
    localFile File

    entry IFileEntry

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

    Parameter
    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

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

    Parameter
    remoteFilePath String

    localFile File

    Pengembalian
    boolean

    Throws
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    Set the Clock instance to use.

    Parameter
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    Marks the TestDevice as microdroid and sets its CID.

    Parameter
    process Process : Process of the Microdroid VM.

    setTestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

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

    Parameter
    timeout long

    envVarMap

    fullCmd String

    Pengembalian
    CommandResult

    simpleFastbootCommand

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

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

    Parameter
    timeout long

    fullCmd String

    Pengembalian
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

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

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

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

    Pengembalian
    boolean True if device did become unavailable.