เนทีฟดีไวซ์

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver

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


การใช้งานเริ่มต้นของอุปกรณ์ Android ที่ไม่ใช่สแต็ ITestDevice

สรุป

คลาสที่ซ้อนกัน

class NativeDevice.AdbAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) สำหรับการเรียกใช้คำสั่ง OS 'adb ....'

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) สำหรับการรีบูตอุปกรณ์

ค่าคงที่

int INVALID_USER_ID

ค่าที่ส่งคืนสำหรับรหัสผู้ใช้ที่ไม่ถูกต้อง/ไม่พบ: UserHandle กำหนดค่า -10000

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

จำนวนคำสั่งเริ่มต้นที่พยายามดำเนินการอีกครั้ง

เขตข้อมูล

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

ผู้สร้างสาธารณะ

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

สร้าง TestDevice

วิธีการสาธารณะ

boolean canSwitchToHeadlessSystemUser ()

ส่งคืนว่าอนุญาตให้เปลี่ยนเป็นผู้ใช้ SYSTEM ที่ไม่มีหัวหรือไม่

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

ตรวจสอบว่าคุณลักษณะใดรองรับหรือไม่โดยพิจารณาจากระดับที่รองรับน้อยที่สุด

boolean checkConnectivity ()

ตรวจสอบว่าอุปกรณ์มีการเชื่อมต่อเครือข่าย

boolean clearErrorDialogs ()

พยายามปิดกล่องโต้ตอบแสดงข้อผิดพลาดที่แสดงอยู่บน UI ของอุปกรณ์ในปัจจุบัน

void clearLastConnectedWifiNetwork ()

ล้างเครือข่าย wifi ที่เชื่อมต่อล่าสุด

void clearLogcat ()

ลบข้อมูล logcat ที่สะสมไว้

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

เชื่อมต่อกับเครือข่าย wifi

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

เชื่อมต่อกับเครือข่าย wifi

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

เชื่อมต่อกับเครือข่าย wifi.ฉ

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

เชื่อมต่อกับเครือข่าย wifi

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

ตัวแปรของ connectToWifiNetwork(String, String) ที่เชื่อมต่อเฉพาะในกรณีที่อุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

ตัวแปรของ connectToWifiNetwork(String, String) ที่เชื่อมต่อเฉพาะในกรณีที่อุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน

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

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา

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

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา

int createUser (String name)

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0

int createUserNoThrow (String name)

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0

void deleteFile (String deviceFilePath)

วิธีตัวช่วยลบไฟล์หรือไดเรกทอรีในเครื่อง

void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

ลบ IDeviceActionReceiver ที่ลงทะเบียน

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

วิธีตัวช่วยเพื่อตรวจสอบว่าอุปกรณ์รีสตาร์ทอย่างนุ่มนวลหรือไม่โดยเปรียบเทียบ system_server ปัจจุบันกับ system_server ProcessInfo ก่อนหน้า

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

วิธีการช่วยเหลือเพื่อตรวจสอบว่าอุปกรณ์รีสตาร์ทอย่างนุ่มนวลตั้งแต่เวลา UTC ตั้งแต่ epoch จากอุปกรณ์และ ERROR(/TimeUnit)

boolean disableAdbRoot ()

ปิด adb root

void disableKeyguard ()

พยายามปิดใช้งานคีย์การ์ด

boolean disableNetworkMonitor ()

ปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์

boolean disconnectFromWifi ()

ตัดการเชื่อมต่อจากเครือข่าย wifi

boolean doesFileExist (String deviceFilePath, int userId)

วิธีการช่วยเหลือเพื่อตรวจสอบว่ามีไฟล์บนอุปกรณ์สำหรับผู้ใช้ที่กำหนดหรือไม่

boolean doesFileExist (String deviceFilePath)

วิธีการช่วยเหลือเพื่อตรวจสอบว่ามีไฟล์บนอุปกรณ์อยู่หรือไม่

File dumpHeap (String process, String devicePath)

พยายามดัมพ์ฮีปจาก system_server

boolean enableAdbRoot ()

เปิด adb root

boolean enableNetworkMonitor ()

เปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์

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

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ

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

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ

String executeAdbCommand (String... cmdArgs)

เมธอด Helper ซึ่งเรียกใช้คำสั่ง adb เป็นคำสั่งระบบ

CommandResult executeFastbootCommand (String... cmdArgs)

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง fastboot เป็นคำสั่งระบบโดยมีการหมดเวลาเริ่มต้น 2 นาที

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

วิธีตัวช่วยที่รันคำสั่ง fastboot เป็นคำสั่งระบบ

CommandResult executeLongFastbootCommand (String... cmdArgs)

เมธอด Helper ซึ่งดำเนินการคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบ

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

เมธอด Helper ซึ่งดำเนินการคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบพร้อมตัวแปรสภาพแวดล้อมระบบ

String executeShellCommand (String command)

เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งคืนเอาต์พุตเป็น ERROR(/String)

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

void executeShellCommand (String command, IShellOutputReceiver receiver)

ดำเนินการคำสั่ง adb shell ที่กำหนด ลองใหม่หลายครั้งหากคำสั่งล้มเหลว

CommandResult executeShellV2Command (String cmd)

เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งคืนผลลัพธ์เป็น CommandResult ที่บรรจุอย่างถูกต้องด้วยเอาต์พุตสถานะคำสั่ง stdout และ stderr

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

เมธอด Helper ซึ่งดำเนินการคำสั่งเชลล์ adb และส่งคืนผลลัพธ์เป็น CommandResult ที่บรรจุอย่างถูกต้องด้วยเอาต์พุตสถานะคำสั่งและ stderr

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งคืนผลลัพธ์เป็น CommandResult ที่เติมข้อมูลเอาต์พุตสถานะคำสั่ง stdout และ stderr อย่างเหมาะสม

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

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

ดำเนินการคำสั่ง adb shell พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมลักษณะการทำงานของคำสั่ง

CommandResult fastbootWipePartition (String partition)

วิธีการช่วยเหลือซึ่งจะล้างพาร์ทิชันสำหรับอุปกรณ์

getActiveApexes ()

ดึงข้อมูลเกี่ยวกับ APEX ที่เปิดใช้งานบนอุปกรณ์

getAllSettings (String namespace)

คืนค่าคีย์คู่ของเนมสเปซที่ร้องขอ

DeviceAllocationState getAllocationState ()

ส่งคืนสถานะการจัดสรรปัจจุบันของอุปกรณ์

String getAndroidId (int userId)

ค้นหาและส่งคืน android-id ที่เชื่อมโยงกับ userId หากไม่พบจะเป็น null

getAndroidIds ()

สร้างแผนที่ของรหัส android พบรหัสผู้ใช้ที่ตรงกัน

int getApiLevel ()

รับระดับ API ของอุปกรณ์

PackageInfo getAppPackageInfo (String packageName)

ดึงข้อมูลเกี่ยวกับแพ็คเกจที่ติดตั้งบนอุปกรณ์

getAppPackageInfos ()

ดึงข้อมูลแพ็คเกจที่ติดตั้งบนอุปกรณ์

String getBasebandVersion ()

วิธีอำนวยความสะดวกในการรับเวอร์ชันเบสแบนด์ (วิทยุ) ของอุปกรณ์นี้

Integer getBattery ()

ส่งกลับระดับแบตเตอรี่ปัจจุบันของอุปกรณ์หรือค่า Null หากไม่มีระดับแบตเตอรี่

boolean getBooleanProperty (String name, boolean defaultValue)

ส่งกลับค่าบูลีนของคุณสมบัติที่กำหนด

getBootHistory ()

วิธีตัวช่วยรวบรวมแผนที่ประวัติการบูตพร้อมเวลาบูตและเหตุผลในการบูต

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

เมธอด Helper รวบรวมแมปประวัติการบูตพร้อมเวลาบูตและเหตุผลการบูตตั้งแต่เวลาที่กำหนดตั้งแต่ยุคจากอุปกรณ์และหน่วยเวลาที่ระบุ

String getBootloaderVersion ()

วิธีอำนวยความสะดวกในการรับเวอร์ชัน bootloader ของอุปกรณ์นี้

InputStreamSource getBugreport ()

ดึงรายงานข้อผิดพลาดจากอุปกรณ์

InputStreamSource getBugreportz ()

ดึงรายงานข้อผิดพลาดจากอุปกรณ์

String getBuildAlias ()

เรียกนามแฝงของบิลด์ที่อุปกรณ์กำลังทำงานอยู่

String getBuildFlavor ()

เรียกรสชาติการสร้างสำหรับอุปกรณ์

String getBuildId ()

ดึงบิลด์ที่อุปกรณ์กำลังทำงานอยู่

String getBuildSigningKeys ()

ส่งกลับประเภทคีย์ที่ใช้เพื่อเซ็นอิมเมจอุปกรณ์

โดยทั่วไปแล้ว อุปกรณ์ Android อาจลงนามด้วยคีย์ทดสอบ (เช่นใน AOSP) หรือคีย์รีลีส (ควบคุมโดยผู้ผลิตอุปกรณ์แต่ละราย)

DeviceDescriptor getCachedDeviceDescriptor ()

ส่งคืน DeviceDescriptor ที่แคชไว้หากอุปกรณ์ได้รับการจัดสรร มิฉะนั้นจะส่งคืน DeviceDescriptor ปัจจุบัน

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

ส่งคืน DeviceDescriptor ที่แคชไว้หากอุปกรณ์ได้รับการจัดสรร มิฉะนั้นจะส่งคืน DeviceDescriptor ปัจจุบัน

String[] getChildren (String path)

ทางเลือกในการใช้ IFileEntry ที่บางครั้งใช้งานไม่ได้เนื่องจากการอนุญาต

AbstractConnection getConnection ()

การเชื่อมต่อปัจจุบันที่เกี่ยวข้องกับอุปกรณ์

DeviceFoldableState getCurrentFoldableState ()

คืนค่าสถานะพับได้ปัจจุบันของอุปกรณ์หรือค่า null หากเกิดปัญหาบางอย่างขึ้น

int getCurrentUser ()

