NativeDevice
public class NativeDevice
extends Object
implements IManagedTestDevice , IConfigurationReceiver
java.lang.Object | |
เ | com.android.tradefed.device.NativeDevice |
การใช้งานเริ่มต้นของอุปกรณ์ ITestDevice
Non-full stack
สรุป
คลาสที่ซ้อนกัน | |
---|---|
class | NativeDevice.AdbAction |
class | NativeDevice.AdbShellAction |
class | NativeDevice.RebootDeviceAction |
enum | NativeDevice.RebootMode โหมดการรีบูต |
ค่าคงที่ | |
---|---|
int | INVALID_USER_ID ค่าที่ส่งคืนสำหรับ 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) สร้าง |
วิธีการสาธารณะ | |
---|---|
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.f |
boolean | connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid) เชื่อมต่อกับเครือข่าย wifi |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid) ตัวแปรของ |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk) ตัวแปรของ |
int | createUser (String name, boolean guest, boolean ephemeral) สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา |
int | createUser (String name) สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0 |
int | createUserNoThrow (String name) สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0 |
void | deleteFile (String deviceFilePath) วิธีการช่วยเหลือในการลบไฟล์หรือไดเร็กทอรีบนอุปกรณ์ |
boolean | deviceSoftRestarted ( ProcessInfo prevSystemServerProcess) วิธีตัวช่วยในการตรวจสอบว่าอุปกรณ์ซอฟต์รีสตาร์ทโดยเปรียบเทียบ system_server ปัจจุบันกับ system_server |
boolean | deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit) วิธีตัวช่วยในการตรวจสอบว่าอุปกรณ์ซอฟต์รีสตาร์ทตั้งแต่เวลา UTC ตั้งแต่ยุคจากอุปกรณ์และ |
boolean | disableAdbRoot () ปิดรูท adb |
void | disableKeyguard () ความพยายามที่จะปิดการใช้งานคีย์การ์ด |
boolean | disableNetworkMonitor () ปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์ |
boolean | disconnectFromWifi () ตัดการเชื่อมต่อจากเครือข่าย wifi |
boolean | doesFileExist (String deviceFilePath, int userId) วิธี Helper เพื่อตรวจสอบว่าไฟล์ในอุปกรณ์มีอยู่สำหรับผู้ใช้ที่กำหนดหรือไม่ |
boolean | doesFileExist (String deviceFilePath) วิธี Helper เพื่อตรวจสอบว่าไฟล์ในอุปกรณ์มีอยู่หรือไม่ |
File | dumpHeap (String process, String devicePath) พยายามดัมพ์ฮีพจาก system_server |
boolean | enableAdbRoot () เปิด adb root |
boolean | enableNetworkMonitor () เปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์ |
String | executeAdbCommand (long timeout, String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ |
String | executeAdbCommand (String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง adb เป็นคำสั่งระบบ |
CommandResult | executeFastbootCommand (String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง fastboot เป็นคำสั่งระบบโดยมีการหมดเวลาเริ่มต้น 2 นาที |
CommandResult | executeFastbootCommand (long timeout, String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง fastboot เป็นคำสั่งระบบ |
CommandResult | executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบพร้อมตัวแปรสภาพแวดล้อมของระบบ |
CommandResult | executeLongFastbootCommand (String... cmdArgs) เมธอด Helper ซึ่งรันคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบ |
String | executeShellCommand (String command) เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งคืนเอาต์พุตเป็น |
void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
void | executeShellCommand (String command, IShellOutputReceiver receiver) ดำเนินการคำสั่งเชลล์ adb ที่กำหนด ลองใหม่หลายครั้งหากคำสั่งล้มเหลว |
CommandResult | executeShellV2Command (String cmd) เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งกลับผลลัพธ์เป็น |
CommandResult | executeShellV2Command (String cmd, OutputStream pipeToOutput) เมธอด Helper ที่รันคำสั่งเชลล์ adb และส่งคืนผลลัพธ์เป็น |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput) เมธอด Helper ที่รันคำสั่งเชลล์ adb และส่งคืนผลลัพธ์เป็น |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง |
CommandResult | fastbootWipePartition (String partition) วิธีตัวช่วยที่ล้างพาร์ทิชันสำหรับอุปกรณ์ |
getActiveApexes () ดึงข้อมูลเกี่ยวกับ APEX ที่เปิดใช้งานบนอุปกรณ์ | |
getAllSettings (String namespace) ส่งกลับคู่ค่าคีย์ของเนมสเปซที่ร้องขอ | |
DeviceAllocationState | getAllocationState () คืนสถานะการจัดสรรปัจจุบันของอุปกรณ์ |
String | getAndroidId (int userId) ค้นหาและส่งคืน android-id ที่เชื่อมโยงกับ userId หากไม่พบจะเป็นโมฆะ |
getAndroidIds () สร้างแผนที่รหัส Android ที่พบว่าตรงกับรหัสผู้ใช้ | |
int | getApiLevel () รับระดับ API ของอุปกรณ์ |
PackageInfo | getAppPackageInfo (String packageName) ดึงข้อมูลเกี่ยวกับแพ็คเกจที่ติดตั้งบนอุปกรณ์ |
getAppPackageInfos () ดึงข้อมูลของแพ็คเกจที่ติดตั้งบนอุปกรณ์ | |
String | getBasebandVersion () วิธีที่สะดวกสบายในการรับเวอร์ชันเบสแบนด์ (วิทยุ) ของอุปกรณ์นี้ |
Integer | getBattery () ส่งกลับระดับแบตเตอรี่ปัจจุบันของอุปกรณ์หรือ Null หากระดับแบตเตอรี่ไม่พร้อมใช้งาน |
boolean | getBooleanProperty (String name, boolean defaultValue) ส่งกลับค่าบูลีนของคุณสมบัติที่กำหนด |
getBootHistory () เมธอด Helper รวบรวมแมปประวัติการบู๊ตพร้อมเวลาบู๊ตและเหตุผลในการบู๊ต | |
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 | getCachedDeviceDescriptor (boolean shortDescriptor) ส่งคืน |
String[] | getChildren (String path) ทางเลือกอื่นในการใช้ |
DeviceFoldableState | getCurrentFoldableState () ส่งกลับสถานะปัจจุบันที่พับได้ของอุปกรณ์หรือ null หากมีปัญหาเกิดขึ้น |
int | getCurrentUser () ส่งคืน ID ของผู้ใช้ที่กำลังทำงานอยู่ |
String | getDeviceClass () รับคลาสอุปกรณ์ |
long | getDeviceDate () ส่งคืนวันที่ของอุปกรณ์เป็นมิลลิวินาทีตั้งแต่ยุค |
DeviceDescriptor | getDeviceDescriptor () ส่งคืน |
DeviceDescriptor | getDeviceDescriptor (boolean shortDescriptor) ส่งคืน |
TestDeviceState | getDeviceState () รับสถานะของอุปกรณ์ |
long | getDeviceTimeOffset (Date date) ตัวช่วยรับความแตกต่างของเวลาระหว่างอุปกรณ์กับ |
InputStreamSource | getEmulatorOutput () รับสตรีมของโปรแกรมจำลอง stdout และ stderr |
Process | getEmulatorProcess () ส่งคืน |
final File | getExecuteShellCommandLog () บันทึกที่มีบันทึกการทำงาน |
long | getExternalStoreFreeSpace () วิธี Helper เพื่อกำหนดจำนวนพื้นที่ว่างบนที่จัดเก็บข้อมูลภายนอกของอุปกรณ์ |
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) ผู้ช่วยที่ไม่เป็นทางการเพื่อรับ |
getFoldableStates () ส่งคืนรายการสถานะแบบพับได้บนอุปกรณ์ | |
IDevice | getIDevice () ส่งคืนการอ้างอิงไปยัง ddmlib |
getInstalledPackageNames () เรียกชื่อแพ็คเกจแอปพลิเคชันที่มีอยู่ในอุปกรณ์ | |
long | getIntProperty (String name, long defaultValue) ส่งคืนค่าจำนวนเต็มของคุณสมบัติที่กำหนดจากอุปกรณ์ |
String | getIpAddress () รับที่อยู่ IP ของอุปกรณ์ |
KeyguardControllerState | getKeyguardState () ส่งคืนอ็อบเจ็กต์เพื่อรับสถานะปัจจุบันของคีย์การ์ดหรือค่า null หากไม่ได้รับการสนับสนุน |
long | getLastExpectedRebootTimeMillis () ส่งคืน Tradefed API ครั้งล่าสุดที่ทริกเกอร์การรีบูตในหน่วยมิลลิวินาทีตั้งแต่ EPOCH ตามที่ส่งคืนโดย |
int | getLaunchApiLevel () รับระดับ API ที่เปิดตัวครั้งแรกของอุปกรณ์ |
InputStreamSource | getLogcat () ดึงสแนปชอตสตรีมของข้อมูล logcat |
InputStreamSource | getLogcat (int maxBytes) ดึงสตรีมสแนปชอตของ |
InputStreamSource | getLogcatDump () รับดัมพ์ของ logcat ปัจจุบันสำหรับอุปกรณ์ |
InputStreamSource | getLogcatSince (long date) ดึงสตรีมสแนปชอตของข้อมูล logcat ที่บันทึกไว้โดยเริ่มตั้งแต่วันที่ระบุ |
String | getMacAddress () ส่งกลับที่อยู่ MAC ของอุปกรณ์ จะเป็นโมฆะหากไม่สามารถสืบค้นจากอุปกรณ์ได้ |
getMainlineModuleInfo () รับข้อมูลเกี่ยวกับโมดูล mainline ที่ติดตั้งบนอุปกรณ์ | |
int | getMaxNumberOfRunningUsersSupported () รับจำนวนผู้ใช้สูงสุดที่รองรับการทำงานพร้อมกัน |
int | getMaxNumberOfUsersSupported () รับจำนวนผู้ใช้ที่รองรับสูงสุด |
IDeviceStateMonitor | getMonitor () ส่งคืน |
String | getMountPoint (String mountName) ส่งกลับจุดเมานท์ |
ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) ส่งกลับ |
getMountPointInfo () ส่งคืนข้อมูลเวอร์ชันที่แยกวิเคราะห์ใน /proc/mounts บน device | |
TestDeviceOptions | getOptions () ดึงตัวเลือกการทดสอบสำหรับอุปกรณ์ |
long | getPartitionFreeSpace (String partition) วิธี Helper เพื่อกำหนดจำนวนเนื้อที่ว่างบนพาร์ติชั่นอุปกรณ์ |
Integer | getPrimaryUserId () ส่งคืน ID ผู้ใช้หลัก |
ProcessInfo | getProcessByName (String processName) เมธอด Helper รันคำสั่ง "pidof" และ "stat" และส่งคืนอ็อบเจ็กต์ |
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) ดู |
String | getSimOperator () ส่งคืนผู้ให้บริการซิมการ์ดหรือ null หากไม่มีหรือหากไม่มีอุปกรณ์ |
String | getSimState () คืนสถานะซิมการ์ดหรือ null หากไม่มีหรืออุปกรณ์ไม่พร้อมใช้งาน |
getTombstones () ดึงและคืนรายการของหลุมฝังศพจากอุปกรณ์ | |
long | getTotalMemory () ส่งกลับขนาดหน่วยความจำกายภาพทั้งหมดเป็นไบต์หรือ -1 ในกรณีที่เกิดข้อผิดพลาดภายใน |
getUninstallablePackageNames () ดึงชื่อแพ็คเกจแอปพลิเคชันที่สามารถถอนการติดตั้งได้ | |
boolean | getUseFastbootErase () ดูว่าจะใช้ fastboot ลบหรือรูปแบบ fastboot เพื่อล้างพาร์ทิชันบนอุปกรณ์ |
int | getUserFlags (int userId) ค้นหาและส่งคืนแฟล็กของผู้ใช้ที่กำหนด |
getUserInfos () รับ Map of useId ไปยัง | |
int | getUserSerialNumber (int userId) ส่งคืนหมายเลขซีเรียลที่เกี่ยวข้องกับ userId หากพบ -10000 ในกรณีอื่น ๆ |
IManagedTestDevice.DeviceEventResponse | handleAllocationEvent (DeviceEvent event) ประมวลผล ประมวลผล 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 | isDeviceEncrypted () ส่งคืนหากอุปกรณ์ถูกเข้ารหัส |
boolean | isDirectory (String path) คืนค่า True หากพาธบนอุปกรณ์เป็นไดเร็กทอรี มิฉะนั้น จะเป็นเท็จ |
boolean | isEnableAdbRoot () |
boolean | isEncryptionSupported () ส่งคืนหากอุปกรณ์รองรับการเข้ารหัส |
boolean | isExecutable (String fullPath) คืนค่า True หากพาธของไฟล์บนอุปกรณ์เป็นไฟล์เรียกทำงาน มิฉะนั้นจะเป็นเท็จ |
boolean | isFastbootEnabled () ส่งคืนหากมี fastboot สำหรับอุปกรณ์ |
boolean | isHeadless () คืนค่า จริง หากอุปกรณ์ไม่มีหัว (ไม่มีหน้าจอ) มิฉะนั้น เท็จ |
boolean | isMultiUserSupported () กำหนดว่ารองรับผู้ใช้หลายคนหรือไม่ |
boolean | isPackageInstalled (String packageName, String userId) สอบถามอุปกรณ์สำหรับชื่อแพ็คเกจที่กำหนดและระบุ ID ผู้ใช้เพื่อตรวจสอบว่าอุปกรณ์นั้นติดตั้งอยู่หรือไม่สำหรับผู้ใช้นั้น |
boolean | isPackageInstalled (String packageName) สอบถามอุปกรณ์สำหรับชื่อแพ็คเกจที่กำหนดเพื่อตรวจสอบว่าติดตั้งอยู่หรือไม่ |
boolean | isRuntimePermissionSupported () ตรวจสอบว่าแพลตฟอร์มบนอุปกรณ์รองรับการอนุญาตรันไทม์หรือไม่ |
boolean | isStateBootloaderOrFastbootd () คืนค่า จริง หากอุปกรณ์อยู่ใน |
boolean | isUserRunning (int userId) ตรวจสอบว่าผู้ใช้รายใดรายหนึ่งกำลังทำงานอยู่ |
boolean | isUserSecondary (int userId) ส่งคืนว่าผู้ใช้ที่ระบุเป็นผู้ใช้รองตามแฟล็กหรือไม่ |
boolean | isWifiEnabled () ทดสอบว่าเปิดใช้งาน wifi หรือไม่ |
listDisplayIds () รวบรวมรายการ ID จอแสดงผลที่พร้อมใช้งานบนอุปกรณ์ตามที่รายงานโดย "dumpsys SurfaceFlinger" | |
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 และก่อนที่อุปกรณ์จะกลับมาออนไลน์ |
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) ดึงไฟล์จากอุปกรณ์ เก็บไว้ใน |
File | pullFile (String remoteFilePath) ดึงไฟล์จากอุปกรณ์ เก็บไว้ใน |
boolean | pullFile (String remoteFilePath, File localFile, int userId) ดึงไฟล์ออกจากอุปกรณ์ |
String | pullFileContents (String remoteFilePath) ดึงไฟล์จากอุปกรณ์และส่งคืนเนื้อหา |
File | pullFileFromExternal (String remoteFilePath) วิธีอำนวยความสะดวกในการดึงไฟล์จากที่จัดเก็บข้อมูลภายนอกของอุปกรณ์ เก็บไว้ใน |
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) ตัวแปรของ |
boolean | pushFile (File localFile, String remoteFilePath) พุชไฟล์ไปยังอุปกรณ์ |
boolean | pushString (String contents, String remoteFilePath) พุชไฟล์ที่สร้างจากสตริงไปยังอุปกรณ์ |
void | reboot (String reason) รีบูตอุปกรณ์เข้าสู่โหมด adb โดยมี |
void | reboot () รีบูตอุปกรณ์เข้าสู่โหมด adb |
void | rebootIntoBootloader () รีบูตอุปกรณ์เข้าสู่โหมด bootloader |
void | rebootIntoFastbootd () รีบูตอุปกรณ์เข้าสู่โหมด fastbootd |
void | rebootIntoRecovery () รีบูตอุปกรณ์เข้าสู่โหมดการกู้คืน adb |
void | rebootIntoSideload () รีบูตอุปกรณ์เข้าสู่โหมด adb sideload (โปรดทราบว่านี่เป็นโหมดพิเศษภายใต้การกู้คืน) บล็อกจนกว่าอุปกรณ์จะเข้าสู่โหมดไซด์โหลด |
void | rebootIntoSideload (boolean autoReboot) รีบูตอุปกรณ์เข้าสู่โหมด adb sideload (โปรดทราบว่านี่เป็นโหมดพิเศษภายใต้การกู้คืน) บล็อกจนกว่าอุปกรณ์จะเข้าสู่โหมดไซด์โหลด |
void | rebootUntilOnline () ทางเลือกอื่นในการ |
void | rebootUntilOnline (String reason) ทางเลือกอื่นในการ |
void | rebootUserspace () รีบูตเฉพาะส่วน userspace ของอุปกรณ์ |
void | rebootUserspaceUntilOnline () ทางเลือกอื่นในการ |
boolean | recoverDevice () ความพยายามที่จะกู้คืนการสื่อสารของอุปกรณ์ |
void | remountSystemWritable () ทำให้พาร์ติชันระบบบนอุปกรณ์สามารถเขียนได้ |
void | remountVendorWritable () ทำให้พาร์ติชันผู้ขายบนอุปกรณ์สามารถเขียนได้ |
boolean | removeAdmin (String componentName, int userId) ลบผู้ดูแลระบบอุปกรณ์ที่กำหนดในผู้ใช้ที่กำหนดและคืนค่า |
void | removeOwners () ลบเจ้าของโปรไฟล์อุปกรณ์ที่มีอยู่ทั้งหมดด้วยความพยายามอย่างเต็มที่ |
boolean | removeUser (int userId) ลบผู้ใช้ที่กำหนดออกจากอุปกรณ์ |
void | resetContentProviderSetup () รีเซ็ตการตั้งค่าสถานะสำหรับการตั้งค่าผู้ให้บริการเนื้อหาเพื่อทริกเกอร์อีกครั้ง |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) วิธีที่สะดวกสำหรับการดำเนินการ |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) เรียกใช้การทดสอบเครื่องมือวัด และให้การกู้คืนอุปกรณ์ |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) เหมือนกับ |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) เหมือนกับ |
void | setConfiguration ( IConfiguration configuration) |
void | setDate (Date date) ตั้งวันที่ในเครื่อง หมายเหตุ: การตั้งค่าวันที่บนอุปกรณ์ต้องใช้ root |
boolean | setDeviceOwner (String componentName, int userId) ตั้งค่าคอมโพเนนต์ผู้ดูแลระบบอุปกรณ์เป็นเจ้าของอุปกรณ์ในผู้ใช้ที่กำหนด |
void | setDeviceState ( TestDeviceState deviceState) อัปเดตสถานะของอุปกรณ์ |
void | setEmulatorOutputStream ( SizeLimitedOutputStream output) สำหรับตัวจำลองให้ตั้งค่า |
void | setEmulatorProcess (Process p) ตั้งค่า |
void | setFastbootEnabled (boolean fastbootEnabled) ตั้งค่าตัวเลือก fastboot สำหรับอุปกรณ์ |
void | setFastbootPath (String fastbootPath) ตั้งค่าพาธไปยังไบนารี fastboot ที่ควรใช้ |
void | setIDevice (IDevice newDevice) อัปเดต IDevice ที่เชื่อมโยงกับ ITestDevice นี้ |
void | setOptions ( TestDeviceOptions options) ตั้งค่า |
boolean | setProperty (String propKey, String propValue) ตั้งค่าคุณสมบัติที่กำหนดบนอุปกรณ์ |
void | setRecovery ( IDeviceRecovery recovery) ตั้งค่า |
void | setRecoveryMode ( ITestDevice.RecoveryMode mode) ตั้งค่าโหมดการกู้คืนปัจจุบันเพื่อใช้กับอุปกรณ์ |
void | setSetting (String namespace, String key, String value) ดู |
void | setSetting (int userId, String namespace, String key, String value) เพิ่มการตั้งค่าให้กับเนมสเปซของผู้ใช้ที่กำหนด |
void | setUseFastbootErase (boolean useFastbootErase) ตั้งค่าว่าจะใช้ fastboot ลบหรือรูปแบบ fastboot เพื่อล้างพาร์ทิชันบนอุปกรณ์ |
void | startLogcat () เริ่มจับเอาต์พุต logcat จากอุปกรณ์ในพื้นหลัง |
boolean | startUser (int userId) เริ่มต้นผู้ใช้ที่ระบุในพื้นหลังหากหยุดอยู่ในขณะนี้ |
boolean | startUser (int userId, 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) สลับไปใช้ userId อื่นที่มีระยะหมดเวลาเริ่มต้น |
boolean | switchUser (int userId, long timeout) เปลี่ยนไปใช้ userId อื่นโดยมีระยะหมดเวลาที่ระบุเป็นกำหนดเวลา |
boolean | syncFiles (File localFileDir, String deviceFilePath) ซิงค์เนื้อหาของไดเร็กทอรีไฟล์ในเครื่องกับอุปกรณ์เพิ่มขึ้น |
Bugreport | takeBugreport () รับรายงานข้อบกพร่องและส่งคืนภายในวัตถุ |
String | uninstallPackage (String packageName) ถอนการติดตั้งแพ็คเกจ Android จากอุปกรณ์ |
String | uninstallPackageForUser (String packageName, int userId) ถอนการติดตั้งแพ็คเกจ Android จากอุปกรณ์สำหรับผู้ใช้ที่กำหนด |
boolean | unlockDevice () ปลดล็อกอุปกรณ์หากอุปกรณ์อยู่ในสถานะเข้ารหัส |
boolean | waitForBootComplete (long timeOut) บล็อกจนกว่าจะตั้งค่าสถานะการบูตอุปกรณ์เสร็จสมบูรณ์ |
boolean | waitForDeviceAvailable () รอให้อุปกรณ์ตอบสนองและพร้อมสำหรับการทดสอบ |
boolean | waitForDeviceAvailable (long waitTime) รอให้อุปกรณ์ตอบสนองและพร้อมสำหรับการทดสอบ |
void | waitForDeviceBootloader () บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน fastboot |
boolean | waitForDeviceInRecovery (long waitTime) บล็อกสำหรับอุปกรณ์ให้อยู่ในสถานะ 'การกู้คืน adb' (โปรดทราบว่าสิ่งนี้แตกต่างจาก |
boolean | waitForDeviceInSideload (long waitTime) บล็อกสำหรับอุปกรณ์ให้อยู่ในสถานะ 'adb sideload' |
boolean | waitForDeviceNotAvailable (long waitTime) บล็อกสำหรับอุปกรณ์ที่จะใช้งานไม่ได้เช่นหายไปจากadb |
void | waitForDeviceOnline () บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน adb |
void | waitForDeviceOnline (long waitTime) บล็อกจนกว่าอุปกรณ์จะมองเห็นได้ผ่าน adb |
boolean | waitForDeviceShell (long waitTime) รอให้อุปกรณ์ตอบสนองต่อคำสั่งเชลล์ adb พื้นฐาน |
วิธีการป้องกัน | |
---|---|
void | checkApiLevelAgainst (String feature, int strictMinLevel) |
NativeDevice.RebootDeviceAction | createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason) สร้าง |
void | doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason) ทำการรีบูต adb |
void | ensureRuntimePermissionSupported () วิธีตัวช่วยเพื่อส่งข้อยกเว้นหากไม่รองรับการอนุญาตรันไทม์ |
InputStreamSource | getBugreportInternal () |
File | getBugreportzInternal () เมธอด Internal Helper เพื่อรับไฟล์ zip bugreportz เป็น |
IRunUtil | getRunUtil () รับอินสแตนซ์ |
String | internalGetProperty (String propName, String fastbootVar, String description) ดึงคุณสมบัติของอุปกรณ์จากแคช ddmlib โดยค่าเริ่มต้น และถอยกลับไปที่ `adb shell getprop` หรือ `fastboot getvar` ขึ้นอยู่กับว่าอุปกรณ์อยู่ใน Fastboot หรือไม่ |
boolean | isNewer (File localFile, IFileEntry entry) คืน |
boolean | performDeviceAction (String actionDescription, com.android.tradefed.device.NativeDevice.DeviceAction action, int retryAttempts) ดำเนินการกับอุปกรณ์นี้ |
void | postAdbReboot () การดำเนินการเพิ่มเติมที่เป็นไปได้ที่สามารถทำได้หลังจากรีบูต |
void | prePostBootSetup () อนุญาตให้อุปกรณ์แต่ละประเภท (AndroidNativeDevice, TestDevice) แทนที่วิธีนี้สำหรับการตั้งค่าการบูตเฉพาะ |
boolean | pullFileInternal (String remoteFilePath, File localFile) |
void | setClock (Clock clock) ตั้งค่าอินสแตนซ์นาฬิกาที่จะใช้ |
void | setLogStartDelay (int delay) ตั้งเวลาเป็นมิลลิวินาทีที่จะรอก่อนที่จะเริ่มการดักจับ logcat สำหรับอุปกรณ์ออนไลน์ |
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
ค่าที่ส่งคืนสำหรับ ID ผู้ใช้ที่ไม่ถูกต้อง/ไม่พบ: UserHandle กำหนดค่า -10000
ค่าคงที่: -10000 (0xffffd8f0)
MAX_HOST_DEVICE_TIME_OFFSET
protected static final long MAX_HOST_DEVICE_TIME_OFFSET
ค่าคงที่: 5000 (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
mOptions
protected TestDeviceOptions mOptions
ผู้สร้างสาธารณะ
NativeDevice
public NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
สร้าง TestDevice
พารามิเตอร์ | |
---|---|
device | IDevice : IDevice ที่เกี่ยวข้อง |
stateMonitor | IDeviceStateMonitor : กลไก IDeviceStateMonitor ที่จะใช้ |
allocationMonitor | IDeviceMonitor : IDeviceMonitor เพื่อแจ้งการเปลี่ยนแปลงสถานะการจัดสรร สามารถเป็นโมฆะได้ |
วิธีการสาธารณะ
checkApiLevelAgainstNextRelease
public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
ตรวจสอบว่าคุณสมบัติได้รับการสนับสนุนในปัจจุบันหรือไม่โดยได้รับการสนับสนุนในระดับที่น้อยที่สุด วิธีนี้คำนึงถึงคุณลักษณะที่ยังไม่เผยแพร่ก่อนที่จะยกระดับ API
พารามิเตอร์ | |
---|---|
strictMinLevel | int : ระดับต่ำสุดที่เป็นไปได้อย่างเข้มงวดซึ่งสนับสนุนคุณลักษณะนี้ |
คืนสินค้า | |
---|---|
boolean | เป็นจริงหากระดับได้รับการสนับสนุน เท็จเป็นอย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ตรวจสอบการเชื่อมต่อ
public boolean checkConnectivity ()
ตรวจสอบว่าอุปกรณ์มีการเชื่อมต่อเครือข่าย
คืนสินค้า | |
---|---|
boolean | true หากอุปกรณ์มีการเชื่อมต่อเครือข่ายที่ใช้งานได้ false overwise |
ขว้าง | |
---|---|
DeviceNotAvailableException |
clearErrorDialogs
public boolean clearErrorDialogs ()
พยายามปิดกล่องโต้ตอบข้อผิดพลาดที่แสดงอยู่ใน UI ของอุปกรณ์ในปัจจุบัน
คืนสินค้า | |
---|---|
boolean | true หากไม่มีไดอะล็อกหรือไดอะล็อกถูกล้างสำเร็จ false อย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
clearLastConnectedWifiNetwork
public void clearLastConnectedWifiNetwork ()
ล้างเครือข่าย wifi ที่เชื่อมต่อล่าสุด ควรเรียกสิ่งนี้เมื่อเริ่มการเรียกใช้ใหม่เพื่อหลีกเลี่ยงการเชื่อมต่อกับเครือข่าย wifi ที่ใช้ในการทดสอบครั้งก่อนหลังจากอุปกรณ์รีบูต
clearLogcat
public void clearLogcat ()
ลบข้อมูล logcat ที่สะสมไว้
สิ่งนี้มีประโยชน์สำหรับกรณีที่คุณต้องการให้แน่ใจว่าITestDevice#getLogcat()
ส่งคืนเฉพาะข้อมูลบันทึกที่สร้างขึ้นหลังจากจุดหนึ่ง (เช่น หลังจากแฟลชบิลด์อุปกรณ์ใหม่ ฯลฯ) connectToWifiNetwork
public boolean connectToWifiNetwork (wifiSsidToPsk, boolean scanSsid)
เชื่อมต่อกับเครือข่าย wifi
เปิด wifi และบล็อกจนกว่าจะทำการเชื่อมต่อสำเร็จกับหนึ่งในเครือข่าย wifi ที่ระบุในแผนที่ wifiSsidToPsk เมื่อทำการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่า ITestDevice#disconnectFromWifi()
หรือ ITestDevice#clearLastConnectedWifiNetwork()
จะถูกเรียก
พารามิเตอร์ | |
---|---|
wifiSsidToPsk | |
scanSsid | boolean : จะสแกนหา SSID ที่ซ่อนอยู่สำหรับเครือข่ายนี้หรือไม่ |
คืนสินค้า | |
---|---|
boolean | true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
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 |
connectToWifiNetwork
public boolean connectToWifiNetwork (wifiSsidToPsk)
เชื่อมต่อกับเครือข่าย wifi
เปิด wifi และบล็อกจนกว่าจะทำการเชื่อมต่อสำเร็จกับหนึ่งในเครือข่าย wifi ที่ระบุในแผนที่ wifiSsidToPsk เมื่อทำการเชื่อมต่อแล้ว อินสแตนซ์จะพยายามกู้คืนการเชื่อมต่อหลังจากรีบูตทุกครั้งจนกว่า ITestDevice#disconnectFromWifi()
หรือ ITestDevice#clearLastConnectedWifiNetwork()
จะถูกเรียก.f
พารามิเตอร์ | |
---|---|
wifiSsidToPsk |
คืนสินค้า | |
---|---|
boolean | true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
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 |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)
ตัวแปรของ connectToWifiNetwork(String, String)
ที่เชื่อมต่อเฉพาะเมื่ออุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน
พารามิเตอร์ | |
---|---|
scanSsid | boolean : จะสแกนหา SSID ที่ซ่อนอยู่สำหรับเครือข่ายนี้หรือไม่ |
คืนสินค้า | |
---|---|
boolean | true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)
ตัวแปรของ connectToWifiNetwork(String, String)
ที่เชื่อมต่อเฉพาะเมื่ออุปกรณ์ไม่มีการเชื่อมต่อเครือข่ายในปัจจุบัน
คืนสินค้า | |
---|---|
boolean | true หากเชื่อมต่อกับเครือข่าย wifi สำเร็จ false อย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
createUser
public int createUser (String name, boolean guest, boolean ephemeral)
สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กที่ให้มา
พารามิเตอร์ | |
---|---|
name | String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์ |
guest | boolean : เปิดใช้งานการตั้งค่าสถานะผู้ใช้ --guest ระหว่างการสร้าง |
ephemeral | boolean : เปิดใช้งานการตั้งค่าสถานะผู้ใช้ --ชั่วคราว ระหว่างการสร้าง |
คืนสินค้า | |
---|---|
int | id ของผู้ใช้ที่สร้างขึ้น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
createUser
public int createUser (String name)
สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0
พารามิเตอร์ | |
---|---|
name | String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์ |
คืนสินค้า | |
---|---|
int | จำนวนเต็มสำหรับรหัสผู้ใช้ที่สร้างขึ้น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
createUserNoThrow
public int createUserNoThrow (String name)
สร้างผู้ใช้ด้วยชื่อที่กำหนดและแฟล็กเริ่มต้น 0
พารามิเตอร์ | |
---|---|
name | String : ของผู้ใช้ที่จะสร้างบนอุปกรณ์ |
คืนสินค้า | |
---|---|
int | สร้างจำนวนเต็มสำหรับรหัสผู้ใช้หรือ -1 สำหรับข้อผิดพลาด |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ลบไฟล์
public void deleteFile (String deviceFilePath)
วิธีการช่วยเหลือในการลบไฟล์หรือไดเร็กทอรีบนอุปกรณ์
พารามิเตอร์ | |
---|---|
deviceFilePath | String : เส้นทางที่แน่นอนของไฟล์บนอุปกรณ์ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
อุปกรณ์SoftRestarted
public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
วิธีตัวช่วยในการตรวจสอบว่าอุปกรณ์ซอฟต์รีสตาร์ทโดยเปรียบเทียบ system_server ปัจจุบันกับ system_server ProcessInfo
ก่อนหน้าหรือไม่ ใช้ getProcessByName(String)
เพื่อรับ ProcessInfo
พารามิเตอร์ | |
---|---|
prevSystemServerProcess | ProcessInfo : กระบวนการ system_server ก่อนหน้า ProcessInfo |
คืนสินค้า | |
---|---|
boolean | true หากอุปกรณ์รีสตาร์ทแบบซอฟต์ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
อุปกรณ์SoftRestartedตั้งแต่
public boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
วิธีตัวช่วยในการตรวจสอบว่าอุปกรณ์ซอฟต์รีสตาร์ทตั้งแต่เวลา UTC ตั้งแต่ยุคจากอุปกรณ์และ ERROR(/TimeUnit)
Soft-Restart หมายถึง system_server ที่รีสตาร์ทภายนอกฮาร์ดรีบูตของอุปกรณ์ (เช่น: ร้องขอให้รีบูต) อุปกรณ์ปัจจุบัน utcEpochTime ในหน่วยมิลลิวินาทีสามารถรับได้โดยวิธี getDeviceDate()
พารามิเตอร์ | |
---|---|
utcEpochTime | long : เวลาของอุปกรณ์เป็นวินาทีตั้งแต่ยุค |
timeUnit | TimeUnit : หน่วยเวลา TimeUnit สำหรับ utcEpochTime ที่กำหนด |
คืนสินค้า | |
---|---|
boolean | true หากอุปกรณ์รีสตาร์ทแบบซอฟต์ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ปิดการใช้งานAdbRoot
public boolean disableAdbRoot ()
ปิดรูท adb
การปิดใช้งานรูท adb อาจทำให้อุปกรณ์ยกเลิกการเชื่อมต่อจาก 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 |
ไม่FileExist
public boolean doesFileExist (String deviceFilePath, int userId)
วิธี Helper เพื่อตรวจสอบว่าไฟล์ในอุปกรณ์มีอยู่สำหรับผู้ใช้ที่กำหนดหรือไม่
พารามิเตอร์ | |
---|---|
deviceFilePath | String : เส้นทางที่แน่นอนของไฟล์บนอุปกรณ์ที่จะตรวจสอบ |
userId | int : รหัสผู้ใช้ที่ใช้ตรวจสอบการมีอยู่ของไฟล์ |
คืนสินค้า | |
---|---|
boolean | true ถ้ามีไฟล์อยู่ false มิฉะนั้น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ไม่FileExist
public boolean doesFileExist (String deviceFilePath)
วิธี Helper เพื่อตรวจสอบว่าไฟล์ในอุปกรณ์มีอยู่หรือไม่
พารามิเตอร์ | |
---|---|
deviceFilePath | String : เส้นทางที่แน่นอนของไฟล์บนอุปกรณ์ที่จะตรวจสอบ |
คืนสินค้า | |
---|---|
boolean | true ถ้ามีไฟล์อยู่ false มิฉะนั้น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
dumpHeap
public File dumpHeap (String process, String devicePath)
พยายามดัมพ์ฮีพจาก system_server เป็นความรับผิดชอบของผู้โทรในการล้างไฟล์ที่ทิ้ง
พารามิเตอร์ | |
---|---|
process | String : ชื่อของกระบวนการของอุปกรณ์ที่จะถ่ายโอนข้อมูล |
devicePath | String : เส้นทางบนอุปกรณ์ที่จะวางดัมพ์ จะต้องเป็นสถานที่ที่ได้รับอนุญาต |
คืนสินค้า | |
---|---|
File | ERROR(/File) ที่มีรายงาน Null ถ้าบางสิ่งบางอย่างล้มเหลว |
ขว้าง | |
---|---|
DeviceNotAvailableException |
เปิดใช้งานAdbRoot
public boolean enableAdbRoot ()
เปิด adb root หากการตั้งค่า "เปิดใช้งานรูท" เป็น "เท็จ" จะบันทึกข้อความและส่งคืนโดยไม่ต้องเปิดใช้งานรูท
การเปิดใช้งาน adb root อาจทำให้อุปกรณ์ตัดการเชื่อมต่อจาก adb วิธีนี้จะบล็อกจนกว่าอุปกรณ์จะพร้อมใช้งานคืนสินค้า | |
---|---|
boolean | true ถ้าสำเร็จ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
enableNetworkMonitor
public boolean enableNetworkMonitor ()
เปิดใช้งานการตรวจสอบเครือข่ายบนอุปกรณ์
คืนสินค้า | |
---|---|
boolean | true หากเปิดใช้งานการตรวจสอบสำเร็จ false ถ้ามันล้มเหลว |
ขว้าง | |
---|---|
DeviceNotAvailableException |
รันAdbCommand
public String executeAdbCommand (long timeout, String... cmdArgs)
เมธอด Helper ซึ่งรันคำสั่ง adb เป็นคำสั่งระบบที่มีการหมดเวลาที่ระบุ
ควรใช้ executeShellCommand(String)
แทนทุกเมื่อที่ทำได้ เนื่องจากวิธีการดังกล่าวให้การตรวจจับความล้มเหลวและประสิทธิภาพที่ดีขึ้น
พารามิเตอร์ | |
---|---|
timeout | long : เวลาเป็นมิลลิวินาทีก่อนที่อุปกรณ์จะถือว่าไม่ตอบสนอง 0L ไม่มีการหมดเวลา |
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)
เมธอด Helper ซึ่งรันคำสั่ง fastboot เป็นคำสั่งระบบโดยมีการหมดเวลาเริ่มต้น 2 นาที
คาดว่าจะใช้เมื่ออุปกรณ์อยู่ในโหมด fastboot แล้วพารามิเตอร์ | |
---|---|
cmdArgs | String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน |
คืนสินค้า | |
---|---|
CommandResult | CommandResult ที่มีเอาต์พุตของ command |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ดำเนินการFastbootCommand
public CommandResult executeFastbootCommand (long timeout, String... cmdArgs)
เมธอด Helper ซึ่งรันคำสั่ง fastboot เป็นคำสั่งระบบ
คาดว่าจะใช้เมื่ออุปกรณ์อยู่ในโหมด fastboot แล้วพารามิเตอร์ | |
---|---|
timeout | long : เวลาเป็นมิลลิวินาทีก่อนที่คำสั่งจะหมดอายุ |
cmdArgs | String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน |
คืนสินค้า | |
---|---|
CommandResult | CommandResult ที่มีเอาต์พุตของ command |
ขว้าง | |
---|---|
DeviceNotAvailableException |
รันLongFastbootCommand
public CommandResult executeLongFastbootCommand (envVarMap, String... cmdArgs)
เมธอด Helper ซึ่งรันคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบพร้อมตัวแปรสภาพแวดล้อมของระบบ
เหมือนกันกับ executeFastbootCommand(String)
ยกเว้นว่าใช้การหมดเวลานานขึ้น
พารามิเตอร์ | |
---|---|
envVarMap | |
cmdArgs | String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน |
คืนสินค้า | |
---|---|
CommandResult | CommandResult ที่มีเอาต์พุตของ command |
ขว้าง | |
---|---|
DeviceNotAvailableException |
รันLongFastbootCommand
public CommandResult executeLongFastbootCommand (String... cmdArgs)
เมธอด Helper ซึ่งรันคำสั่ง fastboot ที่รันเป็นเวลานานเป็นคำสั่งระบบ
เหมือนกันกับexecuteFastbootCommand(String)
ยกเว้นว่าใช้การหมดเวลานานขึ้นพารามิเตอร์ | |
---|---|
cmdArgs | String : คำสั่ง fastboot และอาร์กิวเมนต์ที่จะรัน |
คืนสินค้า | |
---|---|
CommandResult | CommandResult ที่มีเอาต์พุตของ command |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public String executeShellCommand (String command)
เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งคืนเอาต์พุตเป็น String
พารามิเตอร์ | |
---|---|
command | String : คำสั่งเชลล์ adb เพื่อเรียกใช้ |
คืนสินค้า | |
---|---|
String | ผลลัพธ์ของเชลล์ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง
พารามิเตอร์ | |
---|---|
command | String : คำสั่งเชลล์ adb เพื่อเรียกใช้ |
receiver | IShellOutputReceiver : IShellOutputReceiver เพื่อส่งเอาต์พุตของเชลล์ไปยัง |
maxTimeToOutputShellResponse | long : ระยะเวลาสูงสุดระหว่างที่คำสั่งได้รับอนุญาตให้ไม่แสดงการตอบสนองใด ๆ หน่วยตามที่ระบุใน timeUnit |
timeUnit | TimeUnit : หน่วยสำหรับ maxTimeToOutputShellResponse |
retryAttempts | int : จำนวนครั้งสูงสุดที่จะลองคำสั่งอีกครั้งหากล้มเหลวเนื่องจากข้อยกเว้น retryAttempts จะถูกส่งออกไปหากทำการลองใหม่อีกครั้งโดยไม่ประสบความสำเร็จ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง
พารามิเตอร์ | |
---|---|
command | String : คำสั่งเชลล์ adb เพื่อเรียกใช้ |
receiver | IShellOutputReceiver : IShellOutputReceiver เพื่อส่งเอาต์พุตของเชลล์ไปยัง |
maxTimeoutForCommand | long : หมดเวลาสูงสุดสำหรับคำสั่งให้เสร็จสมบูรณ์; หน่วยตามที่ระบุใน timeUnit |
maxTimeToOutputShellResponse | long : ระยะเวลาสูงสุดระหว่างที่คำสั่งได้รับอนุญาตให้ไม่แสดงการตอบสนองใด ๆ หน่วยตามที่ระบุใน timeUnit |
timeUnit | TimeUnit : หน่วยสำหรับ maxTimeToOutputShellResponse |
retryAttempts | int : จำนวนครั้งสูงสุดที่จะลองคำสั่งอีกครั้งหากล้มเหลวเนื่องจากข้อยกเว้น retryAttempts จะถูกส่งออกไปหากทำการลองใหม่อีกครั้งโดยไม่ประสบความสำเร็จ |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver)
ดำเนินการคำสั่งเชลล์ adb ที่กำหนด ลองใหม่หลายครั้งหากคำสั่งล้มเหลว
รูปแบบที่ง่ายกว่าของexecuteShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
พร้อมค่าเริ่มต้นพารามิเตอร์ | |
---|---|
command | String : คำสั่งเชลล์ adb เพื่อเรียกใช้ |
receiver | IShellOutputReceiver : IShellOutputReceiver เพื่อส่งเอาต์พุตของเชลล์ไปยัง |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd)
เมธอด Helper ซึ่งรันคำสั่ง adb shell และส่งกลับผลลัพธ์เป็น CommandResult
ที่เติมอย่างถูกต้องด้วยเอาต์พุตสถานะคำสั่ง stdout และ stderr
พารามิเตอร์ | |
---|---|
cmd | String : คำสั่งที่ควรรัน |
คืนสินค้า | |
---|---|
CommandResult | ผลลัพธ์ใน CommandResult |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)
เมธอด Helper ที่รันคำสั่งเชลล์ adb และส่งคืนผลลัพธ์เป็น CommandResult
ที่เติมอย่างเหมาะสมด้วยเอาต์พุตสถานะคำสั่งและ stderr stdout ถูกนำไปยังสตรีมที่ระบุ
พารามิเตอร์ | |
---|---|
cmd | String : คำสั่งที่ควรรัน |
pipeToOutput | OutputStream : ERROR(/OutputStream) ที่เอาต์พุต std จะถูกเปลี่ยนเส้นทาง หรือเป็น null |
คืนสินค้า | |
---|---|
CommandResult | ผลลัพธ์ใน CommandResult |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput)
เมธอด Helper ที่รันคำสั่งเชลล์ adb และส่งคืนผลลัพธ์เป็น CommandResult
ที่เติมอย่างเหมาะสมด้วยเอาต์พุตสถานะคำสั่ง stdout และ stderr
พารามิเตอร์ | |
---|---|
cmd | String : คำสั่งที่ควรรัน |
pipeAsInput | File : A ERROR(/File) ที่จะถูกไพพ์เป็นอินพุตของคำสั่ง หรือ null |
คืนสินค้า | |
---|---|
CommandResult | ผลลัพธ์ใน CommandResult |
ขว้าง | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
ดำเนินการคำสั่งเชลล์ adb พร้อมพารามิเตอร์เพิ่มเติมเพื่อควบคุมพฤติกรรมของคำสั่ง
พารามิเตอร์ | |
---|---|
cmd | String : คำสั่งเชลล์ adb เพื่อเรียกใช้ |
maxTimeoutForCommand | long : หมดเวลาสูงสุดสำหรับคำสั่งให้เสร็จสมบูรณ์; หน่วยตามที่ระบุใน timeUnit |
timeUnit | TimeUnit : หน่วยสำหรับ maxTimeToOutputShellResponse |
retryAttempts | int : จำนวนครั้งสูงสุดที่จะลองคำสั่งอีกครั้งหากล้มเหลวเนื่องจากข้อยกเว้น retryAttempts จะถูกส่งออกไปหากทำการลองใหม่อีกครั้งโดยไม่ประสบความสำเร็จ |
คืนสินค้า | |
---|---|
CommandResult |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
fastbootWipePartition
public CommandResult fastbootWipePartition (String partition)
Helper method which wipes a partition for the device.
IfgetUseFastbootErase()
is true
, then fastboot erase will be used to wipe the partition. The device must then create a filesystem the next time the device boots. Otherwise, fastboot format is used which will create a new filesystem on the device. Expected to be used when device is already in fastboot mode.พารามิเตอร์ | |
---|---|
partition | String : the partition to wipe |
คืนสินค้า | |
---|---|
CommandResult | the CommandResult containing output of command |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getActiveApexes
publicgetActiveApexes ()
Fetch the information about APEXes activated on the device.
คืนสินค้า | |
---|---|
ERROR(/Set) of ApexInfo currently activated on the device |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getAllSettings
publicgetAllSettings (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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getAndroidIds
publicgetAndroidIds ()
Create a Map of android ids found matching user ids. There is no insurance that each user id will found an android id associated in this function so some user ids may match null.
คืนสินค้า | |
---|---|
Map of android ids found matching user ids. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getApiLevel
public int getApiLevel ()
Get the device API Level. Defaults to UNKNOWN_API_LEVEL
.
คืนสินค้า | |
---|---|
int | an integer indicating the API Level of device |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getAppPackageInfos
publicgetAppPackageInfos ()
Fetch information of packages installed on the device.
คืนสินค้า | |
---|---|
ERROR(/List) of PackageInfo s installed on the device. |
ขว้าง | |
---|---|
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 String baseband version or null if it cannot be determined (device has no radio or version string cannot be read) |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getBootHistory
publicgetBootHistory ()
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
publicgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
Helper method collects the boot history map with boot time and boot reason since the given time since epoch from device and the time unit specified. The current device utcEpochTime in Millisecond can be obtained by method getDeviceDate()
.
พารามิเตอร์ | |
---|---|
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 |
ขว้าง | |
---|---|
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 String bootloader version or null if it cannot be found |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getBuildFlavor
public String getBuildFlavor ()
Retrieve the build flavor for the device.
คืนสินค้า | |
---|---|
String | the build flavor or null if it could not be retrieved |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Returns the current foldable state of the device or null if some issues occurred.
คืนสินค้า | |
---|---|
DeviceFoldableState |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getCurrentUser
public int getCurrentUser ()
Return the id of the current running user. In case of error, return -10000.
คืนสินค้า | |
---|---|
int |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getDeviceClass
public String getDeviceClass ()
Get the device class.
คืนสินค้า | |
---|---|
String | the 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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public InputStreamSource getEmulatorOutput ()
Get the stream of emulator stdout and stderr
คืนสินค้า | |
---|---|
InputStreamSource | emulator output |
getEmulatorProcess
public Process getEmulatorProcess ()
Return the Process
corresponding to this emulator.
คืนสินค้า | |
---|---|
Process | the 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 |
ขว้าง | |
---|---|
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 genericgetProductType()
method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.คืนสินค้า | |
---|---|
String | the String product type name or null if it cannot be determined |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getFastbootProductVariant
public String getFastbootProductVariant ()
Convenience method to get the product type of this device when its in fastboot mode.
This method should only be used if device should be in fastboot. Its a bit safer variant than the genericgetProductType()
method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.คืนสินค้า | |
---|---|
String | the String product type name or null if it cannot be determined |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getFoldableStates
publicgetFoldableStates ()
Returns the list of foldable states on the device. Can be obtained with "cmd device_state print-states".
คืนสินค้า | |
---|---|
ขว้าง | |
---|---|
DeviceNotAvailableException |
getIDevice
public IDevice getIDevice ()
Returns a reference to the associated ddmlib IDevice
.
IDevice
may be allocated by DDMS each time the device disconnects and reconnects from adb. Thus callers should not keep a reference to the IDevice
, because that reference may become stale.คืนสินค้า | |
---|---|
IDevice | the IDevice |
getInstalledPackageNames
publicgetInstalledPackageNames ()
Fetch the application package names present on the device.
คืนสินค้า | |
---|---|
ERROR(/Set) of String package names currently installed on the device. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public long getLastExpectedRebootTimeMillis ()
Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by 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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getLogcat
public InputStreamSource getLogcat ()
Grabs a snapshot stream of the logcat data.
Works in two modes:
TestDeviceOptions.getMaxLogcatDataSize()
bytes of the current contents of the background logcat captureคืนสินค้า | |
---|---|
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 |
getMainlineModuleInfo
publicgetMainlineModuleInfo ()
Get the information about the mainline modules installed on the device.
คืนสินค้า | |
---|---|
ERROR(/Set) of String mainline modules currently installed on the device. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
Get the maximum number of supported users. Defaults to 0.
คืนสินค้า | |
---|---|
int | an integer indicating the number of supported users |
ขว้าง | |
---|---|
DeviceNotAvailableException |
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 inIDevice
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" |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getMountPointInfo
publicgetMountPointInfo ()
Returns a parsed version of the information in /proc/mounts on the device
คืนสินค้า | |
---|---|
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 String product type name. Will not be null |
ขว้าง | |
---|---|
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 String product variant name or null if it cannot be determined |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getSerialNumber
public String getSerialNumber ()
Convenience method to get serial number of this device.
คืนสินค้า | |
---|---|
String | the String serial number |
getSetting
public String getSetting (int userId, String namespace, String key)
Return the value of the requested setting. namespace must be one of: {"system", "secure", "global"}
พารามิเตอร์ | |
---|---|
userId | int |
namespace | String |
key | String |
คืนสินค้า | |
---|---|
String | the value associated with the namespace:key of a user. Null if not found. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getSetting
public String getSetting (String namespace, String key)
See getSetting(int, String, String)
and performed on system user.
พารามิเตอร์ | |
---|---|
namespace | String |
key | String |
คืนสินค้า | |
---|---|
String |
ขว้าง | |
---|---|
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
publicgetTombstones ()
Fetch and return the list of tombstones from the devices. Requires root.
method is best-effort so if one tombstone fails to be pulled for any reason it will be missing from the list. Only a DeviceNotAvailableException
will terminate the method early.
คืนสินค้า | |
---|---|
A list of tombstone files, empty if no tombstone. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getTotalMemory
public long getTotalMemory ()
Returns total physical memory size in bytes or -1 in case of internal error
คืนสินค้า | |
---|---|
long |
getUninstallablePackageNames
publicgetUninstallablePackageNames ()
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 String package names currently installed on the device. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
getUserInfos
publicgetUserInfos ()
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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: |
คืนสินค้า | |
---|---|
boolean | True if feature is found, false otherwise. |
ขว้าง | |
---|---|
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 String with an error code, or null if success. |
ขว้าง | |
---|---|
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 String with an error code, or null if success. |
ขว้าง | |
---|---|
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 String with an error code, or null if success. |
ขว้าง | |
---|---|
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 String with an error code, or null if success. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
isDeviceEncrypted
public boolean isDeviceEncrypted ()
Returns if the device is encrypted.
คืนสินค้า | |
---|---|
boolean | true if the device is encrypted. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
isDirectory
public boolean isDirectory (String path)
Return True if the path on the device is a directory, false otherwise.
พารามิเตอร์ | |
---|---|
path | String |
คืนสินค้า | |
---|---|
boolean |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
isMultiUserSupported
public boolean isMultiUserSupported ()
Determines if multi user is supported.
คืนสินค้า | |
---|---|
boolean | true if multi user is supported, false otherwise |
ขว้าง | |
---|---|
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. เท็จเป็นอย่างอื่น |
ขว้าง | |
---|---|
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. เท็จเป็นอย่างอื่น |
ขว้าง | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public boolean isRuntimePermissionSupported ()
Check whether platform on device supports runtime permission granting
คืนสินค้า | |
---|---|
boolean | True if runtime permission are supported, false otherwise. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
listDisplayIds
publiclistDisplayIds ()
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
listUsers
publiclistUsers ()
Gets the list of users on the device. Will throw DeviceRuntimeException
if output from device is not as expected.
คืนสินค้า | |
---|---|
the list of user ids. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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.
ขว้าง | |
---|---|
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.
ขว้าง | |
---|---|
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.
ขว้าง | |
---|---|
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)ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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) |
ขว้าง | |
---|---|
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) |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 String containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
ขว้าง | |
---|---|
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) |
ขว้าง | |
---|---|
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 |
คืนสินค้า | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
reboot
public void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.ขว้าง | |
---|---|
DeviceNotAvailableException |
rebootIntoBootloader
public void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.ขว้าง | |
---|---|
DeviceNotAvailableException |
rebootIntoFastbootd
public void rebootIntoFastbootd ()
Reboots the device into fastbootd mode.
Blocks until device is in fastbootd mode.
ขว้าง | |
---|---|
DeviceNotAvailableException |
rebootIntoRecovery
public void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryขว้าง | |
---|---|
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
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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.
ขว้าง | |
---|---|
DeviceNotAvailableException |
rebootUserspaceUntilOnline
public void rebootUserspaceUntilOnline ()
An alternate to rebootUserspace()
()} that only blocks until device is online ie visible to adb.
ขว้าง | |
---|---|
DeviceNotAvailableException |
recoverDevice
public boolean recoverDevice ()
Attempts to recover device communication.
คืนสินค้า | |
---|---|
boolean | True if recovery attempted and successful, returns False if recovery was skipped |
ขว้าง | |
---|---|
DeviceNotAvailableException | if device is no longer available |
remountSystemWritable
public void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
ขว้าง | |
---|---|
DeviceNotAvailableException |
remountVendorWritable
public void remountVendorWritable ()
Make the vendor partition on the device writable. May reboot the device.
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
removeOwners
public void removeOwners ()
Remove all existing device profile owners with the best effort.
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
คืนสินค้า | |
---|---|
boolean | true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 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 |
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public boolean switchToAdbUsb ()
Switch device to adb over usb mode.
คืนสินค้า | |
---|---|
boolean | true if switch was successful, false otherwise. |
ขว้าง | |
---|---|
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. เท็จเป็นอย่างอื่น |
ขว้าง | |
---|---|
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. เท็จเป็นอย่างอื่น |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
takeBugreport
public Bugreport takeBugreport ()
Take a bugreport and returns it inside a Bugreport
object to handle it. Return null in case of issue.
Bugreport#close()
.คืนสินค้า | |
---|---|
Bugreport |
uninstallPackage
public String uninstallPackage (String packageName)
Uninstall an Android package from device.
พารามิเตอร์ | |
---|---|
packageName | String : the Android package to uninstall |
คืนสินค้า | |
---|---|
String | a String with an error code, or null if success. |
ขว้าง | |
---|---|
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 String with an error code, or null if success. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
unlockDevice
public boolean unlockDevice ()
Unlocks the device if the device is in an encrypted state.
This method may restart the framework but will not callpostBootSetup()
. Therefore, the device might not be fully ready to be tested when this method returns.คืนสินค้า | |
---|---|
boolean | true if successful or if the device is unencrypted. |
ขว้าง | |
---|---|
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 |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
waitForDeviceBootloader
public void waitForDeviceBootloader ()
Blocks until device is visible via fastboot. Use default timeout.
ขว้าง | |
---|---|
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. UsewaitForDeviceAvailable()
instead.ขว้าง | |
---|---|
DeviceNotAvailableException |
waitForDeviceOnline
public void waitForDeviceOnline (long waitTime)
Blocks until device is visible via adb.
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.พารามิเตอร์ | |
---|---|
waitTime | long : the time in ms to wait |
ขว้าง | |
---|---|
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. |
วิธีการป้องกัน
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 . |
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. |
ขว้าง | |
---|---|
DeviceNotAvailableException |
ensureRuntimePermissionSupported
protected void ensureRuntimePermissionSupported ()
helper method to throw exception if runtime permission isn't supported
ขว้าง | |
---|---|
DeviceNotAvailableException |
getBugreportInternal
protected InputStreamSource getBugreportInternal ()
คืนสินค้า | |
---|---|
InputStreamSource |
getBugreportzInternal
protected File getBugreportzInternal ()
Internal Helper method to get the bugreportz zip file as a ERROR(/File)
.
คืนสินค้า | |
---|---|
File |
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 |
ขว้าง | |
---|---|
DeviceNotAvailableException |
isNewer
protected boolean isNewer (File localFile, IFileEntry entry)
Return true
if local file is newer than remote file. IFileEntry
being accurate to the minute, in case of equal times, the file will be considered newer.
พารามิเตอร์ | |
---|---|
localFile | File |
entry | IFileEntry |
คืนสินค้า | |
---|---|
boolean |
performDeviceAction
protected boolean performDeviceAction (String actionDescription, com.android.tradefed.device.NativeDevice.DeviceAction action, int retryAttempts)
Performs an action on this device. Attempts to recover device and optionally retry command if action fails.
พารามิเตอร์ | |
---|---|
actionDescription | String : a short description of action to be performed. Used for logging purposes only. |
action | com.android.tradefed.device.NativeDevice.DeviceAction : the action to be performed |
retryAttempts | int : the retry attempts to make for action if it fails but recovery succeeds |
คืนสินค้า | |
---|---|
boolean | true if action was performed successfully |
ขว้าง | |
---|---|
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.
ขว้าง | |
---|---|
DeviceNotAvailableException |
prePostBootSetup
protected void prePostBootSetup ()
Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.
ขว้าง | |
---|---|
DeviceNotAvailableException |
pullFileInternal
protected boolean pullFileInternal (String remoteFilePath, File localFile)
พารามิเตอร์ | |
---|---|
remoteFilePath | String |
localFile | File |
คืนสินค้า | |
---|---|
boolean |
ขว้าง | |
---|---|
DeviceNotAvailableException |
setClock
protected void setClock (Clock clock)
Set the Clock instance to use.
พารามิเตอร์ | |
---|---|
clock | Clock |
setLogStartDelay
protected 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 |
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. |
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2022-11-07 UTC