Thiết bị gốc
public class NativeDevice
extends Object
implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver
java.lang.Object | |
↳ | com.android.tradefed.device.NativeDevice |
Triển khai mặc định của ITestDevice
Thiết bị Android không phải ngăn xếp đầy đủ.
Bản tóm tắt
các lớp lồng nhau | |
---|---|
class | NativeDevice.AdbAction |
class | NativeDevice.AdbShellAction |
class | NativeDevice.RebootDeviceAction |
hằng số | |
---|---|
int | INVALID_USER_ID Giá trị được trả về cho bất kỳ id người dùng không hợp lệ/không tìm thấy: UserHandle đã xác định giá trị -10000 |
long | MAX_HOST_DEVICE_TIME_OFFSET |
int | MAX_RETRY_ATTEMPTS số lần thử lại lệnh mặc định để thực hiện |
Lĩnh vực | |
---|---|
protected static final String | SD_CARD |
protected static final String | STORAGE_EMULATED |
protected TestDeviceOptions | mOptions |
protected final IDeviceStateMonitor | mStateMonitor
|
nhà thầu công cộng | |
---|---|
NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor) Tạo một |
Phương thức công khai | |
---|---|
boolean | canSwitchToHeadlessSystemUser () Trả về liệu nó có được phép chuyển sang người dùng HỆ THỐNG không đầu hay không. |
boolean | checkApiLevelAgainstNextRelease (int strictMinLevel) Kiểm tra xem một tính năng hiện có được hỗ trợ hay không ở mức được hỗ trợ tối thiểu. |
boolean | checkConnectivity () Kiểm tra xem thiết bị có kết nối mạng không. |
boolean | clearErrorDialogs () Cố gắng loại bỏ mọi hộp thoại báo lỗi hiện đang hiển thị trên giao diện người dùng của thiết bị. |
void | clearLastConnectedWifiNetwork () Xóa mạng wifi được kết nối lần cuối. |
void | clearLogcat () Xóa mọi dữ liệu logcat tích lũy. |
boolean | connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) Kết nối với một mạng wifi. |
boolean | connectToWifiNetwork (String wifiSsid, String wifiPsk) Kết nối với một mạng wifi. |
boolean | connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk) Kết nối với mạng wifi.f |
boolean | connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid) Kết nối với một mạng wifi. |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid) Một biến thể của |
boolean | connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk) Một biến thể của |
int | createUser (String name, boolean guest, boolean ephemeral) Tạo người dùng có tên đã cho và các cờ được cung cấp |
int | createUser (String name, boolean guest, boolean ephemeral, boolean forTesting) Tạo người dùng có tên đã cho và các cờ được cung cấp |
int | createUser (String name) Tạo người dùng có tên đã cho và cờ mặc định 0. |
int | createUserNoThrow (String name) Tạo người dùng có tên đã cho và cờ mặc định 0. |
void | deleteFile (String deviceFilePath) Phương thức trợ giúp để xóa tệp hoặc thư mục trên thiết bị. |
void | deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver) Xóa |
boolean | deviceSoftRestarted ( ProcessInfo prevSystemServerProcess) Phương pháp trợ giúp để kiểm tra xem thiết bị có khởi động lại mềm hay không bằng cách so sánh system_server hiện tại với system_server |
boolean | deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit) Phương pháp trợ giúp để kiểm tra xem thiết bị có khởi động lại mềm kể từ thời gian UTC kể từ Epoch từ thiết bị và |
boolean | disableAdbRoot () Tắt adb root. |
void | disableKeyguard () Cố gắng vô hiệu hóa keyguard. |
boolean | disableNetworkMonitor () Vô hiệu hóa giám sát mạng trên thiết bị. |
boolean | disconnectFromWifi () Ngắt kết nối khỏi mạng wifi. |
boolean | doesFileExist (String deviceFilePath, int userId) Phương thức trợ giúp để xác định xem tệp trên thiết bị có tồn tại cho một người dùng cụ thể hay không. |
boolean | doesFileExist (String deviceFilePath) Phương pháp trợ giúp để xác định xem tệp trên thiết bị có tồn tại hay không. |
File | dumpHeap (String process, String devicePath) Cố gắng kết xuất đống từ system_server. |
boolean | enableAdbRoot () Bật adb root. |
boolean | enableNetworkMonitor () Cho phép giám sát mạng trên thiết bị. |
String | executeAdbCommand (long timeout, String... cmdArgs) Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống với thời gian chờ được chỉ định. |
String | executeAdbCommand (long timeout, envMap, String... cmdArgs) executeAdbCommand (long timeout, envMap, String... cmdArgs) Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống với thời gian chờ được chỉ định. |
String | executeAdbCommand (String... cmdArgs) Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống. |
CommandResult | executeFastbootCommand (String... cmdArgs) Phương thức trợ giúp thực thi lệnh fastboot dưới dạng lệnh hệ thống với thời gian chờ mặc định là 2 phút. |
CommandResult | executeFastbootCommand (long timeout, String... cmdArgs) Phương thức trợ giúp thực thi lệnh fastboot dưới dạng lệnh hệ thống. |
CommandResult | executeLongFastbootCommand (String... cmdArgs) Phương thức trợ giúp thực thi lệnh fastboot chạy dài dưới dạng lệnh hệ thống. |
CommandResult | executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs) Phương thức trợ giúp thực thi lệnh fastboot chạy dài dưới dạng lệnh hệ thống với các biến môi trường hệ thống. |
String | executeShellCommand (String command) Phương thức trợ giúp thực thi lệnh shell adb và trả về đầu ra dưới dạng |
void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
void | executeShellCommand (String command, IShellOutputReceiver receiver) Thực thi lệnh adb shell đã cho, thử lại nhiều lần nếu lệnh không thành công. |
CommandResult | executeShellV2Command (String cmd) Phương thức trợ giúp thực thi lệnh trình bao adb và trả về kết quả dưới dạng |
CommandResult | executeShellV2Command (String cmd, OutputStream pipeToOutput) Phương thức trợ giúp thực thi lệnh trình bao adb và trả về kết quả dưới dạng |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput) Phương thức trợ giúp thực thi lệnh trình bao adb và trả về kết quả dưới dạng |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
CommandResult | executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
CommandResult | executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh. |
CommandResult | fastbootWipePartition (String partition) Phương thức trợ giúp xóa phân vùng cho thiết bị. |
getActiveApexes () Tìm nạp thông tin về các APEX được kích hoạt trên thiết bị. | |
getAllSettings (String namespace) Trả về các cặp giá trị khóa của không gian tên được yêu cầu. | |
DeviceAllocationState | getAllocationState () Trả về trạng thái phân bổ hiện tại của thiết bị |
String | getAndroidId (int userId) Tìm và trả lại android-id được liên kết với userId, null nếu không tìm thấy. |
getAndroidIds () Tạo Bản đồ id android được tìm thấy phù hợp với id người dùng. | |
int | getApiLevel () Nhận cấp độ API của thiết bị. |
PackageInfo | getAppPackageInfo (String packageName) Tìm nạp thông tin về một gói được cài đặt trên thiết bị. |
getAppPackageInfos () Tìm nạp thông tin của các gói được cài đặt trên thiết bị. | |
String | getBasebandVersion () Phương pháp thuận tiện để có được phiên bản băng tần cơ sở (radio) của thiết bị này. |
Integer | getBattery () Trả về mức pin hiện tại của thiết bị hoặc Null nếu không có mức pin. |
boolean | getBooleanProperty (String name, boolean defaultValue) Trả về giá trị boolean của thuộc tính đã cho. |
getBootHistory () Phương thức trợ giúp thu thập bản đồ lịch sử khởi động với thời gian khởi động và lý do khởi động. | |
getBootHistorySince (long utcEpochTime, TimeUnit timeUnit) Phương thức của trình trợ giúp thu thập bản đồ lịch sử khởi động với thời gian khởi động và lý do khởi động kể từ thời điểm đã cho kể từ kỷ nguyên từ thiết bị và đơn vị thời gian được chỉ định. | |
String | getBootloaderVersion () Phương pháp thuận tiện để tải phiên bản bộ nạp khởi động của thiết bị này. |
InputStreamSource | getBugreport () Truy xuất báo cáo lỗi từ thiết bị. |
InputStreamSource | getBugreportz () Lấy báo cáo lỗi từ thiết bị. |
String | getBuildAlias () Truy xuất bí danh của bản dựng mà thiết bị hiện đang chạy. |
String | getBuildFlavor () Truy xuất hương vị xây dựng cho thiết bị. |
String | getBuildId () Truy xuất bản dựng mà thiết bị hiện đang chạy. |
String | getBuildSigningKeys () Trả về loại khóa được sử dụng để ký hình ảnh thiết bị Thông thường, các thiết bị Android có thể được ký bằng khóa kiểm tra (như trong AOSP) hoặc khóa phát hành (do nhà sản xuất thiết bị riêng lẻ kiểm soát) |
DeviceDescriptor | getCachedDeviceDescriptor () Trả về một |
DeviceDescriptor | getCachedDeviceDescriptor (boolean shortDescriptor) Trả về một |
String[] | getChildren (String path) Thay thế cho việc sử dụng |
AbstractConnection | getConnection () Kết nối hiện tại được liên kết với thiết bị. |
DeviceFoldableState | getCurrentFoldableState () Trả về trạng thái có thể gập lại hiện tại của thiết bị hoặc trả về giá trị rỗng nếu xảy ra sự cố. |
int | getCurrentUser () Trả về id của người dùng đang chạy hiện tại. |
String | getDeviceClass () Nhận lớp thiết bị. |
long | getDeviceDate () Trả về ngày của thiết bị tính bằng mili giây kể từ epoch. |
DeviceDescriptor | getDeviceDescriptor () Trả về một |
DeviceDescriptor | getDeviceDescriptor (boolean shortDescriptor) Trả về một |
TestDeviceState | getDeviceState () Nhận trạng thái của thiết bị. |
long | getDeviceTimeOffset (Date date) Trình trợ giúp để nhận chênh lệch múi giờ giữa thiết bị và |
InputStreamSource | getEmulatorOutput () Nhận luồng trình giả lập thiết bị xuất chuẩn và thiết bị xuất chuẩn |
Process | getEmulatorProcess () Trả về |
final File | getExecuteShellCommandLog () Nhật ký chứa tất cả các nhật ký |
long | getExternalStoreFreeSpace () Phương pháp trợ giúp để xác định dung lượng trống trên bộ nhớ ngoài của thiết bị. |
String | getFastbootPath () Trả về đường dẫn của tệp nhị phân fastboot đang được sử dụng. |
String | getFastbootProductType () Phương pháp thuận tiện để lấy loại sản phẩm của thiết bị này khi thiết bị ở chế độ fastboot. |
String | getFastbootProductVariant () Phương pháp thuận tiện để lấy loại sản phẩm của thiết bị này khi thiết bị ở chế độ fastboot. |
String | getFastbootSerialNumber () Trả về số sê-ri chế độ fastboot. |
String | getFastbootVariable (String variableName) Truy xuất giá trị biến fastboot đã cho từ thiết bị. |
String | getFastbootVersion () Trả về chuỗi phiên bản của tệp nhị phân fastboot đang được sử dụng. |
IFileEntry | getFileEntry (String path) Truy xuất tham chiếu đến tệp từ xa trên thiết bị. |
IFileEntry | getFileEntry (FileListingService.FileEntry entry) Trình trợ giúp không chính thức để nhận |
getFoldableStates () Trả về danh sách các trạng thái có thể gập lại trên thiết bị. | |
IDevice | getIDevice () Trả về một tham chiếu đến ddmlib |
getInstalledPackageNames () Tìm nạp tên gói ứng dụng có trên thiết bị. | |
long | getIntProperty (String name, long defaultValue) Trả về giá trị nguyên của thuộc tính đã cho từ thiết bị. |
String | getIpAddress () Lấy địa chỉ IP của thiết bị. |
KeyguardControllerState | getKeyguardState () Trả về một đối tượng để lấy trạng thái hiện tại của keyguard hoặc null nếu không được hỗ trợ. |
long | getLastExpectedRebootTimeMillis () Trả về lần cuối cùng API được trao đổi kích hoạt khởi động lại sau mili giây kể từ EPOCH khi được trả về bởi |
int | getLaunchApiLevel () Nhận Cấp API khởi chạy đầu tiên của thiết bị. |
InputStreamSource | getLogcat () Lấy một luồng ảnh chụp nhanh của dữ liệu logcat. |
InputStreamSource | getLogcat (int maxBytes) Lấy một luồng ảnh chụp nhanh của |
InputStreamSource | getLogcatDump () Nhận kết xuất logcat hiện tại cho thiết bị. |
InputStreamSource | getLogcatSince (long date) Lấy một luồng ảnh chụp nhanh dữ liệu logcat đã chụp bắt đầu từ ngày được cung cấp. |
String | getMacAddress () Trả về địa chỉ MAC của thiết bị, null nếu không thể truy vấn từ thiết bị. |
Integer | getMainUserId () Trả về id người dùng chính. |
getMainlineModuleInfo () Nhận thông tin về các mô-đun chính được cài đặt trên thiết bị. | |
int | getMaxNumberOfRunningUsersSupported () Nhận số lượng người dùng chạy đồng thời được hỗ trợ tối đa. |
int | getMaxNumberOfUsersSupported () Nhận số lượng người dùng được hỗ trợ tối đa. |
Process | getMicrodroidProcess () |
IDeviceStateMonitor | getMonitor () Trả lại |
String | getMountPoint (String mountName) Trả về một điểm gắn kết. |
ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) Trả về |
getMountPointInfo () Trả về phiên bản được phân tích cú pháp của thông tin trong /proc/mounts trên thiết bị | |
TestDeviceOptions | getOptions () Tìm nạp các tùy chọn kiểm tra cho thiết bị. |
long | getPartitionFreeSpace (String partition) Phương pháp trợ giúp để xác định dung lượng trống trên phân vùng thiết bị. |
Integer | getPrimaryUserId () Trả về id người dùng chính. |
ProcessInfo | getProcessByName (String processName) Phương thức của trình trợ giúp chạy lệnh "pidof" và "stat" và trả về đối tượng |
String | getProcessPid (String process) Trả về pid của dịch vụ hoặc null nếu xảy ra sự cố. |
String | getProductType () Phương pháp thuận tiện để có được loại sản phẩm của thiết bị này. |
String | getProductVariant () Phương pháp thuận tiện để có được biến thể sản phẩm của thiết bị này. |
String | getProperty (String name) Truy xuất giá trị thuộc tính đã cho từ thiết bị. |
ITestDevice.RecoveryMode | getRecoveryMode () Nhận chế độ khôi phục hiện tại được sử dụng cho thiết bị. |
InputStreamSource | getScreenshot (String format) Chụp ảnh màn hình từ thiết bị. |
InputStreamSource | getScreenshot (long displayId) Lấy ảnh chụp màn hình từ id hiển thị đã cho của thiết bị. |
InputStreamSource | getScreenshot (String format, boolean rescale) Chụp ảnh màn hình từ thiết bị. |
InputStreamSource | getScreenshot () Chụp ảnh màn hình từ thiết bị. |
String | getSerialNumber () Phương pháp thuận tiện để lấy số sê-ri của thiết bị này. |
String | getSetting (int userId, String namespace, String key) Trả về giá trị của cài đặt được yêu cầu. |
String | getSetting (String namespace, String key) Xem |
String | getSimOperator () Trả lại nhà khai thác thẻ SIM hoặc null nếu không có sẵn hoặc nếu không có thiết bị. |
String | getSimState () Trả về trạng thái thẻ SIM hoặc null nếu không có hoặc không có thiết bị. |
getTombstones () Tìm nạp và trả lại danh sách các bia mộ từ thiết bị. | |
long | getTotalMemory () Trả về tổng kích thước bộ nhớ vật lý theo byte hoặc -1 trong trường hợp có lỗi nội bộ |
getUninstallablePackageNames () Tìm nạp tên gói ứng dụng có thể gỡ cài đặt. | |
boolean | getUseFastbootErase () Nhận xem nên sử dụng xóa fastboot hay định dạng fastboot để xóa phân vùng trên thiết bị. |
int | getUserFlags (int userId) Tìm và trả lại các cờ của một người dùng nhất định. |
getUserInfos () Tải Bản đồ của useId tới | |
int | getUserSerialNumber (int userId) Trả lại số sê-ri được liên kết với userId nếu tìm thấy, -10000 trong mọi trường hợp khác. |
IManagedTestDevice.DeviceEventResponse | handleAllocationEvent (DeviceEvent event) Xử lý Xử lý DeviceEvent, có thể hoặc không thể chuyển thiết bị này sang trạng thái phân bổ mới. |
boolean | hasFeature (String feature) Kiểm tra xem một tính năng có sẵn trên thiết bị hay không. |
String | installPackage (File packageFile, boolean reinstall, String... extraArgs) Cài đặt gói Android trên thiết bị. |
String | installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs) Cài đặt gói Android trên thiết bị. |
String | installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs) Cài đặt gói Android trên thiết bị cho một người dùng nhất định. |
String | installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) Cài đặt gói Android trên thiết bị cho một người dùng nhất định. |
boolean | isAdbRoot () |
boolean | isAdbTcp () |
boolean | isAppEnumerationSupported () Kiểm tra xem nền tảng trên thiết bị có hỗ trợ liệt kê ứng dụng hay không |
boolean | isBypassLowTargetSdkBlockSupported () Kiểm tra xem nền tảng trên thiết bị có hỗ trợ bỏ qua khối sdk mục tiêu thấp khi cài đặt ứng dụng hay không |
boolean | isDeviceEncrypted () Trả về nếu thiết bị được mã hóa. |
boolean | isDirectory (String path) Trả về True nếu đường dẫn trên thiết bị là một thư mục, ngược lại là false. |
boolean | isEnableAdbRoot () |
boolean | isEncryptionSupported () Trả về nếu mã hóa được hỗ trợ trên thiết bị. |
boolean | isExecutable (String fullPath) Trả về True nếu đường dẫn tệp trên thiết bị là tệp thực thi, nếu không thì trả về false. |
boolean | isFastbootEnabled () Quay lại nếu fastboot có sẵn cho thiết bị. |
boolean | isHeadless () Trả về true nếu thiết bị không đầu (không có màn hình), ngược lại trả về false. |
boolean | isHeadlessSystemUserMode () Trả về việc thiết bị có sử dụng chế độ người dùng hệ thống không đầu hay không. |
boolean | isMainUserPermanentAdmin () Trả về liệu người dùng chính có phải là quản trị viên vĩnh viễn hay không và không thể bị xóa hoặc hạ cấp xuống trạng thái không phải quản trị viên. |
boolean | isMultiUserSupported () Xác định xem nhiều người dùng có được hỗ trợ hay không. |
boolean | isPackageInstalled (String packageName, String userId) Truy vấn thiết bị để biết tên gói nhất định và id người dùng đã cho để kiểm tra xem thiết bị hiện đã được cài đặt hay chưa cho người dùng đó. |
boolean | isPackageInstalled (String packageName) Truy vấn thiết bị cho một tên gói nhất định để kiểm tra xem nó hiện đã được cài đặt hay chưa. |
boolean | isRuntimePermissionSupported () Kiểm tra xem nền tảng trên thiết bị có hỗ trợ cấp quyền trong thời gian chạy không |
boolean | isStateBootloaderOrFastbootd () Trả về true nếu thiết bị đang ở |
boolean | isUserRunning (int userId) Kiểm tra xem một người dùng nhất định có đang chạy không. |
boolean | isUserSecondary (int userId) Trả về xem người dùng được chỉ định có phải là người dùng phụ hay không theo cờ của người dùng đó. |
boolean | isUserVisible (int userId) Kiểm tra xem người dùng đã cho có hiển thị không. |
boolean | isUserVisibleOnDisplay (int userId, int displayId) Kiểm tra xem người dùng đã cho có hiển thị trong màn hình đã cho hay không. |
boolean | isVisibleBackgroundUsersOnDefaultDisplaySupported () Trả về liệu thiết bị có cho phép bắt đầu hiển thị người dùng trong nền hay không trong |
boolean | isVisibleBackgroundUsersSupported () Trả về liệu thiết bị có cho phép bắt đầu hiển thị người dùng trong nền hay không. |
boolean | isWifiEnabled () Kiểm tra xem wifi đã được bật chưa. |
listDisplayIds () Thu thập danh sách id hiển thị có sẵn trên thiết bị như được báo cáo bởi "dumpsys SurfaceFlinger". | |
listDisplayIdsForStartingVisibleBackgroundUsers () Nhận danh sách các màn hình có thể được sử dụng để | |
listUsers () Lấy danh sách người dùng trên thiết bị. | |
boolean | logAnrs ( ITestLogger logger) Thu thập và ghi nhật ký ANR từ thiết bị. |
boolean | logBugreport (String dataName, ITestLogger listener) Phương thức trợ giúp để lấy báo cáo lỗi và ghi lại cho người báo cáo. |
void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) Đăng một tin nhắn trong logcat của thiết bị. |
void | nonBlockingReboot () Đưa ra lệnh khởi động lại thiết bị và trả về khi hoàn thành lệnh và khi thiết bị không còn hiển thị với adb. |
void | postAdbRootAction () Ghi đè nếu thiết bị cần thực hiện một số hành động cụ thể sau khi adb root và trước khi thiết bị trực tuyến trở lại. |
void | postAdbUnrootAction () Ghi đè nếu thiết bị cần thực hiện một số hành động cụ thể sau khi hủy root adb và trước khi thiết bị trực tuyến trở lại. |
void | postBootSetup () Thực hiện hướng dẫn cấu hình thiết bị để kiểm tra sau mỗi lần khởi động. |
void | postInvocationTearDown (Throwable exception) Các bước bổ sung để dọn dẹp theo yêu cầu cụ thể của thiết bị sẽ được thực thi sau khi lệnh gọi hoàn tất. |
void | preInvocationSetup ( IBuildInfo info, MultiMap <String, String> attributes) Các bước bổ sung cho thiết lập bắt buộc cụ thể của thiết bị sẽ được thực thi trên thiết bị trước quy trình gọi. |
boolean | pullDir (String deviceFilePath, File localDir) Kéo đệ quy nội dung thư mục từ thiết bị. |
boolean | pullFile (String remoteFilePath, File localFile) Truy xuất tệp từ thiết bị. |
File | pullFile (String remoteFilePath, int userId) Truy xuất một tệp từ thiết bị, lưu trữ tệp đó trong |
File | pullFile (String remoteFilePath) Truy xuất một tệp từ thiết bị, lưu trữ tệp đó trong |
boolean | pullFile (String remoteFilePath, File localFile, int userId) Truy xuất tệp từ thiết bị. |
String | pullFileContents (String remoteFilePath) Truy xuất tệp từ thiết bị và trả về nội dung. |
File | pullFileFromExternal (String remoteFilePath) Một phương pháp thuận tiện để truy xuất một tệp từ bộ nhớ ngoài của thiết bị, lưu trữ tệp đó trong một |
boolean | pushDir (File localFileDir, String deviceFilePath, excludedDirectories) pushDir (File localFileDir, String deviceFilePath, excludedDirectories) Đệ quy đẩy nội dung thư mục vào thiết bị trong khi loại trừ một số thư mục được lọc. |
boolean | pushDir (File localFileDir, String deviceFilePath) Đệ quy đẩy nội dung thư mục vào thiết bị. |
boolean | pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded) Biến thể của |
boolean | pushFile (File localFile, String remoteFilePath) Đẩy một tập tin vào thiết bị. |
boolean | pushString (String contents, String remoteFilePath) Đẩy tệp được tạo từ một chuỗi vào thiết bị |
void | reboot (String reason) Khởi động lại thiết bị vào chế độ adb với |
void | reboot () Khởi động lại thiết bị vào chế độ adb. |
void | rebootIntoBootloader () Khởi động lại thiết bị vào chế độ bootloader. |
void | rebootIntoFastbootd () Khởi động lại thiết bị vào chế độ fastbootd. |
void | rebootIntoRecovery () Khởi động lại thiết bị vào chế độ khôi phục adb. |
void | rebootIntoSideload () Khởi động lại thiết bị vào chế độ adb sideload (lưu ý rằng đây là chế độ đặc biệt đang được khôi phục) Chặn cho đến khi thiết bị vào chế độ sideload |
void | rebootIntoSideload (boolean autoReboot) Khởi động lại thiết bị vào chế độ adb sideload (lưu ý rằng đây là chế độ đặc biệt đang được khôi phục) Chặn cho đến khi thiết bị vào chế độ sideload |
void | rebootUntilOnline () Một thay thế để |
void | rebootUntilOnline (String reason) Một thay thế để |
void | rebootUserspace () Chỉ khởi động lại phần không gian người dùng của thiết bị. |
void | rebootUserspaceUntilOnline () Một giải pháp thay thế cho |
boolean | recoverDevice () Nỗ lực khôi phục giao tiếp thiết bị. |
void | registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver) Đăng ký |
void | remountSystemWritable () Làm cho phân vùng hệ thống trên thiết bị có thể ghi được. |
void | remountVendorWritable () Làm cho phân vùng nhà cung cấp trên thiết bị có thể ghi được. |
boolean | removeAdmin (String componentName, int userId) Xóa quản trị viên thiết bị đã cho trong người dùng đã cho và trả về |
void | removeOwners () Xóa tất cả chủ sở hữu cấu hình thiết bị hiện có bằng nỗ lực cao nhất. |
boolean | removeUser (int userId) Xóa một người dùng nhất định khỏi thiết bị. |
void | resetContentProviderSetup () Đặt lại cờ cho thiết lập nhà cung cấp nội dung để kích hoạt lại. |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) Phương pháp thuận tiện để thực hiện |
boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) Chạy thử nghiệm thiết bị và cung cấp khả năng khôi phục thiết bị. |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) Tương tự như |
boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) Tương tự như |
void | setConfiguration ( IConfiguration configuration) Tiêm |
void | setDate (Date date) Đặt ngày trên thiết bị Lưu ý: cài đặt ngày trên thiết bị yêu cầu root |
boolean | setDeviceOwner (String componentName, int userId) Đặt thành phần quản trị viên thiết bị làm chủ sở hữu thiết bị trong người dùng nhất định. |
void | setDeviceState ( TestDeviceState deviceState) Cập nhật trạng thái của thiết bị. |
void | setEmulatorOutputStream ( SizeLimitedOutputStream output) Đối với trình giả lập, hãy đặt |
void | setEmulatorProcess (Process p) Đặt |
void | setFastbootEnabled (boolean fastbootEnabled) Đặt tùy chọn fastboot cho thiết bị. |
void | setFastbootPath (String fastbootPath) Đặt đường dẫn đến tệp nhị phân fastboot sẽ được sử dụng. |
void | setIDevice (IDevice newDevice) Cập nhật IDevice được liên kết với ITestDevice này. |
void | setLogStartDelay (int delay) Đặt thời gian tính bằng ms để đợi trước khi bắt đầu chụp logcat cho thiết bị trực tuyến. |
void | setOptions ( TestDeviceOptions options) Đặt |
boolean | setProperty (String propKey, String propValue) Đặt giá trị thuộc tính đã cho trên thiết bị. |
void | setRecovery ( IDeviceRecovery recovery) Đặt |
void | setRecoveryMode ( ITestDevice.RecoveryMode mode) Đặt chế độ khôi phục hiện tại để sử dụng cho thiết bị. |
void | setSetting (String namespace, String key, String value) Xem |
void | setSetting (int userId, String namespace, String key, String value) Thêm một giá trị cài đặt vào không gian tên của một người dùng nhất định. |
void | setTestLogger ( ITestLogger testLogger) Tiêm phiên bản |
void | setUseFastbootErase (boolean useFastbootErase) Đặt có sử dụng xóa fastboot hoặc định dạng fastboot để xóa phân vùng trên thiết bị hay không. |
void | startLogcat () Bắt đầu chụp đầu ra logcat từ thiết bị ở chế độ nền. |
boolean | startUser (int userId) Bắt đầu một người dùng cụ thể trong nền nếu nó hiện đang bị dừng. |
boolean | startUser (int userId, boolean waitFlag) Bắt đầu một người dùng cụ thể trong nền nếu nó hiện đang bị dừng. |
boolean | startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag) Bắt đầu một người dùng nhất định trong nền, hiển thị trong màn hình nhất định (nghĩa là cho phép người dùng khởi chạy các hoạt động trong màn hình đó). |
void | stopEmulatorOutput () Đóng và xóa đầu ra của trình giả lập. |
void | stopLogcat () Dừng chụp đầu ra logcat từ thiết bị và hủy dữ liệu logcat hiện được lưu. |
boolean | stopUser (int userId) Dừng một người dùng nhất định. |
boolean | stopUser (int userId, boolean waitFlag, boolean forceFlag) Dừng một người dùng nhất định. |
String | switchToAdbTcp () Chuyển thiết bị sang chế độ adb-over-tcp. |
boolean | switchToAdbUsb () Chuyển thiết bị sang chế độ adb qua usb. |
boolean | switchUser (int userId) Chuyển sang userId khác với thời gian chờ mặc định. |
boolean | switchUser (int userId, long timeout) Chuyển sang userId khác với thời gian chờ được cung cấp là hạn chót. |
boolean | syncFiles (File localFileDir, String deviceFilePath) Đồng bộ hóa dần dần nội dung của thư mục tệp cục bộ với thiết bị. |
Bugreport | takeBugreport () Lấy một báo cáo lỗi và gửi nó vào bên trong một đối tượng |
String | uninstallPackage (String packageName) Gỡ cài đặt gói Android khỏi thiết bị. |
String | uninstallPackageForUser (String packageName, int userId) Gỡ cài đặt gói Android khỏi thiết bị cho một người dùng nhất định. |
boolean | unlockDevice () Mở khóa thiết bị nếu thiết bị ở trạng thái được mã hóa. |
boolean | waitForBootComplete (long timeOut) Chặn cho đến khi cờ hoàn tất khởi động của thiết bị được đặt. |
boolean | waitForDeviceAvailable () Đợi thiết bị phản hồi và có sẵn để thử nghiệm. |
boolean | waitForDeviceAvailable (long waitTime) Đợi thiết bị phản hồi và có sẵn để thử nghiệm. |
boolean | waitForDeviceAvailableInRecoverPath (long waitTime) Đợi thiết bị phản hồi và khả dụng mà không xem xét đường dẫn khôi phục. |
void | waitForDeviceBootloader () Chặn cho đến khi thiết bị hiển thị qua fastboot. |
boolean | waitForDeviceInRecovery (long waitTime) Chặn để thiết bị ở trạng thái 'khôi phục adb' (lưu ý rằng điều này khác với |
boolean | waitForDeviceInSideload (long waitTime) Chặn để thiết bị ở trạng thái 'adb sideload' |
boolean | waitForDeviceNotAvailable (long waitTime) Các khối cho thiết bị không khả dụng, tức là bị thiếu trong adb |
void | waitForDeviceOnline () Chặn cho đến khi thiết bị hiển thị qua adb. |
void | waitForDeviceOnline (long waitTime) Chặn cho đến khi thiết bị hiển thị qua adb. |
boolean | waitForDeviceShell (long waitTime) Đợi thiết bị phản hồi lại lệnh trình bao adb cơ bản. |
phương pháp được bảo vệ | |
---|---|
String[] | buildAdbShellCommand (String command, boolean forceExitStatusDetection) Xây dựng lệnh OS cho phiên lệnh adb shell đã cho và lập luận |
void | checkApiLevelAgainst (String feature, int strictMinLevel) |
NativeDevice.RebootDeviceAction | createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason) Tạo một |
IRunUtil | createRunUtil () |
void | doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason) Thực hiện khởi động lại adb. |
void | ensureRuntimePermissionSupported () phương thức trợ giúp để ném ngoại lệ nếu quyền thời gian chạy không được hỗ trợ |
int | getApiLevelSafe () |
ITestLogger | getLogger () |
IRunUtil | getRunUtil () Lấy phiên bản |
void | initializeConnection ( IBuildInfo info, MultiMap <String, String> attributes) |
String | internalGetProperty (String propName, String fastbootVar, String description) Tìm nạp một thuộc tính thiết bị, từ bộ đệm ddmlib theo mặc định và quay trở lại `adb shell getprop` hoặc `fastboot getvar` tùy thuộc vào việc thiết bị có ở trong Fastboot hay không. |
boolean | isInRebootCallback () Trả về việc các cuộc gọi lại khởi động lại hiện đang được thực thi hay không. |
boolean | isNewer (File localFile, IFileEntry entry) Trả về |
void | notifyRebootEnded () Thông báo cho tất cả |
void | notifyRebootStarted () Thông báo cho tất cả |
boolean | performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts) Thực hiện một hành động trên thiết bị này. |
void | postAdbReboot () Các hành động bổ sung có thể được thực hiện sau khi khởi động lại. |
void | prePostBootSetup () Cho phép từng loại thiết bị (AndroidNativeDevice, TestDevice) ghi đè phương pháp này để thiết lập bài đăng cụ thể. |
boolean | pullFileInternal (String remoteFilePath, File localFile) |
void | setClock (Clock clock) Đặt phiên bản Đồng hồ để sử dụng. |
void | setMicrodroidProcess (Process process) Đánh dấu TestDevice là microdroid và đặt CID của nó. |
void | setTestDeviceOptions ( deviceOptions) setTestDeviceOptions ( deviceOptions) |
CommandResult | simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) Thực thi lệnh fastboot đơn giản với các biến môi trường và báo cáo trạng thái của lệnh. |
CommandResult | simpleFastbootCommand (long timeout, String[] fullCmd) Thực thi lệnh fastboot đơn giản và báo cáo trạng thái của lệnh. |
boolean | waitForDeviceNotAvailable (String operationDesc, long time) Đợi để xem thiết bị không khả dụng (ngừng báo cáo với adb). |
hằng số
ID NGƯỜI DÙNG KHÔNG HỢP LỆ
public static final int INVALID_USER_ID
Giá trị được trả về cho bất kỳ id người dùng không hợp lệ/không tìm thấy: UserHandle đã xác định giá trị -10000
Giá trị không đổi: -10000 (0xffffd8f0)
MAX_HOST_DEVICE_TIME_OFFSET
protected static final long MAX_HOST_DEVICE_TIME_OFFSET
Giá trị không đổi: 5000 (0x0000000000001388)
MAX_RETRY_ATTEMPTS
protected static final int MAX_RETRY_ATTEMPTS
số lần thử lại lệnh mặc định để thực hiện
Giá trị không đổi: 2 (0x00000002)
Lĩnh vực
THẺ SD
protected static final String SD_CARD
STORAGE_EMULATED
protected static final String STORAGE_EMULATED
mOptions
protected TestDeviceOptions mOptions
nhà thầu công cộng
Thiết bị gốc
public NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
Tạo một TestDevice
.
Thông số | |
---|---|
device | IDevice : IDevice được liên kết |
stateMonitor | IDeviceStateMonitor : cơ chế IDeviceStateMonitor để sử dụng |
allocationMonitor | IDeviceMonitor : IDeviceMonitor để thông báo về các thay đổi trạng thái phân bổ. có thể là null |
Phương thức công khai
canSwitchToHeadlessSystemUser
public boolean canSwitchToHeadlessSystemUser ()
Trả về liệu nó có được phép chuyển sang người dùng HỆ THỐNG không đầu hay không.
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
checkApiLevelAgainstNextRelease
public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
Kiểm tra xem một tính năng hiện có được hỗ trợ hay không ở mức được hỗ trợ tối thiểu. Phương pháp này tính đến các tính năng chưa được phát hành trước khi cấp độ API được nâng lên.
Thông số | |
---|---|
strictMinLevel | int : Mức tối thiểu nghiêm ngặt có thể hỗ trợ tính năng này. |
trả lại | |
---|---|
boolean | Đúng nếu mức được hỗ trợ. Sai nếu không. |
ném | |
---|---|
DeviceNotAvailableException |
kiểm tra kết nối
public boolean checkConnectivity ()
Kiểm tra xem thiết bị có kết nối mạng không.
trả lại | |
---|---|
boolean | true nếu thiết bị có kết nối mạng đang hoạt động, ngược lại false . |
ném | |
---|---|
DeviceNotAvailableException |
ClearErrorDialogs
public boolean clearErrorDialogs ()
Cố gắng loại bỏ mọi hộp thoại báo lỗi hiện đang hiển thị trên giao diện người dùng của thiết bị.
trả lại | |
---|---|
boolean | true nếu không có hộp thoại nào hoặc hộp thoại đã bị xóa thành công. false khác. |
ném | |
---|---|
DeviceNotAvailableException |
ClearLastConnectedWifiNetwork
public void clearLastConnectedWifiNetwork ()
Xóa mạng wifi được kết nối lần cuối. Điều này nên được gọi khi bắt đầu một lệnh gọi mới để tránh kết nối với mạng wifi được sử dụng trong thử nghiệm trước đó sau khi khởi động lại thiết bị.
rõ ràngLogcat
public void clearLogcat ()
Xóa mọi dữ liệu logcat tích lũy.
Điều này hữu ích cho các trường hợp khi bạn muốn đảm bảoITestDevice#getLogcat()
chỉ trả về dữ liệu nhật ký được tạo sau một thời điểm nhất định (chẳng hạn như sau khi cài đặt bản dựng thiết bị mới, v.v.). kết nối vớiMạngWifi
public boolean connectToWifiNetwork (wifiSsidToPsk, boolean scanSsid)
Kết nối với một mạng wifi.
Bật wifi và chặn cho đến khi kết nối thành công với một trong các mạng wifi được cung cấp trong bản đồ wifiSsidToPsk. Sau khi kết nối được tạo, phiên bản sẽ cố gắng khôi phục kết nối sau mỗi lần khởi động lại cho đến khi ITestDevice#disconnectFromWifi()
hoặc ITestDevice#clearLastConnectedWifiNetwork()
được gọi.
Thông số | |
---|---|
wifiSsidToPsk | |
scanSsid | boolean : có quét SSID ẩn cho mạng này hay không. |
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
kết nối vớiMạngWifi
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)
Kết nối với một mạng wifi.
Bật wifi và chặn cho đến khi kết nối thành công với mạng wifi được chỉ định. Sau khi kết nối được tạo, phiên bản sẽ cố gắng khôi phục kết nối sau mỗi lần khởi động lại cho đến khiITestDevice#disconnectFromWifi()
hoặc ITestDevice#clearLastConnectedWifiNetwork()
được gọi.Thông số | |
---|---|
wifiSsid | String : wifi ssid để kết nối với |
wifiPsk | String : cụm mật khẩu PSK hoặc null nếu không được mã hóa |
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
kết nối vớiMạngWifi
public boolean connectToWifiNetwork (wifiSsidToPsk)
Kết nối với một mạng wifi.
Bật wifi và chặn cho đến khi kết nối thành công với một trong các mạng wifi được cung cấp trong bản đồ wifiSsidToPsk. Sau khi kết nối được tạo, phiên bản sẽ cố gắng khôi phục kết nối sau mỗi lần khởi động lại cho đến khi ITestDevice#disconnectFromWifi()
hoặc ITestDevice#clearLastConnectedWifiNetwork()
được gọi.f
Thông số | |
---|---|
wifiSsidToPsk |
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
kết nối vớiMạngWifi
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)
Kết nối với một mạng wifi.
Bật wifi và chặn cho đến khi kết nối thành công với mạng wifi được chỉ định. Sau khi kết nối được tạo, phiên bản sẽ cố gắng khôi phục kết nối sau mỗi lần khởi động lại cho đến khiITestDevice#disconnectFromWifi()
hoặc ITestDevice#clearLastConnectedWifiNetwork()
được gọi.Thông số | |
---|---|
wifiSsid | String : wifi ssid để kết nối với |
wifiPsk | String : cụm mật khẩu PSK hoặc null nếu không được mã hóa |
scanSsid | boolean : có quét SSID ẩn cho mạng này hay không. |
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)
Một biến thể của connectToWifiNetwork(String, String)
chỉ kết nối nếu thiết bị hiện không có kết nối mạng.
Thông số | |
---|---|
scanSsid | boolean : có quét SSID ẩn cho mạng này không |
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)
Một biến thể của connectToWifiNetwork(String, String)
chỉ kết nối nếu thiết bị hiện không có kết nối mạng.
trả lại | |
---|---|
boolean | true nếu kết nối với mạng wifi thành công. sai nếu false |
ném | |
---|---|
DeviceNotAvailableException |
tạo người dùng
public int createUser (String name, boolean guest, boolean ephemeral)
Tạo người dùng có tên đã cho và các cờ được cung cấp
Thông số | |
---|---|
name | String : của người dùng tạo trên thiết bị |
guest | boolean : bật cờ người dùng --guest trong quá trình tạo |
ephemeral | boolean : bật cờ người dùng --ephemeral trong quá trình tạo |
trả lại | |
---|---|
int | id của người dùng đã tạo |
ném | |
---|---|
DeviceNotAvailableException |
tạo người dùng
public int createUser (String name, boolean guest, boolean ephemeral, boolean forTesting)
Tạo người dùng có tên đã cho và các cờ được cung cấp
Thông số | |
---|---|
name | String : của người dùng tạo trên thiết bị |
guest | boolean : bật cờ người dùng --guest trong quá trình tạo |
ephemeral | boolean : bật cờ người dùng --ephemeral trong quá trình tạo |
forTesting | boolean : bật cờ kiểm tra --for-testing trong quá trình tạo |
trả lại | |
---|---|
int | id của người dùng đã tạo |
ném | |
---|---|
DeviceNotAvailableException |
tạo người dùng
public int createUser (String name)
Tạo người dùng có tên đã cho và cờ mặc định 0.
Thông số | |
---|---|
name | String : của người dùng tạo trên thiết bị |
trả lại | |
---|---|
int | số nguyên cho id người dùng đã tạo |
ném | |
---|---|
DeviceNotAvailableException |
tạoUserNoThrow
public int createUserNoThrow (String name)
Tạo người dùng có tên đã cho và cờ mặc định 0.
Thông số | |
---|---|
name | String : của người dùng tạo trên thiết bị |
trả lại | |
---|---|
int | số nguyên cho id người dùng đã tạo hoặc -1 nếu có lỗi. |
ném | |
---|---|
DeviceNotAvailableException |
xóa tài liệu
public void deleteFile (String deviceFilePath)
Phương thức trợ giúp để xóa tệp hoặc thư mục trên thiết bị.
Thông số | |
---|---|
deviceFilePath | String : Đường dẫn tuyệt đối của tệp trên thiết bị. |
ném | |
---|---|
DeviceNotAvailableException |
hủy đăng kýDeviceActionReceiver
public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)
Xóa IDeviceActionReceiver
đã đăng ký.
Thông số | |
---|---|
deviceActionReceiver | IDeviceActionReceiver : IDeviceActionReceiver sẽ bị xóa. |
deviceSoftKhởi động lại
public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
Phương pháp trợ giúp để kiểm tra xem thiết bị có khởi động lại mềm hay không bằng cách so sánh system_server hiện tại với system_server ProcessInfo
trước đó. Sử dụng getProcessByName(String)
để nhận ProcessInfo
.
Thông số | |
---|---|
prevSystemServerProcess | ProcessInfo : quy trình system_server trước đó ProcessInfo . |
trả lại | |
---|---|
boolean | true nếu thiết bị khởi động lại mềm |
ném | |
---|---|
DeviceNotAvailableException |
deviceSoftRestartedKể từ khi
public boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
Phương pháp trợ giúp để kiểm tra xem thiết bị có khởi động lại mềm kể từ thời gian UTC kể từ Epoch từ thiết bị và ERROR(/TimeUnit)
của thiết bị hay không. Khởi động lại mềm đề cập đến system_server được khởi động lại bên ngoài khởi động lại cứng thiết bị (ví dụ: khởi động lại được yêu cầu). Thiết bị hiện tại utcEpochTime tính bằng Millisecond có thể được lấy bằng phương thức getDeviceDate()
.
Thông số | |
---|---|
utcEpochTime | long : thời gian thiết bị tính bằng giây kể từ epoch. |
timeUnit | TimeUnit : đơn vị thời gian TimeUnit cho utcEpochTime đã cho. |
trả lại | |
---|---|
boolean | true nếu thiết bị khởi động lại mềm |
ném | |
---|---|
DeviceNotAvailableException |
vô hiệu hóaAdbRoot
public boolean disableAdbRoot ()
Tắt adb root.
Vô hiệu hóa adb root có thể khiến thiết bị ngắt kết nối khỏi adb. Phương pháp này sẽ chặn cho đến khi có thiết bị.trả lại | |
---|---|
boolean | true nếu thành công. |
ném | |
---|---|
DeviceNotAvailableException |
vô hiệu hóaKeyguard
public void disableKeyguard ()
Cố gắng vô hiệu hóa keyguard.
Trước tiên, hãy đợi công văn đầu vào sẵn sàng, điều này xảy ra cùng thời điểm khi thiết bị báo cáo BOOT_COMPLETE, rõ ràng là không đồng bộ, vì việc triển khai khung hiện tại thỉnh thoảng có tình trạng tương tranh. Sau đó, lệnh được gửi để loại bỏ keyguard (chỉ hoạt động trên những cái không an toàn)
ném | |
---|---|
DeviceNotAvailableException |
vô hiệu hóaNetworkMonitor
public boolean disableNetworkMonitor ()
Vô hiệu hóa giám sát mạng trên thiết bị.
trả lại | |
---|---|
boolean | true nếu giám sát bị vô hiệu hóa thành công. false nếu nó không thành công. |
ném | |
---|---|
DeviceNotAvailableException |
ngắt kết nốiWifi
public boolean disconnectFromWifi ()
Ngắt kết nối khỏi mạng wifi.
Xóa tất cả các mạng khỏi danh sách mạng đã biết và tắt wifi.trả lại | |
---|---|
boolean | true nếu ngắt kết nối mạng wifi thành công. false nếu ngắt kết nối không thành công. |
ném | |
---|---|
DeviceNotAvailableException |
doesFileExist
public boolean doesFileExist (String deviceFilePath, int userId)
Phương thức trợ giúp để xác định xem tệp trên thiết bị có tồn tại cho một người dùng cụ thể hay không.
Thông số | |
---|---|
deviceFilePath | String : đường dẫn tuyệt đối của tệp trên thiết bị để kiểm tra |
userId | int : ID người dùng để kiểm tra sự tồn tại của tệp |
trả lại | |
---|---|
boolean | true nếu tệp tồn tại, false nếu không. |
ném | |
---|---|
DeviceNotAvailableException |
doesFileExist
public boolean doesFileExist (String deviceFilePath)
Phương pháp trợ giúp để xác định xem tệp trên thiết bị có tồn tại hay không.
Thông số | |
---|---|
deviceFilePath | String : đường dẫn tuyệt đối của tệp trên thiết bị để kiểm tra |
trả lại | |
---|---|
boolean | true nếu tệp tồn tại, false nếu không. |
ném | |
---|---|
DeviceNotAvailableException |
đổ đống
public File dumpHeap (String process, String devicePath)
Cố gắng kết xuất đống từ system_server. Người gọi có trách nhiệm dọn sạch tệp bị đổ.
Thông số | |
---|---|
process | String : tên của quá trình thiết bị để dumpheap trên. |
devicePath | String : đường dẫn trên thiết bị nơi đặt kết xuất. Đây phải là một vị trí mà quyền cho phép nó. |
trả lại | |
---|---|
File | ERROR(/File) chứa báo cáo. Null nếu một cái gì đó thất bại. |
ném | |
---|---|
DeviceNotAvailableException |
enableAdbRoot
public boolean enableAdbRoot ()
Bật adb root. Nếu cài đặt "enable-root" là "false", sẽ ghi lại một thông báo và quay lại mà không bật root.
Bật adb root có thể khiến thiết bị ngắt kết nối khỏi adb. Phương pháp này sẽ chặn cho đến khi có thiết bị.trả lại | |
---|---|
boolean | true nếu thành công. |
ném | |
---|---|
DeviceNotAvailableException |
enableNetworkMonitor
public boolean enableNetworkMonitor ()
Cho phép giám sát mạng trên thiết bị.
trả lại | |
---|---|
boolean | true nếu giám sát được kích hoạt thành công. false nếu nó không thành công. |
ném | |
---|---|
DeviceNotAvailableException |
thực thiAdbCommand
public String executeAdbCommand (long timeout, String... cmdArgs)
Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống với thời gian chờ được chỉ định.
executeShellCommand(String)
nên được sử dụng thay thế bất cứ khi nào có thể, vì phương pháp đó mang lại hiệu suất và khả năng phát hiện lỗi tốt hơn.
Thông số | |
---|---|
timeout | long : thời gian tính bằng mili giây trước khi thiết bị được coi là không phản hồi, 0L không có thời gian chờ |
cmdArgs | String : lệnh adb và các đối số để chạy |
trả lại | |
---|---|
String | thiết bị xuất chuẩn từ lệnh. null nếu lệnh không thực thi được. |
ném | |
---|---|
DeviceNotAvailableException |
thực thiAdbCommand
public String executeAdbCommand (long timeout,envMap, String... cmdArgs)
Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống với thời gian chờ được chỉ định.
executeShellCommand(String)
nên được sử dụng thay thế bất cứ khi nào có thể, vì phương pháp đó mang lại hiệu suất và khả năng phát hiện lỗi tốt hơn.
Thông số | |
---|---|
timeout | long : thời gian tính bằng mili giây trước khi thiết bị được coi là không phản hồi, 0L không có thời gian chờ |
envMap | |
cmdArgs | String : lệnh adb và các đối số để chạy |
trả lại | |
---|---|
String | thiết bị xuất chuẩn từ lệnh. null nếu lệnh không thực thi được. |
ném | |
---|---|
DeviceNotAvailableException |
thực thiAdbCommand
public String executeAdbCommand (String... cmdArgs)
Phương thức trợ giúp thực thi lệnh adb dưới dạng lệnh hệ thống.
executeShellCommand(String)
nên được sử dụng thay thế bất cứ khi nào có thể, vì phương pháp đó mang lại hiệu suất và khả năng phát hiện lỗi tốt hơn.Thông số | |
---|---|
cmdArgs | String : lệnh adb và các đối số để chạy |
trả lại | |
---|---|
String | thiết bị xuất chuẩn từ lệnh. null nếu lệnh không thực thi được. |
ném | |
---|---|
DeviceNotAvailableException |
thực thiFastbootCommand
public CommandResult executeFastbootCommand (String... cmdArgs)
Phương thức trợ giúp thực thi lệnh fastboot dưới dạng lệnh hệ thống với thời gian chờ mặc định là 2 phút.
Dự kiến sẽ được sử dụng khi thiết bị đã ở chế độ fastboot.
Thông số | |
---|---|
cmdArgs | String : lệnh fastboot và các đối số để chạy |
trả lại | |
---|---|
CommandResult | CommandResult chứa đầu ra của lệnh |
ném | |
---|---|
DeviceNotAvailableException |
thực thiFastbootCommand
public CommandResult executeFastbootCommand (long timeout, String... cmdArgs)
Phương thức trợ giúp thực thi lệnh fastboot dưới dạng lệnh hệ thống.
Dự kiến sẽ được sử dụng khi thiết bị đã ở chế độ fastboot.Thông số | |
---|---|
timeout | long : thời gian tính bằng mili giây trước khi lệnh hết hạn |
cmdArgs | String : lệnh fastboot và các đối số để chạy |
trả lại | |
---|---|
CommandResult | CommandResult chứa đầu ra của lệnh |
ném | |
---|---|
DeviceNotAvailableException |
execLongFastbootCommand
public CommandResult executeLongFastbootCommand (String... cmdArgs)
Phương thức trợ giúp thực thi lệnh fastboot chạy dài dưới dạng lệnh hệ thống.
Giống hệt vớiexecuteFastbootCommand(String)
ngoại trừ sử dụng thời gian chờ lâu hơn.Thông số | |
---|---|
cmdArgs | String : lệnh fastboot và các đối số để chạy |
trả lại | |
---|---|
CommandResult | CommandResult chứa đầu ra của lệnh |
ném | |
---|---|
DeviceNotAvailableException |
execLongFastbootCommand
public CommandResult executeLongFastbootCommand (envVarMap, String... cmdArgs)
Phương thức trợ giúp thực thi lệnh fastboot chạy dài dưới dạng lệnh hệ thống với các biến môi trường hệ thống.
Giống hệt với executeFastbootCommand(String)
ngoại trừ sử dụng thời gian chờ lâu hơn.
Thông số | |
---|---|
envVarMap | |
cmdArgs | String : lệnh fastboot và các đối số để chạy |
trả lại | |
---|---|
CommandResult | CommandResult chứa đầu ra của lệnh |
ném | |
---|---|
DeviceNotAvailableException |
thực thiShellCommand
public String executeShellCommand (String command)
Phương thức trợ giúp thực thi lệnh shell adb và trả về đầu ra dưới dạng ERROR(/String)
.
Thông số | |
---|---|
command | String : lệnh shell adb để chạy |
trả lại | |
---|---|
String | đầu ra vỏ |
ném | |
---|---|
DeviceNotAvailableException |
thực thiShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh.
Thông số | |
---|---|
command | String : lệnh shell adb để chạy |
receiver | IShellOutputReceiver : IShellOutputReceiver để hướng đầu ra shell tới. |
maxTimeToOutputShellResponse | long : lượng thời gian tối đa mà lệnh được phép không đưa ra bất kỳ phản hồi nào; đơn vị như được chỉ định trong timeUnit |
timeUnit | TimeUnit : đơn vị cho maxTimeToOutputShellResponse |
retryAttempts | int : số lần tối đa để thử lại lệnh nếu nó không thành công do một ngoại lệ. DeviceNotResponsiveException sẽ bị ném nếu retryAttempts được thực hiện không thành công. |
ném | |
---|---|
DeviceNotAvailableException |
thực thiShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
Thực thi lệnh adb shell, với nhiều tham số hơn để kiểm soát hành vi của lệnh.
Thông số | |
---|---|
command | String : lệnh shell adb để chạy |
receiver | IShellOutputReceiver : IShellOutputReceiver để hướng đầu ra shell tới. |
maxTimeoutForCommand | long : thời gian chờ tối đa để lệnh hoàn thành; đơn vị như được chỉ định trong timeUnit |
maxTimeToOutputShellResponse | long : khoảng thời gian tối đa mà lệnh được phép không đưa ra bất kỳ phản hồi nào; đơn vị như được chỉ định trong 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. |
ném | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver)
Executes the given adb shell command, retrying multiple times if command fails.
A simpler form ofexecuteShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
with default values.Thông số | |
---|---|
command | String : the adb shell command to run |
receiver | IShellOutputReceiver : the IShellOutputReceiver to direct shell output to. |
ném | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd)
Helper method which executes a adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Thông số | |
---|---|
cmd | String : The command that should be run. |
trả lại | |
---|---|
CommandResult | The result in CommandResult . |
ném | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output and stderr. stdout is directed to the specified stream.
Thông số | |
---|---|
cmd | String : The command that should be run. |
pipeToOutput | OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null. |
trả lại | |
---|---|
CommandResult | The result in CommandResult . |
ném | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput)
Helper method which executes an adb shell command and returns the results as a CommandResult
properly populated with the command status output, stdout and stderr.
Thông số | |
---|---|
cmd | String : The command that should be run. |
pipeAsInput | File : A ERROR(/File) that will be piped as input to the command, or null. |
trả lại | |
---|---|
CommandResult | The result in CommandResult . |
ném | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
Executes a adb shell command, with more parameters to control command behavior.
Thông số | |
---|---|
cmd | String : the adb shell command to run |
maxTimeoutForCommand | long : the maximum timeout for the command to complete; unit as specified in timeUnit |
timeUnit | TimeUnit : unit for maxTimeToOutputShellResponse |
retryAttempts | int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success. |
trả lại | |
---|---|
CommandResult |
ném | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)
Executes a adb shell command, with more parameters to control command behavior.
Thông số | |
---|---|
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 |
trả lại | |
---|---|
CommandResult |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
CommandResult |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
CommandResult |
ném | |
---|---|
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.Thông số | |
---|---|
partition | String : the partition to wipe |
trả lại | |
---|---|
CommandResult | the CommandResult containing output of command |
ném | |
---|---|
DeviceNotAvailableException |
getActiveApexes
publicgetActiveApexes ()
Fetch the information about APEXes activated on the device.
trả lại | |
---|---|
ERROR(/Set) of ApexInfo currently activated on the device |
ném | |
---|---|
DeviceNotAvailableException |
getAllSettings
publicgetAllSettings (String namespace)
Return key value pairs of requested namespace.
Thông số | |
---|---|
namespace | String : must be one of {"system", "secure", "global"} |
trả lại | |
---|---|
the map of key value pairs. Null if namespace is not supported. |
ném | |
---|---|
DeviceNotAvailableException |
getAllocationState
public DeviceAllocationState getAllocationState ()
Return the current allocation state of device
trả lại | |
---|---|
DeviceAllocationState |
getAndroidId
public String getAndroidId (int userId)
Find and return the android-id associated to a userId, null if not found.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
String |
ném | |
---|---|
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.
trả lại | |
---|---|
Map of android ids found matching user ids. |
ném | |
---|---|
DeviceNotAvailableException |
getApiLevel
public int getApiLevel ()
Get the device API Level. Defaults to UNKNOWN_API_LEVEL
.
trả lại | |
---|---|
int | an integer indicating the API Level of device |
ném | |
---|---|
DeviceNotAvailableException |
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Fetch information about a package installed on device.
Thông số | |
---|---|
packageName | String |
trả lại | |
---|---|
PackageInfo | the PackageInfo or null if information could not be retrieved |
ném | |
---|---|
DeviceNotAvailableException |
getAppPackageInfos
publicgetAppPackageInfos ()
Fetch information of packages installed on the device.
trả lại | |
---|---|
ERROR(/List) of PackageInfo s installed on the device. |
ném | |
---|---|
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
.
trả lại | |
---|---|
String | the ERROR(/String) baseband version or null if it cannot be determined (device has no radio or version string cannot be read) |
ném | |
---|---|
DeviceNotAvailableException |
getBattery
public Integer getBattery ()
Returns the current battery level of a device or Null if battery level unavailable.
trả lại | |
---|---|
Integer |
getBooleanProperty
public boolean getBooleanProperty (String name, boolean defaultValue)
Returns boolean value of the given property.
Thông số | |
---|---|
name | String : the property name |
defaultValue | boolean : default value to return if property is empty or doesn't exist. |
trả lại | |
---|---|
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. |
ném | |
---|---|
DeviceNotAvailableException |
getBootHistory
publicgetBootHistory ()
Helper method collects the boot history map with boot time and boot reason.
trả lại | |
---|---|
Map of boot time (UTC time in second since Epoch) and boot reason |
ném | |
---|---|
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()
.
Thông số | |
---|---|
utcEpochTime | long : the device time since Epoch. |
timeUnit | TimeUnit : the time unit TimeUnit . |
trả lại | |
---|---|
Map of boot time (UTC time in second since Epoch) and boot reason |
ném | |
---|---|
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)trả lại | |
---|---|
String | the ERROR(/String) bootloader version or null if it cannot be found |
ném | |
---|---|
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).
trả lại | |
---|---|
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
trả lại | |
---|---|
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
trả lại | |
---|---|
String | the build alias or fall back to build id if it could not be retrieved |
ném | |
---|---|
DeviceNotAvailableException |
getBuildFlavor
public String getBuildFlavor ()
Retrieve the build flavor for the device.
trả lại | |
---|---|
String | the build flavor or null if it could not be retrieved |
ném | |
---|---|
DeviceNotAvailableException |
getBuildId
public String getBuildId ()
Retrieve the build the device is currently running.
trả lại | |
---|---|
String | the build id or IBuildInfo#UNKNOWN_BUILD_ID if it could not be retrieved |
ném | |
---|---|
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)
trả lại | |
---|---|
String | The signing key if found, null otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
getCachedDeviceDescriptor
public DeviceDescriptor getCachedDeviceDescriptor ()
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the current DeviceDescriptor
.
trả lại | |
---|---|
DeviceDescriptor |
getCachedDeviceDescriptor
public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)
Returns a cached DeviceDescriptor
if the device is allocated, otherwise returns the current DeviceDescriptor
.
Thông số | |
---|---|
shortDescriptor | boolean : Whether or not to limit descriptor to bare minimum info |
trả lại | |
---|---|
DeviceDescriptor |
getChildren
public String[] getChildren (String path)
Alternative to using IFileEntry
that sometimes won't work because of permissions.
Thông số | |
---|---|
path | String : is the path on the device where to do the search |
trả lại | |
---|---|
String[] | Array of string containing all the file in a path on the device. |
ném | |
---|---|
DeviceNotAvailableException |
getConnection
public AbstractConnection getConnection ()
The current connection associated with the device.
trả lại | |
---|---|
AbstractConnection |
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Returns the current foldable state of the device or null if some issues occurred.
trả lại | |
---|---|
DeviceFoldableState |
ném | |
---|---|
DeviceNotAvailableException |
getCurrentUser
public int getCurrentUser ()
Return the id of the current running user. In case of error, return -10000.
trả lại | |
---|---|
int |
ném | |
---|---|
DeviceNotAvailableException |
getDeviceClass
public String getDeviceClass ()
Get the device class.
trả lại | |
---|---|
String | the ERROR(/String) device class. |
getDeviceDate
public long getDeviceDate ()
Return the date of the device in millisecond since epoch.
trả lại | |
---|---|
long | the date of the device in epoch format. |
ném | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor ()
Trả về một DeviceDescriptor
từ thông tin thiết bị để nhận thông tin về thiết bị mà không chuyển đối tượng thiết bị thực tế.
trả lại | |
---|---|
DeviceDescriptor |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
Trả về một DeviceDescriptor
từ thông tin thiết bị để nhận thông tin về thiết bị mà không chuyển đối tượng thiết bị thực tế.
Thông số | |
---|---|
shortDescriptor | boolean : Whether or not to limit descriptor to bare minimum info |
trả lại | |
---|---|
DeviceDescriptor |
getDeviceState
public TestDeviceState getDeviceState ()
Get the device's state.
trả lại | |
---|---|
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.
Thông số | |
---|---|
date | Date |
trả lại | |
---|---|
long | the difference in milliseconds |
ném | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public InputStreamSource getEmulatorOutput ()
Get the stream of emulator stdout and stderr
trả lại | |
---|---|
InputStreamSource | emulator output |
getEmulatorProcess
public Process getEmulatorProcess ()
Return the ERROR(/Process)
corresponding to this emulator.
trả lại | |
---|---|
Process | the ERROR(/Process) or null |
getExecuteShellCommandLog
public final File getExecuteShellCommandLog ()
The log that contains all the executeShellCommand(String)
logs.
trả lại | |
---|---|
File |
getExternalStoreFreeSpace
public long getExternalStoreFreeSpace ()
Helper method to determine amount of free space on device external storage.
trả lại | |
---|---|
long | the amount of free space in KB |
ném | |
---|---|
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.
trả lại | |
---|---|
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.trả lại | |
---|---|
String | the ERROR(/String) product type name or null if it cannot be determined |
ném | |
---|---|
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.trả lại | |
---|---|
String | the ERROR(/String) product type name or null if it cannot be determined |
ném | |
---|---|
DeviceNotAvailableException |
getFastbootSerialNumber
public String getFastbootSerialNumber ()
Returns the fastboot mode serial number.
trả lại | |
---|---|
String |
getFastbootVariable
public String getFastbootVariable (String variableName)
Retrieve the given fastboot variable value from the device.
Thông số | |
---|---|
variableName | String : the variable name |
trả lại | |
---|---|
String | the property value or null if it does not exist |
ném | |
---|---|
DeviceNotAvailableException |
getFastbootVersion
public String getFastbootVersion ()
Returns the version string of the fastboot binary being used. Or null if something goes wrong.
trả lại | |
---|---|
String |
getFileEntry
public IFileEntry getFileEntry (String path)
Retrieve a reference to a remote file on device.
Thông số | |
---|---|
path | String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie both "/system" and "system" syntax is supported) |
trả lại | |
---|---|
IFileEntry | the IFileEntry or null if file at given path cannot be found |
ném | |
---|---|
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).
Thông số | |
---|---|
entry | FileListingService.FileEntry : a FileEntry not necessarily root as Ddmlib requires. |
trả lại | |
---|---|
IFileEntry | a FileEntryWrapper representing the FileEntry. |
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getFoldableStates
publicgetFoldableStates ()
Returns the list of foldable states on the device. Can be obtained with "cmd device_state print-states".
trả lại | |
---|---|
ném | |
---|---|
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.trả lại | |
---|---|
IDevice | the IDevice |
getInstalledPackageNames
publicgetInstalledPackageNames ()
Fetch the application package names present on the device.
trả lại | |
---|---|
ERROR(/Set) of ERROR(/String) package names currently installed on the device. |
ném | |
---|---|
DeviceNotAvailableException |
getIntProperty
public long getIntProperty (String name, long defaultValue)
Returns integer value of the given property from the device.
Thông số | |
---|---|
name | String : the property name |
defaultValue | long : default value to return if property is empty or doesn't exist. |
trả lại | |
---|---|
long | the property value or defaultValue if the property is empty, doesn't exist, or doesn't have an integer value. |
ném | |
---|---|
DeviceNotAvailableException |
getIpAddress
public String getIpAddress ()
Gets the device's IP address.
trả lại | |
---|---|
String | the device's IP address, or null if device has no IP address |
ném | |
---|---|
DeviceNotAvailableException |
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Return an object to get the current state of the keyguard or null if not supported.
trả lại | |
---|---|
KeyguardControllerState | a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported. |
ném | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public long getLastExpectedRebootTimeMillis ()
Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by ERROR(/System#currentTimeMillis())
.
trả lại | |
---|---|
long |
getLaunchApiLevel
public int getLaunchApiLevel ()
Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL
.
trả lại | |
---|---|
int | an integer indicating the first launched API Level of device |
ném | |
---|---|
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 capturetrả lại | |
---|---|
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.
Thông số | |
---|---|
maxBytes | int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory |
trả lại | |
---|---|
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.
trả lại | |
---|---|
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()
.
Thông số | |
---|---|
date | long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s') |
trả lại | |
---|---|
InputStreamSource |
getMacAddress
public String getMacAddress ()
Returns the MAC address of the device, null if it fails to query from the device.
trả lại | |
---|---|
String |
getMainUserId
public Integer getMainUserId ()
Returns the main user id.
trả lại | |
---|---|
Integer | the userId of the main user if there is one, and null if there is no main user. |
ném | |
---|---|
DeviceNotAvailableException |
getMainlineModuleInfo
publicgetMainlineModuleInfo ()
Get the information about the mainline modules installed on the device.
trả lại | |
---|---|
ERROR(/Set) of ERROR(/String) mainline modules currently installed on the device. |
ném | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfRunningUsersSupported
public int getMaxNumberOfRunningUsersSupported ()
Get the maximum number of supported simultaneously running users. Defaults to 0.
trả lại | |
---|---|
int | an integer indicating the number of simultaneously running users |
ném | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
Get the maximum number of supported users. Defaults to 0.
trả lại | |
---|---|
int | an integer indicating the number of supported users |
ném | |
---|---|
DeviceNotAvailableException |
getMicrodroidProcess
public Process getMicrodroidProcess ()
trả lại | |
---|---|
Process | Returns the Process of the Microdroid VM. If TestDevice is not a Microdroid, returns null. |
getMonitor
public IDeviceStateMonitor getMonitor ()
Return the IDeviceStateMonitor
associated with device.
trả lại | |
---|---|
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)
Thông số | |
---|---|
mountName | String : the name of the mount point |
trả lại | |
---|---|
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.
Thông số | |
---|---|
mountpoint | String |
trả lại | |
---|---|
ITestDevice.MountPointInfo | A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
ném | |
---|---|
DeviceNotAvailableException |
getMountPointInfo
publicgetMountPointInfo ()
Returns a parsed version of the information in /proc/mounts on the device
trả lại | |
---|---|
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
ném | |
---|---|
DeviceNotAvailableException |
getOptions
public TestDeviceOptions getOptions ()
Fetch the test options for the device.
trả lại | |
---|---|
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.
Thông số | |
---|---|
partition | String |
trả lại | |
---|---|
long | the amount of free space in KB |
ném | |
---|---|
DeviceNotAvailableException |
getPrimaryUserId
public Integer getPrimaryUserId ()
Returns the primary user id.
trả lại | |
---|---|
Integer | the userId of the primary user if there is one, and null if there is no primary user. |
ném | |
---|---|
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.
Thông số | |
---|---|
processName | String : the proces name String. |
trả lại | |
---|---|
ProcessInfo | ProcessInfo of given processName |
ném | |
---|---|
DeviceNotAvailableException |
getProcessPid
public String getProcessPid (String process)
Returns the pid of the service or null if something went wrong.
Thông số | |
---|---|
process | String : The proces name String. |
trả lại | |
---|---|
String |
ném | |
---|---|
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.trả lại | |
---|---|
String | the ERROR(/String) product type name. Will not be null |
ném | |
---|---|
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.trả lại | |
---|---|
String | the ERROR(/String) product variant name or null if it cannot be determined |
ném | |
---|---|
DeviceNotAvailableException |
getProperty
public String getProperty (String name)
Retrieve the given property value from the device.
Thông số | |
---|---|
name | String : the property name |
trả lại | |
---|---|
String | the property value or null if it does not exist |
ném | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public ITestDevice.RecoveryMode getRecoveryMode ()
Get the current recovery mode used for the device.
trả lại | |
---|---|
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
Thông số | |
---|---|
format | String : supported PNG, JPEG |
trả lại | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
ném | |
---|---|
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'
Thông số | |
---|---|
displayId | long : the display id of the screen to get screenshot from. |
trả lại | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
ném | |
---|---|
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.
Thông số | |
---|---|
format | String : supported PNG, JPEG |
rescale | boolean : if screenshot should be rescaled to reduce the size of resulting image |
trả lại | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in format, or null if the screenshot was not successful. |
ném | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot ()
Grabs a screenshot from the device.
trả lại | |
---|---|
InputStreamSource | a InputStreamSource of the screenshot in png format, or null if the screenshot was not successful. |
ném | |
---|---|
DeviceNotAvailableException |
getSerialNumber
public String getSerialNumber ()
Convenience method to get serial number of this device.
trả lại | |
---|---|
String | the ERROR(/String) serial number |
getSetting
public String getSetting (int userId, String namespace, String key)
Return the value of the requested setting. namespace must be one of: {"system", "secure", "global"}
Thông số | |
---|---|
userId | int |
namespace | String |
key | String |
trả lại | |
---|---|
String | the value associated with the namespace:key of a user. Null if not found. |
ném | |
---|---|
DeviceNotAvailableException |
getSetting
public String getSetting (String namespace, String key)
See getSetting(int, String, String)
and performed on system user.
Thông số | |
---|---|
namespace | String |
key | String |
trả lại | |
---|---|
String |
ném | |
---|---|
DeviceNotAvailableException |
getSimOperator
public String getSimOperator ()
Return the SIM card operator or null if not available or if device is not available.
trả lại | |
---|---|
String |
getSimState
public String getSimState ()
Return the SIM card state or null if not available or device is not available.
trả lại | |
---|---|
String |
lấy bia mộ
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.
trả lại | |
---|---|
Một danh sách các tập tin bia mộ, trống nếu không có bia mộ. |
ném | |
---|---|
DeviceNotAvailableException |
getTotalMemory
public long getTotalMemory ()
Returns total physical memory size in bytes or -1 in case of internal error
trả lại | |
---|---|
long |
getUninstallablePackageNames
publicgetUninstallablePackageNames ()
Fetch the application package names that can be uninstalled. This is presently defined as non-system packages, and updated system packages.
trả lại | |
---|---|
ERROR(/Set) of uninstallable ERROR(/String) package names currently installed on the device. |
ném | |
---|---|
DeviceNotAvailableException |
getUseFastbootErase
public boolean getUseFastbootErase ()
Get whether to use fastboot erase or fastboot format to wipe a partition on the device.
trả lại | |
---|---|
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.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
int | the flags associated with the userId provided if found, -10000 in any other cases. |
ném | |
---|---|
DeviceNotAvailableException |
getUserInfos
publicgetUserInfos ()
Gets the Map of useId to UserInfo
on the device. Will throw DeviceRuntimeException
if output from device is not as expected.
trả lại | |
---|---|
the list of UserInfo objects. |
ném | |
---|---|
DeviceNotAvailableException |
getUserSerialNumber
public int getUserSerialNumber (int userId)
Return the serial number associated to the userId if found, -10000 in any other cases.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
int |
ném | |
---|---|
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.
Thông số | |
---|---|
event | DeviceEvent |
trả lại | |
---|---|
IManagedTestDevice.DeviceEventResponse |
hasFeature
public boolean hasFeature (String feature)
Check if a feature is available on a device.
Thông số | |
---|---|
feature | String : which format should be "feature: |
trả lại | |
---|---|
boolean | True if feature is found, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
installPackage
public String installPackage (File packageFile, boolean reinstall, String... extraArgs)
Install an Android package on device.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
DeviceNotAvailableException |
installPackageForUser
public String installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs)
Install an Android package on device for a given user.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
DeviceNotAvailableException |
isAdbTcp
public boolean isAdbTcp ()
trả lại | |
---|---|
boolean |
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Check whether platform on device supports app enumeration
trả lại | |
---|---|
boolean | True if app enumeration is supported, false otherwise |
ném | |
---|---|
DeviceNotAvailableException |
isBypassLowTargetSdkBlockSupported
public boolean isBypassLowTargetSdkBlockSupported ()
Check whether platform on device supports bypassing low target sdk block on app installs
trả lại | |
---|---|
boolean | True if bypass low target sdk block is supported, false otherwise |
ném | |
---|---|
DeviceNotAvailableException |
isDeviceEncrypted
public boolean isDeviceEncrypted ()
Returns if the device is encrypted.
trả lại | |
---|---|
boolean | true if the device is encrypted. |
ném | |
---|---|
DeviceNotAvailableException |
isDirectory
public boolean isDirectory (String path)
Return True if the path on the device is a directory, false otherwise.
Thông số | |
---|---|
path | String |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isEnableAdbRoot
public boolean isEnableAdbRoot ()
trả lại | |
---|---|
boolean | true if adb root should be enabled on device |
isEncryptionSupported
public boolean isEncryptionSupported ()
Returns if encryption is supported on the device.
trả lại | |
---|---|
boolean | true if the device supports encryption. |
ném | |
---|---|
DeviceNotAvailableException |
isExecutable
public boolean isExecutable (String fullPath)
Returns True if the file path on the device is an executable file, false otherwise.
Thông số | |
---|---|
fullPath | String |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isFastbootEnabled
public boolean isFastbootEnabled ()
Return if fastboot is available for the device.
trả lại | |
---|---|
boolean |
isHeadless
public boolean isHeadless ()
Return true if the device is headless (no screen), false otherwise.
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isHeadlessSystemUserMode
public boolean isHeadlessSystemUserMode ()
Returns whether the device uses headless system user mode.
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isMainUserPermanentAdmin
public boolean isMainUserPermanentAdmin ()
Returns whether the main user is a permanent admin and can't be deleted or downgraded to non-admin status.
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isMultiUserSupported
public boolean isMultiUserSupported ()
Determines if multi user is supported.
trả lại | |
---|---|
boolean | true if multi user is supported, false otherwise |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
boolean | True if the package is reported as installed. False otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Query the device for a given package name to check if it's currently installed or not.
Thông số | |
---|---|
packageName | String |
trả lại | |
---|---|
boolean | True if the package is reported as installed. False otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public boolean isRuntimePermissionSupported ()
Check whether platform on device supports runtime permission granting
trả lại | |
---|---|
boolean | True if runtime permission are supported, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
isStateBootloaderOrFastbootd
public boolean isStateBootloaderOrFastbootd ()
Returns true if device is in TestDeviceState#FASTBOOT
or TestDeviceState.FASTBOOTD
.
trả lại | |
---|---|
boolean |
isUserRunning
public boolean isUserRunning (int userId)
Check if a given user is running.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
boolean | True if the user is running, false in every other cases. |
ném | |
---|---|
DeviceNotAvailableException |
isUserSecondary
public boolean isUserSecondary (int userId)
Return whether the specified user is a secondary user according to it's flags.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
boolean | true if the user is secondary, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
isUserVisible
public boolean isUserVisible (int userId)
Checks if the given user is visible.
A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities (typically in the default display).
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isUserVisibleOnDisplay
public boolean isUserVisibleOnDisplay (int userId, int displayId)
Checks if the given user is visible in the given display.
A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities in that display.
Thông số | |
---|---|
userId | int |
displayId | int |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isVisibleBackgroundUsersOnDefaultDisplaySupported
public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()
Returns whether the device allow users to be started visible in the background in the ERROR(/java.android.view.Display#DEFAULT_DISPLAY)
.
If it does, you could call startVisibleBackgroundUser(int, int, boolean)
, passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers()
(which should include ERROR(/java.android.view.Display#DEFAULT_DISPLAY)
).
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
isVisibleBackgroundUsersSupported
public boolean isVisibleBackgroundUsersSupported ()
Returns whether the device allow users to be started visible in the background.
If it does, you could call startVisibleBackgroundUser(int, int, boolean)
, passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers()
.
trả lại | |
---|---|
boolean |
ném | |
---|---|
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.trả lại | |
---|---|
boolean | true if wifi is enabled. false if disabled |
ném | |
---|---|
DeviceNotAvailableException |
listDisplayIds
publiclistDisplayIds ()
Collect the list of available displays id on the device as reported by "dumpsys SurfaceFlinger".
trả lại | |
---|---|
The list of displays. Default always returns the default display 0. |
ném | |
---|---|
DeviceNotAvailableException |
listDisplayIdsForStartingVisibleBackgroundUsers
publiclistDisplayIdsForStartingVisibleBackgroundUsers ()
Gets the list of displays that can be used to start a user visible in the background
.
trả lại | |
---|---|
ném | |
---|---|
DeviceNotAvailableException |
listUsers
publiclistUsers ()
Gets the list of users on the device. Will throw DeviceRuntimeException
if output from device is not as expected.
trả lại | |
---|---|
the list of user ids. |
ném | |
---|---|
DeviceNotAvailableException |
logAnrs
public boolean logAnrs (ITestLogger logger)
Collects and log ANRs from the device.
Thông số | |
---|---|
logger | ITestLogger : an ITestLogger to log the ANRs. |
trả lại | |
---|---|
boolean | True if the logging was successful, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
logBugreport
public boolean logBugreport (String dataName, ITestLogger listener)
Helper method to take a bugreport and log it to the reporters.
Thông số | |
---|---|
dataName | String : name under which the bugreport will be reported. |
listener | ITestLogger : an ITestLogger to log the bugreport. |
trả lại | |
---|---|
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.
Thông số | |
---|---|
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.
ném | |
---|---|
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.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
postAdbUnrootAction
public void postAdbUnrootAction ()
Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. Default implementation doesn't include any additional actions. adb root is not guaranteed to be disabled at this stage.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
postBootSetup
public void postBootSetup ()
Perform instructions to configure device for testing that after every boot.
Should be called after device is fully booted/available In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot. Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)ném | |
---|---|
DeviceNotAvailableException |
bài đăngLời cầu nguyệnTearDown
public void postInvocationTearDown (Throwable exception)
Các bước bổ sung để dọn dẹp theo yêu cầu cụ thể của thiết bị sẽ được thực thi sau khi lệnh gọi hoàn tất.
Thông số | |
---|---|
exception | Throwable : nếu có, ngoại lệ cuối cùng được đưa ra do lỗi gọi. |
cài đặt trước
public void preInvocationSetup (IBuildInfo info, MultiMap<String, String> attributes)
Các bước bổ sung cho thiết lập bắt buộc cụ thể của thiết bị sẽ được thực thi trên thiết bị trước quy trình gọi.
Thông số | |
---|---|
info | IBuildInfo : IBuildInfo của thiết bị. |
attributes | MultiMap : Các thuộc tính được lưu trữ trong ngữ cảnh gọi |
ném | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
pullDir
public boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
Thông số | |
---|---|
deviceFilePath | String : the absolute file path of the remote source |
localDir | File : the local directory to pull files into |
trả lại | |
---|---|
boolean | true if file was pulled successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
pullFile
public boolean pullFile (String remoteFilePath, File localFile)
Retrieves a file off device.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
ném | |
---|---|
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
.
Thông số | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
userId | int : The user id to pull from |
trả lại | |
---|---|
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) |
ném | |
---|---|
DeviceNotAvailableException |
pullFile
public File pullFile (String remoteFilePath)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
Thông số | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
trả lại | |
---|---|
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) |
ném | |
---|---|
DeviceNotAvailableException |
pullFile
public boolean pullFile (String remoteFilePath, File localFile, int userId)
Retrieves a file off device.
Thông số | |
---|---|
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 |
trả lại | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
pullFileContents
public String pullFileContents (String remoteFilePath)
Retrieves a file off device, and returns the contents.
Thông số | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
trả lại | |
---|---|
String | A ERROR(/String) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
ném | |
---|---|
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
.
Thông số | |
---|---|
remoteFilePath | String : the path to file on device, relative to the device's external storage mountpoint |
trả lại | |
---|---|
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) |
ném | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath,excludedDirectories)
Recursively push directory contents to device while excluding some directories that are filtered.
Thông số | |
---|---|
localFileDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
excludedDirectories |
trả lại | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath)
Recursively push directory contents to device.
Thông số | |
---|---|
localFileDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
trả lại | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
ném | |
---|---|
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.
Thông số | |
---|---|
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 |
trả lại | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
pushFile
public boolean pushFile (File localFile, String remoteFilePath)
Push a file to device. By default using a content provider.
Thông số | |
---|---|
localFile | File : the local file to push |
remoteFilePath | String : the remote destination absolute file path |
trả lại | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
pushString
public boolean pushString (String contents, String remoteFilePath)
Push file created from a string to device
Thông số | |
---|---|
contents | String : the contents of the file to push |
remoteFilePath | String : the remote destination absolute file path |
trả lại | |
---|---|
boolean | true if string was pushed successfully. false otherwise. |
ném | |
---|---|
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.
Thông số | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
ném | |
---|---|
DeviceNotAvailableException |
reboot
public void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.ném | |
---|---|
DeviceNotAvailableException |
rebootIntoBootloader
public void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.ném | |
---|---|
DeviceNotAvailableException |
rebootIntoFastbootd
public void rebootIntoFastbootd ()
Reboots the device into fastbootd mode.
Blocks until device is in fastbootd mode.
ném | |
---|---|
DeviceNotAvailableException |
rebootIntoRecovery
public void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryném | |
---|---|
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
ném | |
---|---|
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
Thông số | |
---|---|
autoReboot | boolean : whether to automatically reboot the device after sideload |
ném | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
ném | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline (String reason)
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Thông số | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
ném | |
---|---|
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.
ném | |
---|---|
DeviceNotAvailableException |
rebootUserspaceUntilOnline
public void rebootUserspaceUntilOnline ()
An alternate to rebootUserspace()
()} that only blocks until device is online ie visible to adb.
ném | |
---|---|
DeviceNotAvailableException |
phục hồithiết bị
public boolean recoverDevice ()
Nỗ lực khôi phục giao tiếp thiết bị.
trả lại | |
---|---|
boolean | Đúng nếu quá trình khôi phục đã cố gắng và thành công, trả về Sai nếu quá trình khôi phục bị bỏ qua |
ném | |
---|---|
DeviceNotAvailableException | if device is no longer available |
registerDeviceActionReceiver
public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)
Registers a IDeviceActionReceiver
for this device.
All registered IDeviceActionReceiver
s will be notified before a device action starts and after the device action ends.
Thông số | |
---|---|
deviceActionReceiver | IDeviceActionReceiver : A IDeviceActionReceiver which will be registered. |
remountSystemWritable
public void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
ném | |
---|---|
DeviceNotAvailableException |
remountVendorWritable
public void remountVendorWritable ()
Make the vendor partition on the device writable. May reboot the device.
ném | |
---|---|
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.
Thông số | |
---|---|
componentName | String : of device admin to be removed. |
userId | int : of user that the device admin lives in. |
trả lại | |
---|---|
boolean | True if it is successful, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
removeOwners
public void removeOwners ()
Remove all existing device profile owners with the best effort.
ném | |
---|---|
DeviceNotAvailableException |
removeUser
public boolean removeUser (int userId)
Remove a given user from the device.
Thông số | |
---|---|
userId | int : of the user to remove |
trả lại | |
---|---|
boolean | true if we were successful in removing the user, false otherwise. |
ném | |
---|---|
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.
Thông số | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners | ITestLifeCycleReceiver : the test result listener(s) |
trả lại | |
---|---|
boolean | true if test command completed. false if it failed to complete, but recovery succeeded |
ném | |
---|---|
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.
Thông số | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
trả lại | |
---|---|
boolean | true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded |
ném | |
---|---|
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.
Thông số | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners |
trả lại | |
---|---|
boolean |
ném | |
---|---|
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.
Thông số | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners | ITestLifeCycleReceiver |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
setConfiguration
public void setConfiguration (IConfiguration configuration)
Injects the IConfiguration
in use.
Thông số | |
---|---|
configuration | IConfiguration |
setDate
public void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
Thông số | |
---|---|
date | Date : specify a particular date; will use host date if null |
ném | |
---|---|
DeviceNotAvailableException |
setDeviceOwner
public boolean setDeviceOwner (String componentName, int userId)
Set a device admin component as device owner in given user.
Thông số | |
---|---|
componentName | String : of device admin to be device owner. |
userId | int : of the user that the device owner lives in. |
trả lại | |
---|---|
boolean | True if it is successful, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
setDeviceState
public void setDeviceState (TestDeviceState deviceState)
Update the device's state.
Thông số | |
---|---|
deviceState | TestDeviceState : the TestDeviceState |
setEmulatorOutputStream
public void setEmulatorOutputStream (SizeLimitedOutputStream output)
For emulator set SizeLimitedOutputStream
to log output
Thông số | |
---|---|
output | SizeLimitedOutputStream : to log the output |
setEmulatorProcess
public void setEmulatorProcess (Process p)
Sets the ERROR(/Process)
, when this device is an emulator.
Thông số | |
---|---|
p | Process |
setFastbootEnabled
public void setFastbootEnabled (boolean fastbootEnabled)
Set the fastboot option for the device. Should be set when device is first allocated.
Thông số | |
---|---|
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.
Thông số | |
---|---|
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 IDeviceThông số | |
---|---|
newDevice | IDevice : the IDevice |
setLogStartDelay
public void setLogStartDelay (int delay)
Sets the time in ms to wait before starting logcat capture for a online device.
Thông số | |
---|---|
delay | int : the delay in ms |
setOptions
public void setOptions (TestDeviceOptions options)
Set the TestDeviceOptions
for the device
Thông số | |
---|---|
options | TestDeviceOptions |
setProperty
public boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
Thông số | |
---|---|
propKey | String : The key targeted to be set. |
propValue | String : The property value to be set. |
trả lại | |
---|---|
boolean | returns True if the setprop command was successful, False otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
setRecovery
public void setRecovery (IDeviceRecovery recovery)
Set the IDeviceRecovery
to use for this device. Should be set when device is first allocated.
Thông số | |
---|---|
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, etcThông số | |
---|---|
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.
Thông số | |
---|---|
namespace | String |
key | String |
value | String |
ném | |
---|---|
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"}
Thông số | |
---|---|
userId | int |
namespace | String |
key | String |
value | String |
ném | |
---|---|
DeviceNotAvailableException |
setTestLogger
public void setTestLogger (ITestLogger testLogger)
Injects the ITestLogger
instance
Thông số | |
---|---|
testLogger | ITestLogger |
setUseFastbootErase
public void setUseFastbootErase (boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device.
Thông số | |
---|---|
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.
Thông số | |
---|---|
userId | int : of the user to start in the background |
trả lại | |
---|---|
boolean | true if the user was successfully started in the background. |
ném | |
---|---|
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.
Thông số | |
---|---|
userId | int : of the user to start in the background |
waitFlag | boolean : will make the command wait until user is started and unlocked. |
trả lại | |
---|---|
boolean | true if the user was successfully started in the background. |
ném | |
---|---|
DeviceNotAvailableException |
startVisibleBackgroundUser
public boolean startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag)
Starts a given user in the background, visible in the given display (ie, allowing the user to launch activities in that display).
NOTE: this command doesn't check if the user exists, display is available, device supports such feature
, etc.
Thông số | |
---|---|
userId | int : of the user to start in the background |
displayId | int : display to start user visible on |
waitFlag | boolean : will make the command wait until user is started and unlocked. |
trả lại | |
---|---|
boolean | true if the user was successfully started visible in the background. |
ném | |
---|---|
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.
Thông số | |
---|---|
userId | int : of the user to stop. |
trả lại | |
---|---|
boolean | true if the user was successfully stopped. |
ném | |
---|---|
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.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
boolean | true if the user was successfully stopped. |
ném | |
---|---|
DeviceNotAvailableException |
switchToAdbTcp
public String switchToAdbTcp ()
Switch device to adb-over-tcp mode.
trả lại | |
---|---|
String | the tcp serial number or null if device could not be switched |
ném | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public boolean switchToAdbUsb ()
Switch device to adb over usb mode.
trả lại | |
---|---|
boolean | true if switch was successful, false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
switchUser
public boolean switchUser (int userId)
Switch to another userId with a default timeout. switchUser(int, long)
.
Thông số | |
---|---|
userId | int |
trả lại | |
---|---|
boolean | True if the new userId matches the userId provider. False otherwise. |
ném | |
---|---|
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.
Thông số | |
---|---|
userId | int |
timeout | long : to wait before returning false for switch-user failed. |
trả lại | |
---|---|
boolean | True if the new userId matches the userId provider. False otherwise. |
ném | |
---|---|
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.Thông số | |
---|---|
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 |
trả lại | |
---|---|
boolean | true if files were synced successfully. false otherwise. |
ném | |
---|---|
DeviceNotAvailableException |
takeBugreport
public Bugreport takeBugreport ()
Take a bugreport and returns it inside a Bugreport
object to handle it. Return null in case of issue. File referenced in the Bugreport object need to be cleaned via Bugreport.close()
.
trả lại | |
---|---|
Bugreport |
uninstallPackage
public String uninstallPackage (String packageName)
Uninstall an Android package from device.
Thông số | |
---|---|
packageName | String : the Android package to uninstall |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
DeviceNotAvailableException |
uninstallPackageForUser
public String uninstallPackageForUser (String packageName, int userId)
Uninstall an Android package from device for a given user.
Thông số | |
---|---|
packageName | String : the Android package to uninstall |
userId | int : the integer user id to uninstall for. |
trả lại | |
---|---|
String | a ERROR(/String) with an error code, or null if success. |
ném | |
---|---|
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.trả lại | |
---|---|
boolean | true if successful or if the device is unencrypted. |
ném | |
---|---|
DeviceNotAvailableException |
waitForBootComplete
public boolean waitForBootComplete (long timeOut)
Blocks until the device's boot complete flag is set.
Thông số | |
---|---|
timeOut | long : time in msecs to wait for the flag to be set |
trả lại | |
---|---|
boolean | true if device's boot complete flag is set within the timeout |
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public boolean waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
trả lại | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public boolean waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
Thông số | |
---|---|
waitTime | long : the time in ms to wait |
trả lại | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailableInRecoverPath
public boolean waitForDeviceAvailableInRecoverPath (long waitTime)
Waits for the device to be responsive and available without considering recovery path.
Thông số | |
---|---|
waitTime | long |
trả lại | |
---|---|
boolean | True if device is available, False if unavailable. |
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceBootloader
public void waitForDeviceBootloader ()
Blocks until device is visible via fastboot. Use default timeout.
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceInRecovery
public boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery
).
Thông số | |
---|---|
waitTime | long : the time in ms to wait |
trả lại | |
---|---|
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
Thông số | |
---|---|
waitTime | long : the time in ms to wait |
trả lại | |
---|---|
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
Thông số | |
---|---|
waitTime | long : the time in ms to wait |
trả lại | |
---|---|
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.ném | |
---|---|
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.Thông số | |
---|---|
waitTime | long : the time in ms to wait |
ném | |
---|---|
DeviceNotAvailableException |
waitForDeviceShell
public boolean waitForDeviceShell (long waitTime)
Waits for device to be responsive to a basic adb shell command.
Thông số | |
---|---|
waitTime | long : the time in ms to wait |
trả lại | |
---|---|
boolean | true if device becomes responsive before waitTime elapses. |
phương pháp được bảo vệ
buildAdbShellCommand
protected String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)
Builds the OS command for the given adb shell command session and args
Thông số | |
---|---|
command | String |
forceExitStatusDetection | boolean |
trả lại | |
---|---|
String[] |
checkApiLevelAgainst
protected void checkApiLevelAgainst (String feature, int strictMinLevel)
Thông số | |
---|---|
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.
Thông số | |
---|---|
rebootMode | NativeDevice.RebootMode : một chế độ khởi động lại này. |
reason | String : cho lần khởi động lại này. |
trả lại | |
---|---|
NativeDevice.RebootDeviceAction | the created RebootDeviceAction . |
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode, String reason)
Thực hiện khởi động lại adb.
Thông số | |
---|---|
rebootMode | NativeDevice.RebootMode : một chế độ khởi động lại này. |
reason | String : cho lần khởi động lại này. |
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
ensureRuntimePermissionSupported
protected void ensureRuntimePermissionSupported ()
helper method to throw exception if runtime permission isn't supported
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getApiLevelSafe
protected int getApiLevelSafe ()
trả lại | |
---|---|
int |
initializeConnection
protected void initializeConnection (IBuildInfo info, MultiMap<String, String> attributes)
Thông số | |
---|---|
info | IBuildInfo |
attributes | MultiMap |
ném | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
internalGetProperty
protected String internalGetProperty (String propName, String fastbootVar, String description)
Fetch a device property, from the ddmlib cache by default, and falling back to either `adb shell getprop` or `fastboot getvar` depending on whether the device is in Fastboot or not.
Thông số | |
---|---|
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. |
trả lại | |
---|---|
String | A string, possibly null or empty, containing the value of the given property |
ném | |
---|---|
DeviceNotAvailableException |
isInRebootCallback
protected boolean isInRebootCallback ()
Returns whether reboot callbacks is currently being executed or not. All public api's for reboot should be disabled if true.
trả lại | |
---|---|
boolean |
isNewer
protected boolean isNewer (File localFile, IFileEntry entry)
Return true
if local file is newer than remote file. IFileEntry
being accurate to the minute, in case of equal times, the file will be considered newer.
Thông số | |
---|---|
localFile | File |
entry | IFileEntry |
trả lại | |
---|---|
boolean |
notifyRebootEnded
protected void notifyRebootEnded ()
Notifies all IDeviceActionReceiver
about reboot end event.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
notifyRebootStarted
protected void notifyRebootStarted ()
Notifies all IDeviceActionReceiver
about reboot start event.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
performDeviceAction
protected boolean performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts)
Performs an action on this device. Attempts to recover device and optionally retry command if action fails.
Thông số | |
---|---|
actionDescription | String : a short description of action to be performed. Used for logging purposes only. |
action | NativeDevice.DeviceAction : the action to be performed |
retryAttempts | int : the retry attempts to make for action if it fails but recovery succeeds |
trả lại | |
---|---|
boolean | true if action was performed successfully |
ném | |
---|---|
DeviceNotAvailableException | if recovery attempt fails or max attempts done without success |
postAdbKhởi động lại
protected void postAdbReboot ()
Các hành động bổ sung có thể được thực hiện sau khi khởi động lại.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
prePostBootSetup
protected void prePostBootSetup ()
Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.
ném | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
pullFileInternal
protected boolean pullFileInternal (String remoteFilePath, File localFile)
Thông số | |
---|---|
remoteFilePath | String |
localFile | File |
trả lại | |
---|---|
boolean |
ném | |
---|---|
DeviceNotAvailableException |
setClock
protected void setClock (Clock clock)
Set the Clock instance to use.
Thông số | |
---|---|
clock | Clock |
setMicrodroidProcess
protected void setMicrodroidProcess (Process process)
Marks the TestDevice as microdroid and sets its CID.
Thông số | |
---|---|
process | Process : Process of the Microdroid VM. |
setTestDeviceOptions
protected void setTestDeviceOptions (deviceOptions)
Thông số | |
---|---|
deviceOptions |
simpleFastbootCommand
protected CommandResult simpleFastbootCommand (long timeout,envVarMap, String[] fullCmd)
Executes a simple fastboot command with environment variables and report the status of the command.
Thông số | |
---|---|
timeout | long |
envVarMap | |
fullCmd | String |
trả lại | |
---|---|
CommandResult |
simpleFastbootCommand
protected CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)
Executes a simple fastboot command and report the status of the command.
Thông số | |
---|---|
timeout | long |
fullCmd | String |
trả lại | |
---|---|
CommandResult |
waitForDeviceNotAvailable
protected boolean waitForDeviceNotAvailable (String operationDesc, long time)
Wait to see the device going unavailable (stop reporting to adb).
Thông số | |
---|---|
operationDesc | String : The name of the operation that is waiting for unavailable. |
time | long : The time to wait for unavailable to occur. |
trả lại | |
---|---|
boolean | True if device did become unavailable. |
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2023-04-28 UTC.