ส่งคืน id ของผู้ใช้ที่กำลังทำงานอยู่

String getDeviceClass ()

รับคลาสอุปกรณ์

long getDeviceDate ()

ส่งกลับวันที่ของอุปกรณ์ในหน่วยมิลลิวินาทีตั้งแต่ยุค

DeviceDescriptor getDeviceDescriptor ()

ส่งกลับ DeviceDescriptor จากข้อมูลอุปกรณ์เพื่อรับข้อมูลโดยไม่ต้องผ่านวัตถุอุปกรณ์จริง

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

ส่งกลับ DeviceDescriptor จากข้อมูลอุปกรณ์เพื่อรับข้อมูลโดยไม่ต้องผ่านวัตถุอุปกรณ์จริง

TestDeviceState getDeviceState ()

รับสถานะของอุปกรณ์

long getDeviceTimeOffset (Date date)

ตัวช่วยในการรับความแตกต่างของเวลาระหว่างอุปกรณ์กับ ERROR(/Date) ที่กำหนด

InputStreamSource getEmulatorOutput ()

รับสตรีมของโปรแกรมจำลอง stdout และ stderr

Process getEmulatorProcess ()

ส่งคืน ERROR(/Process) ที่สอดคล้องกับโปรแกรมจำลองนี้

final File getExecuteShellCommandLog ()

บันทึกที่มีบันทึก executeShellCommand(String) ทั้งหมด

long getExternalStoreFreeSpace ()

วิธีการช่วยเหลือเพื่อกำหนดจำนวนพื้นที่ว่างบนที่จัดเก็บข้อมูลภายนอกของอุปกรณ์

String getFastbootPath ()

ส่งคืนเส้นทางของไบนารี fastboot ที่ใช้อยู่

String getFastbootProductType ()

วิธีอำนวยความสะดวกในการรับประเภทผลิตภัณฑ์ของอุปกรณ์นี้เมื่ออยู่ในโหมด fastboot

String getFastbootProductVariant ()

วิธีอำนวยความสะดวกในการรับประเภทผลิตภัณฑ์ของอุปกรณ์นี้เมื่ออยู่ในโหมด fastboot

String getFastbootSerialNumber ()

ส่งกลับหมายเลขซีเรียลของโหมด fastboot

String getFastbootVariable (String variableName)

ดึงค่าตัวแปร fastboot ที่กำหนดจากอุปกรณ์

String getFastbootVersion ()

ส่งคืนสตริงเวอร์ชันของไบนารี fastboot ที่ใช้อยู่

IFileEntry getFileEntry (String path)

เรียกข้อมูลอ้างอิงไปยังไฟล์ระยะไกลบนอุปกรณ์

IFileEntry getFileEntry (FileListingService.FileEntry entry)

ตัวช่วยที่ไม่เป็นทางการในการรับ FileEntry จากเส้นทางที่ไม่ใช่รูท

getFoldableStates ()

ส่งกลับรายการสถานะการพับบนอุปกรณ์

IDevice getIDevice ()

ส่งกลับการอ้างอิงไปยัง ddmlib IDevice ที่เกี่ยวข้อง

getInstalledPackageNames ()

ดึงชื่อแพ็คเกจแอปพลิเคชันที่มีอยู่ในอุปกรณ์

long getIntProperty (String name, long defaultValue)

ส่งกลับค่าจำนวนเต็มของคุณสมบัติที่กำหนดจากอุปกรณ์

String getIpAddress ()

รับที่อยู่ IP ของอุปกรณ์

KeyguardControllerState getKeyguardState ()

ส่งคืนวัตถุเพื่อรับสถานะปัจจุบันของคีย์การ์ดหรือค่าว่างหากไม่รองรับ

long getLastExpectedRebootTimeMillis ()

ส่งคืนเวลาล่าสุดที่ Tradefed API ทริกเกอร์การรีบูตในหน่วยมิลลิวินาทีตั้งแต่ EPOCH ตามที่ส่งคืนโดย ERROR(/System#currentTimeMillis())

int getLaunchApiLevel ()

รับระดับ API ที่เปิดตัวครั้งแรกของอุปกรณ์

InputStreamSource getLogcat ()

คว้าสตรีมภาพรวมของข้อมูล logcat

InputStreamSource getLogcat (int maxBytes)

คว้าสตรีมสแน็ปช็อตของ maxBytes ล่าสุดของข้อมูล logcat ที่จับได้

InputStreamSource getLogcatDump ()

รับการถ่ายโอนข้อมูลของ logcat ปัจจุบันสำหรับอุปกรณ์

InputStreamSource getLogcatSince (long date)

รับสตรีมสแน็ปช็อตของข้อมูล logcat ที่บันทึกโดยเริ่มต้นวันที่ที่ระบุ

String getMacAddress ()

ส่งคืนที่อยู่ MAC ของอุปกรณ์ ค่า null หากล้มเหลวในการค้นหาจากอุปกรณ์

Integer getMainUserId ()

ส่งคืนรหัสผู้ใช้หลัก

getMainlineModuleInfo ()

รับข้อมูลเกี่ยวกับโมดูล mainline ที่ติดตั้งบนอุปกรณ์

int getMaxNumberOfRunningUsersSupported ()

รับจำนวนสูงสุดที่รองรับผู้ใช้ที่รันพร้อมกัน

int getMaxNumberOfUsersSupported ()

รับจำนวนผู้ใช้ที่รองรับสูงสุด

Process getMicrodroidProcess ()
IDeviceStateMonitor getMonitor ()

ส่งคืน IDeviceStateMonitor ที่เชื่อมโยงกับอุปกรณ์

String getMountPoint (String mountName)

ส่งกลับจุดเชื่อมต่อ

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

ส่งคืน MountPointInfo ที่สอดคล้องกับเส้นทางเมาต์พอยต์ที่ระบุ หรือ null หากพาธนั้นไม่มีสิ่งใดเมาต์ หรือมิฉะนั้นจะไม่ปรากฏใน /proc/mounts เป็นจุดเมานท์

getMountPointInfo ()

ส่งคืนข้อมูลที่แยกวิเคราะห์ใน /proc/mounts บนอุปกรณ์

TestDeviceOptions getOptions ()

เรียกตัวเลือกการทดสอบสำหรับอุปกรณ์

long getPartitionFreeSpace (String partition)

วิธีการช่วยเหลือเพื่อกำหนดจำนวนพื้นที่ว่างบนพาร์ติชันอุปกรณ์

Integer getPrimaryUserId ()

ส่งคืนรหัสผู้ใช้หลัก

ProcessInfo getProcessByName (String processName)

วิธีการช่วยเหลือเรียกใช้คำสั่ง "pidof" และ "stat" และส่งคืนวัตถุ ProcessInfo ด้วย PID และเวลาเริ่มต้นกระบวนการของกระบวนการที่กำหนด

String getProcessPid (String process)

คืนค่า pid ของบริการหรือค่า null หากเกิดข้อผิดพลาด

String getProductType ()

วิธีอำนวยความสะดวกในการรับประเภทผลิตภัณฑ์ของอุปกรณ์นี้

String getProductVariant ()

วิธีอำนวยความสะดวกในการรับผลิตภัณฑ์ย่อยของอุปกรณ์นี้

String getProperty (String name)

ดึงค่าคุณสมบัติที่กำหนดจากอุปกรณ์

ITestDevice.RecoveryMode getRecoveryMode ()

รับโหมดการกู้คืนปัจจุบันที่ใช้สำหรับอุปกรณ์

InputStreamSource getScreenshot (String format)

จับภาพหน้าจอจากอุปกรณ์

InputStreamSource getScreenshot (long displayId)

จับภาพหน้าจอจากอุปกรณ์ที่ระบุ ID ที่แสดง

InputStreamSource getScreenshot (String format, boolean rescale)

จับภาพหน้าจอจากอุปกรณ์

InputStreamSource getScreenshot ()

จับภาพหน้าจอจากอุปกรณ์

String getSerialNumber ()

วิธีที่สะดวกในการรับหมายเลขซีเรียลของอุปกรณ์นี้

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

ส่งกลับค่าของการตั้งค่าที่ร้องขอ

String getSetting (String namespace, String key)

ดู getSetting(int, String, String) และดำเนินการกับผู้ใช้ระบบ

String getSimOperator ()

ส่งคืนผู้ให้บริการซิมการ์ดหรือค่า null หากไม่มีหรืออุปกรณ์ไม่พร้อมใช้งาน

String getSimState ()

ส่งคืนสถานะซิมการ์ดหรือโมฆะหากไม่มีหรืออุปกรณ์ไม่พร้อมใช้งาน

getTombstones ()

ดึงและส่งคืนรายการหินหลุมฝังศพจากอุปกรณ์

long getTotalMemory ()

ส่งคืนขนาดหน่วยความจำฟิสิคัลทั้งหมดเป็นไบต์หรือ -1 ในกรณีที่เกิดข้อผิดพลาดภายใน

getUninstallablePackageNames ()

เรียกค้นชื่อแพ็กเกจแอปพลิเคชันที่สามารถถอนการติดตั้งได้

boolean getUseFastbootErase ()

รับว่าจะใช้การลบ fastboot หรือรูปแบบ fastboot เพื่อล้างพาร์ติชันบนอุปกรณ์

int getUserFlags (int userId)

ค้นหาและส่งคืนแฟล็กของผู้ใช้ที่กำหนด

getUserInfos ()

รับแผนที่ของ useId ไปยัง UserInfo บนอุปกรณ์

int getUserSerialNumber (int userId)

ส่งคืนหมายเลขซีเรียลที่เกี่ยวข้องกับ userId หากพบ -10,000 ในกรณีอื่นๆ

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

ประมวลผล DeviceEvent ที่กำหนด

ประมวลผล DeviceEvent ซึ่งอาจเปลี่ยนหรือไม่เปลี่ยนอุปกรณ์นี้เป็นสถานะการจัดสรรใหม่ก็ได้

boolean hasFeature (String feature)

ตรวจดูว่ามีคุณลักษณะใดในอุปกรณ์หรือไม่

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

ติดตั้งแพ็คเกจ Android บนอุปกรณ์

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

ติดตั้งแพ็คเกจ Android บนอุปกรณ์

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

ติดตั้งแพ็คเกจ Android บนอุปกรณ์สำหรับผู้ใช้ที่กำหนด

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

ติดตั้งแพ็คเกจ Android บนอุปกรณ์สำหรับผู้ใช้ที่กำหนด

boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

ตรวจสอบว่าแพลตฟอร์มบนอุปกรณ์รองรับการแจงนับแอปหรือไม่

boolean isBypassLowTargetSdkBlockSupported ()

ตรวจสอบว่าแพลตฟอร์มบนอุปกรณ์รองรับการเลี่ยงผ่านบล็อก sdk เป้าหมายต่ำในการติดตั้งแอปหรือไม่

boolean isDeviceEncrypted ()

ส่งคืนหากอุปกรณ์ได้รับการเข้ารหัส

boolean isDirectory (String path)

คืนค่า True หากพาธบนอุปกรณ์เป็นไดเร็กทอรี หากเป็นเท็จ หากไม่ใช่

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

ส่งกลับหากอุปกรณ์รองรับการเข้ารหัส

boolean isExecutable (String fullPath)

คืนค่า True หากพาธไฟล์บนอุปกรณ์เป็นไฟล์เรียกทำงาน หากเป็นเท็จ หากไม่เป็นเช่นนั้น

boolean isFastbootEnabled ()

ส่งคืนหาก fastboot พร้อมใช้งานสำหรับอุปกรณ์

boolean isHeadless ()

คืนค่าจริงหากอุปกรณ์ไม่มีส่วนหัว (ไม่มีหน้าจอ) หากเป็นเท็จมิฉะนั้น

boolean isHeadlessSystemUserMode ()

ส่งคืนว่าอุปกรณ์ใช้โหมดผู้ใช้ระบบหัวขาดหรือไม่

boolean isMainUserPermanentAdmin ()

ส่งคืนว่าผู้ใช้หลักเป็นผู้ดูแลระบบถาวรและไม่สามารถลบหรือลดระดับเป็นสถานะที่ไม่ใช่ผู้ดูแลระบบ

boolean isMultiUserSupported ()

กำหนดว่ารองรับผู้ใช้หลายคนหรือไม่

boolean isPackageInstalled (String packageName, String userId)

ค้นหาอุปกรณ์สำหรับชื่อแพ็คเกจที่กำหนดและรหัสผู้ใช้ที่กำหนดเพื่อตรวจสอบว่าติดตั้งอยู่หรือไม่สำหรับผู้ใช้รายนั้น

boolean isPackageInstalled (String packageName)

สอบถามอุปกรณ์สำหรับชื่อแพ็คเกจที่กำหนดเพื่อตรวจสอบว่าติดตั้งอยู่หรือไม่

boolean isRuntimePermissionSupported ()

ตรวจสอบว่าแพลตฟอร์มบนอุปกรณ์รองรับการให้สิทธิ์รันไทม์หรือไม่

boolean isStateBootloaderOrFastbootd ()

คืนค่าจริงหากอุปกรณ์อยู่ใน TestDeviceState#FASTBOOT หรือ TestDeviceState.FASTBOOTD

boolean isUserRunning (int userId)

ตรวจสอบว่าผู้ใช้ที่กำหนดกำลังทำงานอยู่หรือไม่

boolean isUserSecondary (int userId)

ส่งคืนว่าผู้ใช้ที่ระบุเป็นผู้ใช้รองตามแฟล็กหรือไม่

boolean isUserVisible (int userId)

ตรวจสอบว่ามองเห็นผู้ใช้ที่ระบุหรือไม่

boolean isUserVisibleOnDisplay (int userId, int displayId)

ตรวจสอบว่ามองเห็นผู้ใช้ที่ระบุในจอแสดงผลที่กำหนดหรือไม่

boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

ส่งคืนว่าอุปกรณ์อนุญาตให้ผู้ใช้เริ่มต้นมองเห็นได้ในพื้นหลังหรือไม่ใน ERROR(/java.android.view.Display#DEFAULT_DISPLAY)

boolean isVisibleBackgroundUsersSupported ()

ส่งคืนว่าอุปกรณ์อนุญาตให้ผู้ใช้เริ่มต้นมองเห็นได้ในพื้นหลังหรือไม่

boolean isWifiEnabled ()

ทดสอบว่าเปิดใช้งาน wifi หรือไม่

listDisplayIds ()

รวบรวมรายชื่อ display id ที่มีอยู่บนอุปกรณ์ตามที่รายงานโดย "dumpsys SurfaceFlinger"

listDisplayIdsForStartingVisibleBackgroundUsers ()

รับรายการจอแสดงผลที่สามารถใช้เพื่อ start a user visible in the background

listUsers ()

รับรายชื่อผู้ใช้บนอุปกรณ์

boolean logAnrs ( ITestLogger logger)

รวบรวมและบันทึก ANR จากอุปกรณ์

boolean logBugreport (String dataName, ITestLogger listener)

วิธีการช่วยเหลือในการรายงานข้อผิดพลาดและบันทึกไปยังนักข่าว

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

บันทึกข้อความใน logcat ของอุปกรณ์

void nonBlockingReboot ()

ออกคำสั่งเพื่อรีบูตอุปกรณ์และส่งคืนเมื่อคำสั่งเสร็จสิ้น และเมื่อ adb มองไม่เห็นอุปกรณ์อีกต่อไป

void postAdbRootAction ()

แทนที่หากอุปกรณ์ต้องการการดำเนินการบางอย่างหลังจากรูท adb และก่อนที่อุปกรณ์จะกลับมาออนไลน์

void postAdbUnrootAction ()

แทนที่หากอุปกรณ์ต้องการการดำเนินการเฉพาะหลังจาก adb unroot และก่อนที่อุปกรณ์จะกลับมาออนไลน์

void postBootSetup ()

ทำตามคำแนะนำเพื่อกำหนดค่าอุปกรณ์สำหรับการทดสอบหลังจากการบู๊ตทุกครั้ง

void postInvocationTearDown (Throwable exception)

ขั้นตอนเพิ่มเติมสำหรับการล้างข้อมูลที่จำเป็นเฉพาะอุปกรณ์ซึ่งจะดำเนินการหลังจากการเรียกใช้เสร็จสิ้น

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

ขั้นตอนเพิ่มเติมสำหรับการตั้งค่าที่จำเป็นเฉพาะอุปกรณ์ซึ่งจะดำเนินการบนอุปกรณ์ก่อนขั้นตอนการเรียกใช้

boolean pullDir (String deviceFilePath, File localDir)

ดึงเนื้อหาไดเร็กทอรีซ้ำจากอุปกรณ์

boolean pullFile (String remoteFilePath, File localFile)

ดึงไฟล์ออกจากอุปกรณ์

File pullFile (String remoteFilePath, int userId)

ดึงไฟล์ออกจากอุปกรณ์ เก็บไว้ในเครื่องชั่วคราว ERROR(/File) และส่งกลับ File นั้น

File pullFile (String remoteFilePath)

ดึงไฟล์ออกจากอุปกรณ์ เก็บไว้ในเครื่องชั่วคราว ERROR(/File) และส่งกลับ File นั้น

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

ดึงไฟล์ออกจากอุปกรณ์

String pullFileContents (String remoteFilePath)

ดึงไฟล์ออกจากอุปกรณ์และส่งคืนเนื้อหา

File pullFileFromExternal (String remoteFilePath)

วิธีอำนวยความสะดวกในการดึงไฟล์จากที่จัดเก็บข้อมูลภายนอกของอุปกรณ์ จัดเก็บไว้ใน ERROR(/File) ชั่วคราวในเครื่อง และส่งคืนการอ้างอิงไปยัง File นั้น

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

พุชเนื้อหาไดเร็กทอรีซ้ำไปยังอุปกรณ์โดยไม่รวมไดเร็กทอรีบางตัวที่ถูกกรอง

boolean pushDir (File localFileDir, String deviceFilePath)

พุชเนื้อหาไดเร็กทอรีซ้ำไปยังอุปกรณ์

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

ตัวแปรของ pushFile(File, String) ซึ่งสามารถเลือกที่จะพิจารณาประเมินความต้องการสำหรับผู้ให้บริการเนื้อหา

boolean pushFile (File localFile, String remoteFilePath)

พุชไฟล์ไปยังอุปกรณ์

boolean pushString (String contents, String remoteFilePath)

ไฟล์พุชที่สร้างจากสตริงไปยังอุปกรณ์

void reboot (String reason)

รีบูตอุปกรณ์เข้าสู่โหมด adb พร้อม reason ที่กำหนดให้คงอยู่ตลอดการรีบูต

void reboot ()

รีบูตอุปกรณ์เข้าสู่โหมด adb

void rebootIntoBootloader ()

รีบูตอุปกรณ์เข้าสู่โหมด bootloader

void rebootIntoFastbootd ()

รีบูตอุปกรณ์เข้าสู่โหมด fastbootd

void rebootIntoRecovery ()

รีบูตอุปกรณ์เข้าสู่โหมดการกู้คืน adb

void rebootIntoSideload ()

รีบูตอุปกรณ์เข้าสู่โหมด adb sideload (โปรดทราบว่านี่เป็นโหมดพิเศษภายใต้การกู้คืน)

บล็อกจนกว่าอุปกรณ์จะเข้าสู่โหมดไซด์โหลด

void rebootIntoSideload (boolean autoReboot)

รีบูตอุปกรณ์เข้าสู่โหมด adb sideload (โปรดทราบว่านี่เป็นโหมดพิเศษภายใต้การกู้คืน)

บล็อกจนกว่าอุปกรณ์จะเข้าสู่โหมดไซด์โหลด

void rebootUntilOnline ()

ทางเลือกในการ reboot() ที่บล็อกเฉพาะจนกว่าอุปกรณ์จะออนไลน์เช่น adb มองเห็นได้

void rebootUntilOnline (String reason)

ทางเลือกในการ reboot() ที่บล็อกเฉพาะจนกว่าอุปกรณ์จะออนไลน์เช่น adb มองเห็นได้

void rebootUserspace ()

รีบูตเฉพาะส่วน userspace ของอุปกรณ์

void rebootUserspaceUntilOnline ()

ทางเลือกอื่นในการ rebootUserspace() ()} ที่บล็อกเฉพาะจนกว่าอุปกรณ์จะออนไลน์ เช่น adb มองเห็นได้

boolean recoverDevice ()

พยายามกู้คืนการสื่อสารของอุปกรณ์

void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

ลงทะเบียน IDeviceActionReceiver สำหรับอุปกรณ์นี้

void remountSystemWritable ()

ทำให้พาร์ติชันระบบบนอุปกรณ์สามารถเขียนได้

void remountVendorWritable ()

ทำให้พาร์ติชันผู้ขายบนอุปกรณ์สามารถเขียนได้

boolean removeAdmin (String componentName, int userId)

ลบผู้ดูแลระบบอุปกรณ์ที่กำหนดในผู้ใช้ที่กำหนดและคืน true หากสำเร็จ หากเป็น false ฉะนั้น

void removeOwners ()

ลบเจ้าของโปรไฟล์อุปกรณ์ที่มีอยู่ทั้งหมดด้วยความพยายามที่ดีที่สุด

boolean removeUser (int userId)

ลบผู้ใช้ที่ระบุออกจากอุปกรณ์

void resetContentProviderSetup ()

รีเซ็ตแฟล็กสำหรับการตั้งค่าผู้ให้บริการเนื้อหาเพื่อทริกเกอร์อีกครั้ง

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

วิธีการที่สะดวกสำหรับการดำเนินการ ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) โดยมีผู้ฟังอย่างน้อยหนึ่งรายที่ส่งผ่านเป็นพารามิเตอร์

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

เรียกใช้การทดสอบเครื่องมือและให้การกู้คืนอุปกรณ์

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

เหมือนกับ ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) แต่รันการทดสอบ สำหรับผู้ใช้ที่กำหนด

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

เหมือนกับ ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) แต่รันการทดสอบสำหรับผู้ใช้ที่กำหนด

void setConfiguration ( IConfiguration configuration)

ใส่ IConfiguration ที่ใช้งานอยู่

void setDate (Date date)

ตั้งวันที่บนอุปกรณ์

หมายเหตุ: การตั้งค่าวันที่บนอุปกรณ์จำเป็นต้องรูท

boolean setDeviceOwner (String componentName, int userId)

ตั้งค่าองค์ประกอบผู้ดูแลระบบอุปกรณ์เป็นเจ้าของอุปกรณ์ในผู้ใช้ที่กำหนด

void setDeviceState ( TestDeviceState deviceState)

อัปเดตสถานะของอุปกรณ์

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

สำหรับอีมูเลเตอร์ให้ตั้งค่า SizeLimitedOutputStream เพื่อบันทึกเอาต์พุต

void setEmulatorProcess (Process p)

ตั้งค่า ERROR(/Process) เมื่ออุปกรณ์นี้เป็นโปรแกรมจำลอง

void setFastbootEnabled (boolean fastbootEnabled)

ตั้งค่าตัวเลือก fastboot สำหรับอุปกรณ์

void setFastbootPath (String fastbootPath)

กำหนดเส้นทางไปยังไบนารี fastboot ที่ควรใช้

void setIDevice (IDevice newDevice)

อัปเดต IDevice ที่เชื่อมโยงกับ ITestDevice นี้

void setLogStartDelay (int delay)

ตั้งเวลาเป็น ms เพื่อรอก่อนที่จะเริ่มการจับภาพ logcat สำหรับอุปกรณ์ออนไลน์

void setOptions ( TestDeviceOptions options)

ตั้งค่า TestDeviceOptions สำหรับอุปกรณ์

boolean setProperty (String propKey, String propValue)

ตั้งค่าคุณสมบัติที่กำหนดบนอุปกรณ์

void setRecovery ( IDeviceRecovery recovery)

ตั้งค่า IDeviceRecovery เพื่อใช้สำหรับอุปกรณ์นี้

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

ตั้งค่าโหมดการกู้คืนปัจจุบันเพื่อใช้กับอุปกรณ์

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

ดู setSetting(int, String, String, String) และดำเนินการกับผู้ใช้ระบบ

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

เพิ่มการตั้งค่าให้กับเนมสเปซของผู้ใช้ที่กำหนด

void setTestLogger ( ITestLogger testLogger)

ใส่อินสแตนซ์ ITestLogger

void setUseFastbootErase (boolean useFastbootErase)

ตั้งค่าว่าจะใช้การลบ fastboot หรือรูปแบบ fastboot เพื่อล้างพาร์ติชันบนอุปกรณ์

void startLogcat ()

เริ่มบันทึกเอาต์พุต logcat จากอุปกรณ์ในพื้นหลัง

boolean startUser (int userId)

เริ่มต้นผู้ใช้ที่กำหนดในพื้นหลังหากหยุดอยู่ในขณะนี้

boolean startUser (int userId, boolean waitFlag)

เริ่มต้นผู้ใช้ที่กำหนดในพื้นหลังหากหยุดอยู่ในขณะนี้

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

เริ่มผู้ใช้ที่กำหนดในพื้นหลัง มองเห็นได้ในจอแสดงผลที่กำหนด (เช่น อนุญาตให้ผู้ใช้เริ่มกิจกรรมในจอแสดงผลนั้น)

void stopEmulatorOutput ()

ปิดและลบเอาต์พุตตัวจำลอง

void stopLogcat ()

หยุดบันทึกเอาต์พุต logcat จากอุปกรณ์ และละทิ้งข้อมูล logcat ที่บันทึกไว้ในปัจจุบัน

boolean stopUser (int userId)

หยุดผู้ใช้ที่กำหนด

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

หยุดผู้ใช้ที่กำหนด

String switchToAdbTcp ()

เปลี่ยนอุปกรณ์เป็นโหมด adb-over-tcp

boolean switchToAdbUsb ()

เปลี่ยนอุปกรณ์เป็น adb ผ่านโหมด usb

boolean switchUser (int userId)

เปลี่ยนไปใช้รหัสผู้ใช้อื่นโดยหมดเวลาเริ่มต้น

boolean switchUser (int userId, long timeout)

เปลี่ยนไปใช้ userId อื่นโดยหมดเวลาที่กำหนดไว้ตามกำหนดเวลา

boolean syncFiles (File localFileDir, String deviceFilePath)

เพิ่มการซิงค์เนื้อหาของไดเร็กทอรีไฟล์ในเครื่องกับอุปกรณ์

Bugreport takeBugreport ()

รับรายงานจุดบกพร่องและส่งคืนภายในวัตถุรายงานจุด Bugreport เพื่อจัดการ

String uninstallPackage (String packageName)

ถอนการติดตั้งแพ็คเกจ Android จากอุปกรณ์

String uninstallPackageForUser (String packageName, int userId)

ถอนการติดตั้งแพ็คเกจ Android จากอุปกรณ์สำหรับผู้ใช้ที่ระบุ

boolean unlockDevice ()

ปลดล็อกอุปกรณ์หากอุปกรณ์อยู่ในสถานะเข้ารหัส

boolean waitForBootComplete (long timeOut)

บล็อกจนกว่าจะมีการตั้งค่าแฟล็กการบู๊ตเสร็จสมบูรณ์ของอุปกรณ์

boolean waitForDeviceAvailable ()

รอให้อุปกรณ์ตอบสนองและพร้อมสำหรับการทดสอบ

boolean waitForDeviceAvailable (long waitTime)

รอให้อุปกรณ์ตอบสนองและพร้อมสำหรับการทดสอบ

boolean waitForDeviceAvailableInRecoverPath (long waitTime)

รอให้อุปกรณ์ตอบสนองและพร้อมใช้งานโดยไม่ต้องพิจารณาเส้นทางการกู้คืน

void waitForDeviceBootloader ()

บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน fastboot

boolean waitForDeviceInRecovery (long waitTime)

บล็อกเพื่อให้อุปกรณ์อยู่ในสถานะ 'การกู้คืน adb' (โปรดทราบว่าสิ่งนี้แตกต่างจาก IDeviceRecovery )

boolean waitForDeviceInSideload (long waitTime)

บล็อกเพื่อให้อุปกรณ์อยู่ในสถานะ "adb sideload"

boolean waitForDeviceNotAvailable (long waitTime)

บล็อกไม่ให้อุปกรณ์พร้อมใช้งาน เช่น ขาดหายไปจาก adb

void waitForDeviceOnline ()

บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน adb

void waitForDeviceOnline (long waitTime)

บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน adb

boolean waitForDeviceShell (long waitTime)

รอให้อุปกรณ์ตอบสนองต่อคำสั่ง adb shell พื้นฐาน

วิธีการป้องกัน

String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)

สร้างคำสั่ง OS สำหรับเซสชันคำสั่ง adb shell และ args ที่กำหนด

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

สร้าง RebootDeviceAction เพื่อใช้เมื่อดำเนินการรีบูต

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

ทำการรีบูต adb

void ensureRuntimePermissionSupported ()

วิธีตัวช่วยโยนข้อยกเว้นหากไม่รองรับการอนุญาตรันไทม์

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

รับอินสแตนซ์ RunUtil เพื่อใช้งาน

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

ดึงคุณสมบัติของอุปกรณ์จากแคช ddmlib ตามค่าเริ่มต้น และถอยกลับเป็น `adb shell getprop' หรือ 'fastboot getvar' ขึ้นอยู่กับว่าอุปกรณ์นั้นอยู่ใน Fastboot หรือไม่

boolean isInRebootCallback ()

ส่งคืนว่ารีบูตการโทรกลับกำลังดำเนินการอยู่หรือไม่

boolean isNewer (File localFile, IFileEntry entry)

คืน true หากไฟล์ในเครื่องใหม่กว่าไฟล์ระยะไกล

void notifyRebootEnded ()

แจ้ง IDeviceActionReceiver ทั้งหมดเกี่ยวกับเหตุการณ์สิ้นสุดการรีบูต

void notifyRebootStarted ()

แจ้ง IDeviceActionReceiver ทั้งหมดเกี่ยวกับเหตุการณ์เริ่มต้นการรีบูต

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

ดำเนินการบนอุปกรณ์นี้

void postAdbReboot ()

การดำเนินการเพิ่มเติมที่เป็นไปได้ซึ่งสามารถทำได้หลังจากรีบูต

void prePostBootSetup ()

อนุญาตให้อุปกรณ์แต่ละประเภท (AndroidNativeDevice, TestDevice) แทนที่วิธีนี้สำหรับการตั้งค่าหลังการบู๊ตเฉพาะ

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

ตั้งค่าอินสแตนซ์นาฬิกาที่จะใช้

void setMicrodroidProcess (Process process)

ทำเครื่องหมาย TestDevice เป็น microdroid และตั้งค่า CID

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

ดำเนินการคำสั่ง fastboot อย่างง่ายด้วยตัวแปรสภาพแวดล้อมและรายงานสถานะของคำสั่ง

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

ดำเนินการคำสั่ง fastboot อย่างง่ายและรายงานสถานะของคำสั่ง

boolean waitForDeviceNotAvailable (String operationDesc, long time)

รอดูว่าอุปกรณ์จะใช้งานไม่ได้ (หยุดการรายงานไปยัง adb)

ค่าคงที่

INVALID_USER_ID

public static final int INVALID_USER_ID

ค่าที่ส่งคืนสำหรับรหัสผู้ใช้ที่ไม่ถูกต้อง/ไม่พบ: UserHandle กำหนดค่า -10000

ค่าคงที่: -10,000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

ค่าคงที่: 5,000 (0x0000000000001388)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

จำนวนคำสั่งเริ่มต้นที่พยายามดำเนินการอีกครั้ง

ค่าคงที่: 2 (0x00000002)

เขตข้อมูล

SD_CARD

protected static final String SD_CARD

STORAGE_EMULATED

protected static final String STORAGE_EMULATED

ตัวเลือก

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

ผู้สร้างสาธารณะ

เนทีฟดีไวซ์

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

สร้าง TestDevice

พารามิเตอร์
device IDevice : IDevice ที่เกี่ยวข้อง

stateMonitor IDeviceStateMonitor : กลไก IDeviceStateMonitor ที่จะใช้

allocationMonitor IDeviceMonitor : IDeviceMonitor เพื่อแจ้งการเปลี่ยนแปลงสถานะการจัดสรร สามารถเป็นโมฆะ

วิธีการสาธารณะ

สามารถสลับเป็น HeadlessSystemUser

public boolean canSwitchToHeadlessSystemUser ()

ส่งคืนว่าอนุญาตให้เปลี่ยนเป็นผู้ใช้ SYSTEM ที่ไม่มีหัวหรือไม่

ส่งคืน
boolean

พ่น
DeviceNotAvailableException

ตรวจสอบApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

ตรวจสอบว่าคุณลักษณะใดรองรับหรือไม่โดยพิจารณาจากระดับที่รองรับน้อยที่สุด วิธีนี้คำนึงถึงคุณลักษณะที่ยังไม่ได้เผยแพร่ ก่อนที่ระดับ API จะเพิ่มขึ้น

พารามิเตอร์
strictMinLevel int : ระดับต่ำสุดที่เข้มงวดที่สนับสนุนคุณลักษณะนี้

ส่งคืน
boolean จริงหากรองรับระดับ เป็นอย่างอื่น

พ่น
DeviceNotAvailableException

ตรวจสอบการเชื่อมต่อ

public boolean checkConnectivity ()

ตรวจสอบว่าอุปกรณ์มีการเชื่อมต่อเครือข่าย

ส่งคืน
boolean true หากอุปกรณ์มีการเชื่อมต่อเครือข่ายที่ใช้งานได้ false

พ่น
DeviceNotAvailableException

clearErrorDialogs

public boolean clearErrorDialogs ()

พยายามปิดกล่องโต้ตอบแสดงข้อผิดพลาดที่แสดงอยู่บน UI ของอุปกรณ์ในปัจจุบัน

ส่งคืน
boolean true ถ้าไม่มีไดอะล็อกหรือไดอะล็อกถูกล้างสำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

clearLastConnectedWifiNetwork

public void clearLastConnectedWifiNetwork ()

ล้างเครือข่าย wifi ที่เชื่อมต่อล่าสุด ควรเรียกสิ่งนี้เมื่อเริ่มการร้องขอใหม่เพื่อหลีกเลี่ยงการเชื่อมต่อกับเครือข่าย wifi ที่ใช้ในการทดสอบครั้งก่อนหลังจากรีบูตอุปกรณ์

เคลียร์ Logcat

public void clearLogcat ()

ลบข้อมูล logcat ที่สะสมไว้

สิ่งนี้มีประโยชน์สำหรับกรณีที่คุณต้องการให้แน่ใจว่า ITestDevice#getLogcat() ส่งคืนเฉพาะข้อมูลบันทึกที่สร้างหลังจากจุดหนึ่งเท่านั้น (เช่น หลังจากแฟลชบิลด์อุปกรณ์ใหม่ เป็นต้น)

connectToWifiเครือข่าย

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

เชื่อมต่อกับเครือข่าย wifi

เปิด wifi และบล็อกจนกว่าจะทำการเชื่อมต่อสำเร็จกับหนึ่งในเครือข่าย wifi ที่ระบุในแผนที่ wifiSsidToPsk เมื่อสร้างการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่าจะมีการเรียก ITestDevice#disconnectFromWifi() หรือ ITestDevice#clearLastConnectedWifiNetwork()

พารามิเตอร์
wifiSsidToPsk : แผนที่ของ wifi SSIDs กับรหัสผ่าน

scanSsid boolean : จะสแกนหา SSID ที่ซ่อนอยู่สำหรับเครือข่ายนี้หรือไม่

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

connectToWifiเครือข่าย

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

เชื่อมต่อกับเครือข่าย wifi

เปิด wifi และบล็อกจนกว่าการเชื่อมต่อสำเร็จกับเครือข่าย wifi ที่ระบุ เมื่อสร้างการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่าจะมีการเรียก ITestDevice#disconnectFromWifi() หรือ ITestDevice#clearLastConnectedWifiNetwork()

พารามิเตอร์
wifiSsid String : wifi ssid ที่จะเชื่อมต่อ

wifiPsk String : วลีรหัสผ่าน PSK หรือ null หากไม่ได้เข้ารหัส

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

connectToWifiเครือข่าย

public boolean connectToWifiNetwork ( wifiSsidToPsk)

เชื่อมต่อกับเครือข่าย wifi

เปิด wifi และบล็อกจนกว่าจะทำการเชื่อมต่อสำเร็จกับหนึ่งในเครือข่าย wifi ที่ระบุในแผนที่ wifiSsidToPsk เมื่อสร้างการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่าจะมีการเรียก ITestDevice#disconnectFromWifi() หรือ ITestDevice#clearLastConnectedWifiNetwork()

พารามิเตอร์
wifiSsidToPsk : แผนที่ของ wifi SSIDs กับรหัสผ่าน

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

connectToWifiเครือข่าย

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

เชื่อมต่อกับเครือข่าย wifi

เปิด wifi และบล็อกจนกว่าการเชื่อมต่อสำเร็จกับเครือข่าย wifi ที่ระบุ เมื่อสร้างการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่าจะมีการเรียก ITestDevice#disconnectFromWifi() หรือ ITestDevice#clearLastConnectedWifiNetwork()

พารามิเตอร์
wifiSsid String : wifi ssid ที่จะเชื่อมต่อ

wifiPsk String : วลีรหัสผ่าน PSK หรือ null หากไม่ได้เข้ารหัส

scanSsid boolean : จะสแกนหา SSID ที่ซ่อนอยู่สำหรับเครือข่ายนี้หรือไม่

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

connectToWifiNetworkถ้าจำเป็น

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

ตัวแปรของ connectToWifiNetwork(String, String) ที่เชื่อมต่อเฉพาะในกรณีที่อุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน

พารามิเตอร์
scanSsid boolean : จะสแกนหา SSID ที่ซ่อนอยู่สำหรับเครือข่ายนี้หรือไม่

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

connectToWifiNetworkถ้าจำเป็น

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

ตัวแปรของ connectToWifiNetwork(String, String) ที่เชื่อมต่อเฉพาะในกรณีที่อุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน

ส่งคืน
boolean true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น

พ่น
DeviceNotAvailableException

สร้างผู้ใช้

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

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา

พารามิเตอร์
name String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์

guest boolean : เปิดใช้งานแฟล็กผู้ใช้ --guest ระหว่างการสร้าง

ephemeral boolean : เปิดใช้งานแฟล็กผู้ใช้ -- ชั่วคราวระหว่างการสร้าง

ส่งคืน
int รหัสของผู้ใช้ที่สร้างขึ้น

พ่น
DeviceNotAvailableException

สร้างผู้ใช้

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

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา

พารามิเตอร์
name String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์

guest boolean : เปิดใช้งานแฟล็กผู้ใช้ --guest ระหว่างการสร้าง

ephemeral boolean : เปิดใช้งานแฟล็กผู้ใช้ -- ชั่วคราวระหว่างการสร้าง

forTesting boolean : เปิดใช้งานแฟล็กทดสอบ --for-testing ระหว่างการสร้าง

ส่งคืน
int รหัสของผู้ใช้ที่สร้างขึ้น

พ่น
DeviceNotAvailableException

สร้างผู้ใช้

public int createUser (String name)

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0

พารามิเตอร์
name String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์

ส่งคืน
int จำนวนเต็มสำหรับรหัสผู้ใช้ที่สร้างขึ้น

พ่น
DeviceNotAvailableException

สร้าง UserNoThrow

public int createUserNoThrow (String name)

สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0

พารามิเตอร์
name String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์

ส่งคืน
int จำนวนเต็มสำหรับ ID ผู้ใช้ที่สร้างขึ้นหรือ -1 สำหรับข้อผิดพลาด

พ่น
DeviceNotAvailableException

ลบไฟล์

public void deleteFile (String deviceFilePath)

วิธีตัวช่วยลบไฟล์หรือไดเรกทอรีในเครื่อง

พารามิเตอร์
deviceFilePath String : เส้นทางที่สมบูรณ์ของไฟล์บนอุปกรณ์

พ่น
DeviceNotAvailableException

ยกเลิกการลงทะเบียน DeviceActionReceiver

public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

ลบ IDeviceActionReceiver ที่ลงทะเบียน

พารามิเตอร์
deviceActionReceiver IDeviceActionReceiver : IDeviceActionReceiver ซึ่งจะถูกลบออก

deviceSoftRestarted

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

วิธีตัวช่วยเพื่อตรวจสอบว่าอุปกรณ์รีสตาร์ทอย่างนุ่มนวลหรือไม่โดยเปรียบเทียบ system_server ปัจจุบันกับ system_server ProcessInfo ก่อนหน้า ใช้ getProcessByName(String) เพื่อรับ ProcessInfo

พารามิเตอร์
prevSystemServerProcess ProcessInfo : system_server ก่อนหน้าประมวลผล ProcessInfo

ส่งคืน
boolean true หากอุปกรณ์รีสตาร์ทอย่างนุ่มนวล

พ่น
DeviceNotAvailableException

deviceSoftRestartedตั้งแต่

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

วิธีการช่วยเหลือเพื่อตรวจสอบว่าอุปกรณ์รีสตาร์ทอย่างนุ่มนวลตั้งแต่เวลา UTC ตั้งแต่ epoch จากอุปกรณ์และ ERROR(/TimeUnit) Soft-Restart หมายถึง system_server ที่รีสตาร์ทนอกการฮาร์ดรีบูตอุปกรณ์ (เช่น: การรีบูตที่ร้องขอ) สามารถรับ utcEpochTime ของอุปกรณ์ปัจจุบันในหน่วยมิลลิวินาทีได้โดยใช้วิธี getDeviceDate()

พารามิเตอร์
utcEpochTime long : เวลาของอุปกรณ์เป็นวินาทีตั้งแต่ยุค

timeUnit TimeUnit : หน่วยเวลา TimeUnit สำหรับ utcEpochTime ที่กำหนด

ส่งคืน
boolean true หากอุปกรณ์รีสตาร์ทอย่างนุ่มนวล

พ่น
DeviceNotAvailableException

ปิดการใช้งาน AdbRoot

public boolean disableAdbRoot ()

ปิด adb root

การปิดใช้งาน adb root อาจทำให้อุปกรณ์ตัดการเชื่อมต่อจาก adb วิธีนี้จะบล็อกจนกว่าอุปกรณ์จะพร้อมใช้งาน

ส่งคืน
boolean true ถ้าสำเร็จ

พ่น
DeviceNotAvailableException

ปิดการใช้งานKeyguard

public void disableKeyguard ()

พยายามปิดใช้งานคีย์การ์ด

ขั้นแรกให้รอการป้อนข้อมูลให้พร้อม ซึ่งจะเกิดขึ้นในช่วงเวลาเดียวกับที่อุปกรณ์รายงานว่า BOOT_COMPLETE เห็นได้ชัดว่าเป็นแบบอะซิงโครนัส เนื่องจากการใช้เฟรมเวิร์กในปัจจุบันมีสภาวะการแย่งชิงเป็นครั้งคราว จากนั้นคำสั่งจะถูกส่งไปปิดคีย์การ์ด (ใช้ได้กับอันที่ไม่ปลอดภัยเท่านั้น)

พ่น
DeviceNotAvailableException

ปิดการใช้งาน NetworkMonitor

public boolean disableNetworkMonitor ()

ปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์

ส่งคืน
boolean true หากปิดใช้งานการตรวจสอบได้สำเร็จ false ถ้ามันล้มเหลว

พ่น
DeviceNotAvailableException

ตัดการเชื่อมต่อจาก Wifi

public boolean disconnectFromWifi ()

ตัดการเชื่อมต่อจากเครือข่าย wifi

ลบเครือข่ายทั้งหมดออกจากรายการเครือข่ายที่รู้จักและปิดใช้งาน wifi

ส่งคืน
boolean true หากตัดการเชื่อมต่อจากเครือข่าย wifi สำเร็จ false หากการตัดการเชื่อมต่อล้มเหลว

พ่น
DeviceNotAvailableException

มีไฟล์อยู่

public boolean doesFileExist (String deviceFilePath, 
                int userId)

วิธีการช่วยเหลือเพื่อตรวจสอบว่ามีไฟล์บนอุปกรณ์สำหรับผู้ใช้ที่กำหนดหรือไม่

พารามิเตอร์
deviceFilePath String : เส้นทางที่แน่นอนของไฟล์บนอุปกรณ์ที่จะตรวจสอบ

userId int : รหัสผู้ใช้ที่ใช้ตรวจสอบการมีอยู่ของไฟล์

ส่งคืน
boolean true ถ้ามีไฟล์อยู่ มิฉะนั้นจะ false

พ่น
DeviceNotAvailableException

มีไฟล์อยู่

public boolean doesFileExist (String deviceFilePath)

วิธีการช่วยเหลือเพื่อตรวจสอบว่ามีไฟล์บนอุปกรณ์อยู่หรือไม่

พารามิเตอร์
deviceFilePath String : เส้นทางที่แน่นอนของไฟล์บนอุปกรณ์ที่จะตรวจสอบ

ส่งคืน
boolean true ถ้ามีไฟล์อยู่ มิฉะนั้นจะ false

พ่น
DeviceNotAvailableException

กองขยะ

public File dumpHeap (String process, 
                String devicePath)

พยายามดัมพ์ฮีปจาก system_server เป็นความรับผิดชอบของผู้โทรในการล้างไฟล์ที่ทิ้ง

พารามิเตอร์
process String : ชื่อของกระบวนการอุปกรณ์ที่จะถ่ายโอนข้อมูลบน

devicePath String : เส้นทางบนอุปกรณ์ที่จะวางการถ่ายโอนข้อมูล นี่จะต้องเป็นตำแหน่งที่ได้รับอนุญาต

ส่งคืน
File ERROR(/File) ที่มีรายงาน เป็นโมฆะหากมีบางอย่างล้มเหลว

พ่น
DeviceNotAvailableException

เปิดใช้งาน AdbRoot

public boolean enableAdbRoot ()

เปิด adb root หากการตั้งค่า "เปิดใช้งานรูท" เป็น "เท็จ" จะบันทึกข้อความและส่งคืนโดยไม่เปิดใช้งานรูท

การเปิดใช้งาน adb root อาจทำให้อุปกรณ์ตัดการเชื่อมต่อจาก adb วิธีนี้จะบล็อกจนกว่าอุปกรณ์จะพร้อมใช้งาน

ส่งคืน
boolean true ถ้าสำเร็จ

พ่น
DeviceNotAvailableException

เปิดใช้ NetworkMonitor

public boolean enableNetworkMonitor ()

เปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์

ส่งคืน
boolean true หากเปิดใช้งานการมอนิเตอร์สำเร็จ false ถ้ามันล้มเหลว

พ่น
DeviceNotAvailableException

ดำเนินการ AdbCommand

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

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ

ควรใช้ executeShellCommand(String) แทนหากทำได้ เนื่องจากวิธีนี้ให้การตรวจจับความล้มเหลวและประสิทธิภาพที่ดีกว่า

พารามิเตอร์
timeout long : เวลาเป็นมิลลิวินาทีก่อนที่อุปกรณ์จะถือว่าไม่ตอบสนอง 0L สำหรับการหมดเวลา

cmdArgs String : คำสั่ง adb และอาร์กิวเมนต์ที่จะเรียกใช้

ส่งคืน
String stdout จากคำสั่ง null ถ้าคำสั่งล้มเหลวในการดำเนินการ

พ่น
DeviceNotAvailableException

ดำเนินการ AdbCommand

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

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ

ควรใช้ executeShellCommand(String) แทนหากทำได้ เนื่องจากวิธีนี้ให้การตรวจจับความล้มเหลวและประสิทธิภาพที่ดีกว่า

พารามิเตอร์
timeout long : เวลาเป็นมิลลิวินาทีก่อนที่อุปกรณ์จะถือว่าไม่ตอบสนอง 0L สำหรับการหมดเวลา

envMap : สภาพแวดล้อมที่จะตั้งค่าสำหรับคำสั่ง

cmdArgs String : คำสั่ง adb และอาร์กิวเมนต์ที่จะเรียกใช้

ส่งคืน
String stdout จากคำสั่ง null ถ้าคำสั่งล้มเหลวในการดำเนินการ

พ่น
DeviceNotAvailableException

ดำเนินการ AdbCommand

public String executeAdbCommand (String... cmdArgs)

เมธอด Helper ซึ่งเรียกใช้คำสั่ง adb เป็นคำสั่งระบบ

ควรใช้ executeShellCommand(String) แทนหากทำได้ เนื่องจากวิธีนี้ให้การตรวจจับความล้มเหลวและประสิทธิภาพที่ดีกว่า

พารามิเตอร์
cmdArgs String : คำสั่ง adb และอาร์กิวเมนต์ที่จะเรียกใช้

ส่งคืน
String stdout จากคำสั่ง null ถ้าคำสั่งล้มเหลวในการดำเนินการ

พ่น
DeviceNotAvailableException

ดำเนินการ FastbootCommand

public CommandResult executeFastbootCommand (String... cmdArgs)

วิธีการช่วยเหลือซึ่งดำเนินการคำสั่ง fastboot เป็นคำสั่งระบบโดยมีการหมดเวลาเริ่มต้น 2 นาที

คาดว่าจะใช้เมื่ออุปกรณ์อยู่ในโหมด fastboot แล้ว

พารามิเตอร์
cmdArgs String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน

ส่งคืน
CommandResult CommandResult ที่มีเอาต์พุตของคำสั่ง

พ่น
DeviceNotAvailableException

ดำเนินการ FastbootCommand

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

วิธีตัวช่วยที่รันคำสั่ง fastboot เป็นคำสั่งระบบ

คาดว่าจะใช้เมื่ออุปกรณ์อยู่ในโหมด fastboot แล้ว

พารามิเตอร์
timeout long : เวลาเป็นมิลลิวินาทีก่อนที่คำสั่งจะหมดอายุ

cmdArgs String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน

ส่งคืน
CommandResult CommandResult ที่มีเอาต์พุตของคำสั่ง

พ่น
DeviceNotAvailableException

ดำเนินการ LongFastbootCommand

public CommandResult executeLongFastbootCommand (String... cmdArgs)

เมธอด Helper ซึ่งดำเนินการคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบ

เหมือนกันกับ executeFastbootCommand(String) ยกเว้นใช้การหมดเวลาที่นานขึ้น

พารามิเตอร์
cmdArgs String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน

ส่งคืน
CommandResult CommandResult ที่มีเอาต์พุตของคำสั่ง

พ่น
DeviceNotAvailableException

ดำเนินการ LongFastbootCommand

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

เมธอด Helper ซึ่งดำเนินการคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบพร้อมตัวแปรสภาพแวดล้อมระบบ

เหมือนกันกับ executeFastbootCommand(String) ยกเว้นใช้การหมดเวลาที่นานขึ้น

พารามิเตอร์
envVarMap : ตัวแปรสภาวะแวดล้อมระบบที่คำสั่ง fastboot รันด้วย

cmdArgs String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน

ส่งคืน
CommandResult CommandResult ที่มีเอาต์พุตของคำสั่ง

พ่น
DeviceNotAvailableException

ดำเนินการเชลล์คำสั่ง

public String executeShellCommand (String command)

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

พารามิเตอร์
command String : the adb shell command to run

ส่งคืน
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.

พารามิเตอร์
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.

พารามิเตอร์
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.

พารามิเตอร์
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.

พารามิเตอร์
cmd String : The command that should be run.

ส่งคืน
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.

พารามิเตอร์
cmd String : The command that should be run.

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

ส่งคืน
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.

พารามิเตอร์
cmd String : The command that should be run.

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

ส่งคืน
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.

พารามิเตอร์
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.

ส่งคืน
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.

พารามิเตอร์
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

ส่งคืน
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.

พารามิเตอร์
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.

ส่งคืน
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.

พารามิเตอร์
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.

ส่งคืน
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.

พารามิเตอร์
partition String : the partition to wipe

ส่งคืน
CommandResult the CommandResult containing output of command

Throws
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Fetch the information about APEXes activated on the device.

ส่งคืน
ERROR(/Set) of ApexInfo currently activated on the device

Throws
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Return key value pairs of requested namespace.

พารามิเตอร์
namespace String : must be one of {"system", "secure", "global"}

ส่งคืน
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

ส่งคืน
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

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

พารามิเตอร์
userId int

ส่งคืน
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.

ส่งคืน
Map of android ids found matching user ids.

Throws
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

Get the device API Level. Defaults to UNKNOWN_API_LEVEL .

ส่งคืน
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.

พารามิเตอร์
packageName String

ส่งคืน
PackageInfo the PackageInfo or null if information could not be retrieved

Throws
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Fetch information of packages installed on the device.

ส่งคืน
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 .

ส่งคืน
String the ERROR(/String) baseband version or null if it cannot be determined (device has no radio or version string cannot be read)

Throws
DeviceNotAvailableException

getBattery

public Integer getBattery ()

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

ส่งคืน
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

Returns boolean value of the given property.

พารามิเตอร์
name String : the property name

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

ส่งคืน
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.

ส่งคืน
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() .

พารามิเตอร์
utcEpochTime long : the device time since Epoch.

timeUnit TimeUnit : the time unit TimeUnit .

ส่งคืน
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)

ส่งคืน
String the ERROR(/String) bootloader version or null if it cannot be found

Throws
DeviceNotAvailableException

getBugreport

public InputStreamSource getBugreport ()

Retrieves a bugreport from the device.

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

ส่งคืน
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

ส่งคืน
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

ส่งคืน
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.

ส่งคืน
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.

ส่งคืน
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)

ส่งคืน
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 .

ส่งคืน
DeviceDescriptor

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

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

พารามิเตอร์
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

ส่งคืน
DeviceDescriptor

getChildren

public String[] getChildren (String path)

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

พารามิเตอร์
path String : is the path on the device where to do the search

ส่งคืน
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.

ส่งคืน
AbstractConnection

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

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

ส่งคืน
DeviceFoldableState

Throws
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

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

ส่งคืน
int

Throws
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

Get the device class.

ส่งคืน
String the ERROR(/String) device class.

getDeviceDate

public long getDeviceDate ()

Return the date of the device in millisecond since epoch.

ส่งคืน
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.

ส่งคืน
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.

พารามิเตอร์
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

ส่งคืน
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

Get the device's state.

ส่งคืน
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.

พารามิเตอร์
date Date

ส่งคืน
long the difference in milliseconds

Throws
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

Get the stream of emulator stdout and stderr

ส่งคืน
InputStreamSource emulator output

getEmulatorProcess

public Process getEmulatorProcess ()

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

ส่งคืน
Process the ERROR(/Process) or null

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

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

ส่งคืน
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

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

ส่งคืน
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.

ส่งคืน
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.

ส่งคืน
String the ERROR(/String) product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootProductVariant

public String getFastbootProductVariant ()

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

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

ส่งคืน
String the ERROR(/String) product type name or null if it cannot be determined

Throws
DeviceNotAvailableException

getFastbootSerialNumber

public String getFastbootSerialNumber ()

Returns the fastboot mode serial number.

ส่งคืน
String

getFastbootVariable

public String getFastbootVariable (String variableName)

Retrieve the given fastboot variable value from the device.

พารามิเตอร์
variableName String : the variable name

ส่งคืน
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.

ส่งคืน
String

getFileEntry

public IFileEntry getFileEntry (String path)

Retrieve a reference to a remote file on device.

พารามิเตอร์
path String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie both "/system" and "system" syntax is supported)

ส่งคืน
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).

พารามิเตอร์
entry FileListingService.FileEntry : a FileEntry not necessarily root as Ddmlib requires.

ส่งคืน
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".

ส่งคืน

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.

ส่งคืน
IDevice the IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

Fetch the application package names present on the device.

ส่งคืน
ERROR(/Set) of ERROR(/String) package names currently installed on the device.

Throws
DeviceNotAvailableException

getIntProperty

public long getIntProperty (String name, 
                long defaultValue)

Returns integer value of the given property from the device.

พารามิเตอร์
name String : the property name

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

ส่งคืน
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.

ส่งคืน
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.

ส่งคืน
KeyguardControllerState a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported.

Throws
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

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

ส่งคืน
long

getLaunchApiLevel

public int getLaunchApiLevel ()

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

ส่งคืน
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

    ส่งคืน
    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.

    พารามิเตอร์
    maxBytes int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory

    ส่งคืน
    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.

    ส่งคืน
    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() .

    พารามิเตอร์
    date long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s')

    ส่งคืน
    InputStreamSource

    getMacAddress

    public String getMacAddress ()

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

    ส่งคืน
    String

    getMainUserId

    public Integer getMainUserId ()

    Returns the main user id.

    ส่งคืน
    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.

    ส่งคืน
    ERROR(/Set) of ERROR(/String) mainline modules currently installed on the device.

    Throws
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

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

    ส่งคืน
    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.

    ส่งคืน
    int an integer indicating the number of supported users

    Throws
    DeviceNotAvailableException

    getMicrodroidProcess

    public Process getMicrodroidProcess ()

    ส่งคืน
    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.

    ส่งคืน
    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)

    พารามิเตอร์
    mountName String : the name of the mount point

    ส่งคืน
    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.

    พารามิเตอร์
    mountpoint String

    ส่งคืน
    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

    ส่งคืน
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    Throws
    DeviceNotAvailableException

    getOptions

    public TestDeviceOptions getOptions ()

    Fetch the test options for the device.

    ส่งคืน
    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.

    พารามิเตอร์
    partition String

    ส่งคืน
    long the amount of free space in KB

    Throws
    DeviceNotAvailableException

    getPrimaryUserId

    public Integer getPrimaryUserId ()

    Returns the primary user id.

    ส่งคืน
    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.

    พารามิเตอร์
    processName String : the proces name String.

    ส่งคืน
    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.

    พารามิเตอร์
    process String : The proces name String.

    ส่งคืน
    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.

    ส่งคืน
    String the ERROR(/String) product type name. Will not be null

    Throws
    DeviceNotAvailableException

    getProductVariant

    public String getProductVariant ()

    Convenience method to get the product variant of this device.

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

    ส่งคืน
    String the ERROR(/String) product variant name or null if it cannot be determined

    Throws
    DeviceNotAvailableException

    getProperty

    public String getProperty (String name)

    Retrieve the given property value from the device.

    พารามิเตอร์
    name String : the property name

    ส่งคืน
    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.

    ส่งคืน
    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

    พารามิเตอร์
    format String : supported PNG, JPEG

    ส่งคืน
    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'

    พารามิเตอร์
    displayId long : the display id of the screen to get screenshot from.

    ส่งคืน
    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.

    พารามิเตอร์
    format String : supported PNG, JPEG

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

    ส่งคืน
    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.

    ส่งคืน
    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.

    ส่งคืน
    String the ERROR(/String) serial number

    getSetting

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

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

    พารามิเตอร์
    userId int

    namespace String

    key String

    ส่งคืน
    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.

    พารามิเตอร์
    namespace String

    key String

    ส่งคืน
    String

    Throws
    DeviceNotAvailableException

    getSimOperator

    public String getSimOperator ()

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

    ส่งคืน
    String

    getSimState

    public String getSimState ()

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

    ส่งคืน
    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.

    ส่งคืน
    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

    ส่งคืน
    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.

    ส่งคืน
    ERROR(/Set) of uninstallable ERROR(/String) package names currently installed on the device.

    Throws
    DeviceNotAvailableException

    getUseFastbootErase

    public boolean getUseFastbootErase ()

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

    ส่งคืน
    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.

    พารามิเตอร์
    userId int

    ส่งคืน
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    userId int

    ส่งคืน
    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.

    พารามิเตอร์
    event DeviceEvent

    ส่งคืน
    IManagedTestDevice.DeviceEventResponse

    hasFeature

    public boolean hasFeature (String feature)

    Check if a feature is available on a device.

    พารามิเตอร์
    feature String : which format should be "feature: " or " " directly.

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackage

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

    Install an Android package on device.

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

    พารามิเตอร์
    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.

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackageForUser

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

    Install an Android package on device for a given user.

    พารามิเตอร์
    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.

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    installPackageForUser

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

    Install an Android package on device for a given user.

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

    พารามิเตอร์
    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.

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    isAdbRoot

    public boolean isAdbRoot ()

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    isAdbTcp

    public boolean isAdbTcp ()

    ส่งคืน
    boolean

    isAppEnumerationSupported

    public boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    ส่งคืน
    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

    ส่งคืน
    boolean True if bypass low target sdk block is supported, false otherwise

    Throws
    DeviceNotAvailableException

    isDeviceEncrypted

    public boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    ส่งคืน
    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.

    พารามิเตอร์
    path String

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    ส่งคืน
    boolean true if adb root should be enabled on device

    isEncryptionSupported

    public boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    ส่งคืน
    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.

    พารามิเตอร์
    fullPath String

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    isFastbootEnabled

    public boolean isFastbootEnabled ()

    Return if fastboot is available for the device.

    ส่งคืน
    boolean

    isHeadless

    public boolean isHeadless ()

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

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    isHeadlessSystemUserMode

    public boolean isHeadlessSystemUserMode ()

    Returns whether the device uses headless system user mode.

    ส่งคืน
    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.

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    isMultiUserSupported

    public boolean isMultiUserSupported ()

    Determines if multi user is supported.

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    packageName String

    ส่งคืน
    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

    ส่งคืน
    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 .

    ส่งคืน
    boolean

    isUserRunning

    public boolean isUserRunning (int userId)

    Check if a given user is running.

    พารามิเตอร์
    userId int

    ส่งคืน
    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.

    พารามิเตอร์
    userId int

    ส่งคืน
    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).

    พารามิเตอร์
    userId int

    ส่งคืน
    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.

    พารามิเตอร์
    userId int

    displayId int

    ส่งคืน
    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) ).

    ส่งคืน
    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() .

    ส่งคืน
    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.

    ส่งคืน
    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".

    ส่งคืน
    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 .

    ส่งคืน

    Throws
    DeviceNotAvailableException

    listUsers

    public  listUsers ()

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

    ส่งคืน
    the list of user ids.

    Throws
    DeviceNotAvailableException

    logAnrs

    public boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    พารามิเตอร์
    logger ITestLogger : an ITestLogger to log the ANRs.

    ส่งคืน
    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.

    พารามิเตอร์
    dataName String : name under which the bugreport will be reported.

    listener ITestLogger : an ITestLogger to log the bugreport.

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    พารามิเตอร์
    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.

    พารามิเตอร์
    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.

    พารามิเตอร์
    deviceFilePath String : the absolute file path of the remote source

    localDir File : the local directory to pull files into

    ส่งคืน
    boolean true if file was pulled successfully. false otherwise.

    Throws
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    Retrieves a file off device.

    พารามิเตอร์
    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.

    ส่งคืน
    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 .

    พารามิเตอร์
    remoteFilePath String : the absolute path to file on device.

    userId int : The user id to pull from

    ส่งคืน
    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 .

    พารามิเตอร์
    remoteFilePath String : the absolute path to file on device.

    ส่งคืน
    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.

    พารามิเตอร์
    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

    ส่งคืน
    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.

    พารามิเตอร์
    remoteFilePath String : the absolute path to file on device.

    ส่งคืน
    String A ERROR(/String) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    Throws
    DeviceNotAvailableException

    pullFileFromExternal

    public File pullFileFromExternal (String remoteFilePath)

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

    พารามิเตอร์
    remoteFilePath String : the path to file on device, relative to the device's external storage mountpoint

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    ส่งคืน
    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.

    พารามิเตอร์
    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

    ส่งคืน
    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.

    พารามิเตอร์
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    ส่งคืน
    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

    พารามิเตอร์
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

    ส่งคืน
    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.

    พารามิเตอร์
    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

    พารามิเตอร์
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    deviceActionReceiver IDeviceActionReceiver : A IDeviceActionReceiver which will be registered.

    remountSystemWritable

    public void remountSystemWritable ()

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

    Throws
    DeviceNotAvailableException

    remountVendorWritable

    public void remountVendorWritable ()

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

    Throws
    DeviceNotAvailableException

    removeAdmin

    public boolean removeAdmin (String componentName, 
                    int userId)

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

    พารามิเตอร์
    componentName String : of device admin to be removed.

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

    ส่งคืน
    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.

    พารามิเตอร์
    userId int : of the user to remove

    ส่งคืน
    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.

    พารามิเตอร์
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

    ส่งคืน
    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.

    พารามิเตอร์
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

    ส่งคืน
    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.

    พารามิเตอร์
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    ส่งคืน
    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.

    พารามิเตอร์
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    setConfiguration

    public void setConfiguration (IConfiguration configuration)

    Injects the IConfiguration in use.

    พารามิเตอร์
    configuration IConfiguration

    setDate

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

    พารามิเตอร์
    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.

    พารามิเตอร์
    componentName String : of device admin to be device owner.

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

    ส่งคืน
    boolean True if it is successful, false otherwise.

    Throws
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    พารามิเตอร์
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    พารามิเตอร์
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

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

    พารามิเตอร์
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

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

    พารามิเตอร์
    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.

    พารามิเตอร์
    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

    พารามิเตอร์
    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.

    พารามิเตอร์
    delay int : the delay in ms

    setOptions

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    พารามิเตอร์
    options TestDeviceOptions

    setProperty

    public boolean setProperty (String propKey, 
                    String propValue)

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

    พารามิเตอร์
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    ส่งคืน
    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.

    พารามิเตอร์
    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

    พารามิเตอร์
    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.

    พารามิเตอร์
    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"}

    พารามิเตอร์
    userId int

    namespace String

    key String

    value String

    Throws
    DeviceNotAvailableException

    setTestLogger

    public void setTestLogger (ITestLogger testLogger)

    Injects the ITestLogger instance

    พารามิเตอร์
    testLogger ITestLogger

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

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

    พารามิเตอร์
    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.

    พารามิเตอร์
    userId int : of the user to start in the background

    ส่งคืน
    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.

    พารามิเตอร์
    userId int : of the user to start in the background

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

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    userId int : of the user to stop.

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    boolean true if the user was successfully stopped.

    Throws
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

    ส่งคืน
    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.

    ส่งคืน
    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) .

    พารามิเตอร์
    userId int

    ส่งคืน
    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.

    พารามิเตอร์
    userId int

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

    ส่งคืน
    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.

    พารามิเตอร์
    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

    ส่งคืน
    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() .

    ส่งคืน
    Bugreport

    uninstallPackage

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    พารามิเตอร์
    packageName String : the Android package to uninstall

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    uninstallPackageForUser

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    Uninstall an Android package from device for a given user.

    พารามิเตอร์
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    ส่งคืน
    String a ERROR(/String) with an error code, or null if success.

    Throws
    DeviceNotAvailableException

    unlockDevice

    public boolean unlockDevice ()

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

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

    ส่งคืน
    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.

    พารามิเตอร์
    timeOut long : time in msecs to wait for the flag to be set

    ส่งคืน
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    waitTime long : the time in ms to wait

    ส่งคืน
    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.

    พารามิเตอร์
    waitTime long

    ส่งคืน
    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 ).

    พารามิเตอร์
    waitTime long : the time in ms to wait

    ส่งคืน
    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

    พารามิเตอร์
    waitTime long : the time in ms to wait

    ส่งคืน
    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

    พารามิเตอร์
    waitTime long : the time in ms to wait

    ส่งคืน
    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.

    พารามิเตอร์
    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.

    พารามิเตอร์
    waitTime long : the time in ms to wait

    ส่งคืน
    boolean true if device becomes responsive before waitTime elapses.

    Protected methods

    buildAdbShellCommand

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

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

    พารามิเตอร์
    command String

    forceExitStatusDetection boolean

    ส่งคืน
    String[]

    checkApiLevelAgainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

    พารามิเตอร์
    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.

    พารามิเตอร์
    rebootMode NativeDevice.RebootMode : a mode of this reboot.

    reason String : for this reboot.

    ส่งคืน
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    createRunUtil

    protected IRunUtil createRunUtil ()

    ส่งคืน
    IRunUtil

    doAdbReboot

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

    Perform a adb reboot.

    พารามิเตอร์
    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 ()

    ส่งคืน
    int

    getLogger

    protected ITestLogger getLogger ()

    ส่งคืน
    ITestLogger

    getRunUtil

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    ส่งคืน
    IRunUtil

    initializeConnection

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

    พารามิเตอร์
    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.

    พารามิเตอร์
    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.

    ส่งคืน
    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.

    ส่งคืน
    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.

    พารามิเตอร์
    localFile File

    entry IFileEntry

    ส่งคืน
    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.

    พารามิเตอร์
    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

    ส่งคืน
    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)

    พารามิเตอร์
    remoteFilePath String

    localFile File

    ส่งคืน
    boolean

    Throws
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    Set the Clock instance to use.

    พารามิเตอร์
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    Marks the TestDevice as microdroid and sets its CID.

    พารามิเตอร์
    process Process : Process of the Microdroid VM.

    setTestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

    พารามิเตอร์
    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.

    พารามิเตอร์
    timeout long

    envVarMap

    fullCmd String

    ส่งคืน
    CommandResult

    simpleFastbootCommand

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

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

    พารามิเตอร์
    timeout long

    fullCmd String

    ส่งคืน
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

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

    พารามิเตอร์
    operationDesc String : The name of the operation that is waiting for unavailable.

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

    ส่งคืน
    boolean True if device did become unavailable.