1# [devil.android.sdk.adb_wrapper](https://chromium.googlesource.com/catapult.git/+/HEAD/devil/devil/android/sdk/adb_wrapper.py) 2 3*This page was autogenerated. Run `devil/bin/generate_md_docs` to update* 4 5## AdbWrapper 6 7A wrapper around a local Android Debug Bridge executable. 8### AdbWrapper.Backup 9 10Write an archive of the device's data to |path|. 11``` 12 Args: 13 path: Local path to store the backup file. 14 packages: List of to packages to be backed up. 15 apk: (optional) If set include the .apk files in the archive. 16 shared: (optional) If set buckup the device's SD card. 17 nosystem: (optional) If set exclude system applications. 18 include_all: (optional) If set back up all installed applications and 19 |packages| is optional. 20 timeout: (optional) Timeout per try in seconds. 21 retries: (optional) Number of retries to attempt. 22``` 23 24 25### AdbWrapper.DisableVerity 26 27Disable Marshmallow's Verity security feature. 28``` 29 Returns: 30 The output of the disable-verity command as a string. 31``` 32 33 34### AdbWrapper.Emu 35 36Runs an emulator console command. 37``` 38 See http://developer.android.com/tools/devices/emulator.html#console 39 40 Args: 41 cmd: The command to run on the emulator console. 42 timeout: (optional) Timeout per try in seconds. 43 retries: (optional) Number of retries to attempt. 44 45 Returns: 46 The output of the emulator console command. 47``` 48 49 50### AdbWrapper.EnableVerity 51 52Enable Marshmallow's Verity security feature. 53``` 54 Returns: 55 The output of the enable-verity command as a string. 56``` 57 58 59### AdbWrapper.Forward 60 61Forward socket connections from the local socket to the remote socket. 62``` 63 Sockets are specified by one of: 64 tcp:<port> 65 localabstract:<unix domain socket name> 66 localreserved:<unix domain socket name> 67 localfilesystem:<unix domain socket name> 68 dev:<character device name> 69 jdwp:<process pid> (remote only) 70 71 Args: 72 local: The host socket. 73 remote: The device socket. 74 allow_rebind: A boolean indicating whether adb may rebind a local socket; 75 otherwise, the default, an exception is raised if the local socket is 76 already being forwarded. 77 timeout: (optional) Timeout per try in seconds. 78 retries: (optional) Number of retries to attempt. 79``` 80 81 82### AdbWrapper.ForwardList 83 84List all currently forwarded socket connections. 85``` 86 Args: 87 timeout: (optional) Timeout per try in seconds. 88 retries: (optional) Number of retries to attempt. 89 Returns: 90 The output of adb forward --list as a string. 91``` 92 93 94### AdbWrapper.ForwardRemove 95 96Remove a forward socket connection. 97``` 98 Args: 99 local: The host socket. 100 timeout: (optional) Timeout per try in seconds. 101 retries: (optional) Number of retries to attempt. 102``` 103 104 105### AdbWrapper.GetDevPath 106 107Gets the device path. 108``` 109 Args: 110 timeout: (optional) Timeout per try in seconds. 111 retries: (optional) Number of retries to attempt. 112 113 Returns: 114 The device path (e.g. usb:3-4) 115``` 116 117 118### AdbWrapper.GetDeviceSerial 119 120Gets the device serial number associated with this object. 121``` 122 Returns: 123 Device serial number as a string. 124``` 125 126 127### AdbWrapper.GetState 128 129Get device state. 130``` 131 Args: 132 timeout: (optional) Timeout per try in seconds. 133 retries: (optional) Number of retries to attempt. 134 135 Returns: 136 One of 'offline', 'bootloader', or 'device'. 137``` 138 139 140### AdbWrapper.Install 141 142Install an apk on the device. 143``` 144 Args: 145 apk_path: Host path to the APK file. 146 forward_lock: (optional) If set forward-locks the app. 147 allow_downgrade: (optional) If set, allows for downgrades. 148 reinstall: (optional) If set reinstalls the app, keeping its data. 149 sd_card: (optional) If set installs on the SD card. 150 streaming: (optional) If not set, use default way to install. 151 If True, performs streaming install. 152 If False, app is pushed to device and be installed from there. 153 Note this option is not supported prior to adb version 1.0.40 154 timeout: (optional) Timeout per try in seconds. 155 retries: (optional) Number of retries to attempt. 156``` 157 158 159### AdbWrapper.InstallMultiple 160 161Install an apk with splits on the device. 162``` 163 Args: 164 apk_paths: Host path to the APK file. 165 forward_lock: (optional) If set forward-locks the app. 166 reinstall: (optional) If set reinstalls the app, keeping its data. 167 sd_card: (optional) If set installs on the SD card. 168 allow_downgrade: (optional) Allow versionCode downgrade. 169 partial: (optional) Package ID if apk_paths doesn't include all .apks. 170 streaming: (optional) If not set, use default way to install. 171 If True, performs streaming install. 172 If False, app is pushed to device and be installed from there. 173 Note this option is not supported prior to adb version 1.0.40 174 timeout: (optional) Timeout per try in seconds. 175 retries: (optional) Number of retries to attempt. 176``` 177 178 179### AdbWrapper.IterShell 180 181Runs a shell command and returns an iterator over its output lines. 182``` 183 Args: 184 command: A string with the shell command to run. 185 timeout: Timeout in seconds. 186 187 Yields: 188 The output of the command line by line. 189``` 190 191 192### AdbWrapper.JDWP 193 194List of PIDs of processes hosting a JDWP transport. 195``` 196 Args: 197 timeout: (optional) Timeout per try in seconds. 198 retries: (optional) Number of retries to attempt. 199 200 Returns: 201 A list of PIDs as strings. 202``` 203 204 205### AdbWrapper.Logcat 206 207Get an iterable over the logcat output. 208``` 209 Args: 210 clear: If true, clear the logcat. 211 dump: If true, dump the current logcat contents. 212 filter_specs: If set, a list of specs to filter the logcat. 213 logcat_format: If set, the format in which the logcat should be output. 214 Options include "brief", "process", "tag", "thread", "raw", "time", 215 "threadtime", and "long" 216 ring_buffer: If set, a list of alternate ring buffers to request. 217 Options include "main", "system", "radio", "events", "crash" or "all". 218 The default is equivalent to ["main", "system", "crash"]. 219 iter_timeout: If set and neither clear nor dump is set, the number of 220 seconds to wait between iterations. If no line is found before the 221 given number of seconds elapses, the iterable will yield None. 222 check_error: Whether to check the exit status of the logcat command. 223 timeout: (optional) If set, timeout per try in seconds. If clear or dump 224 is set, defaults to DEFAULT_TIMEOUT. 225 retries: (optional) If clear or dump is set, the number of retries to 226 attempt. Otherwise, does nothing. 227 228 Yields: 229 logcat output line by line. 230``` 231 232 233### AdbWrapper.Ls 234 235List the contents of a directory on the device. 236``` 237 Args: 238 path: Path on the device filesystem. 239 timeout: (optional) Timeout per try in seconds. 240 retries: (optional) Number of retries to attempt. 241 242 Returns: 243 A list of pairs (filename, stat) for each file found in the directory, 244 where the stat object has the properties: st_mode, st_size, and st_time. 245 246 Raises: 247 AdbCommandFailedError if |path| does not specify a valid and accessible 248 directory in the device, or the output of "adb ls" command is less 249 than four columns 250``` 251 252 253### AdbWrapper.Pull 254 255Pulls a file from the device to the host. 256``` 257 Args: 258 remote: Path on the device filesystem. 259 local: Path on the host filesystem. 260 timeout: (optional) Timeout per try in seconds. 261 retries: (optional) Number of retries to attempt. 262``` 263 264 265### AdbWrapper.Push 266 267Pushes a file from the host to the device. 268``` 269 Args: 270 local: Path on the host filesystem. 271 remote: Path on the device filesystem. 272 sync: (optional) Whether to only push files that are newer on the host. 273 Not supported when using adb prior to 1.0.39. 274 timeout: (optional) Timeout per try in seconds. 275 retries: (optional) Number of retries to attempt. 276 277 Raises: 278 AdbVersionError if sync=True with versions of adb prior to 1.0.39. 279``` 280 281 282### AdbWrapper.Reboot 283 284Reboots the device. 285``` 286 Args: 287 to_bootloader: (optional) If set reboots to the bootloader. 288 timeout: (optional) Timeout per try in seconds. 289 retries: (optional) Number of retries to attempt. 290``` 291 292 293### AdbWrapper.Remount 294 295Remounts the /system partition on the device read-write. 296### AdbWrapper.Restore 297 298Restore device contents from the backup archive. 299``` 300 Args: 301 path: Host path to the backup archive. 302 timeout: (optional) Timeout per try in seconds. 303 retries: (optional) Number of retries to attempt. 304``` 305 306 307### AdbWrapper.Root 308 309Restarts the adbd daemon with root permissions, if possible. 310``` 311 Args: 312 timeout: (optional) Timeout per try in seconds. 313 retries: (optional) Number of retries to attempt. 314``` 315 316 317### AdbWrapper.Shell 318 319Runs a shell command on the device. 320``` 321 Args: 322 command: A string with the shell command to run. 323 expect_status: (optional) Check that the command's exit status matches 324 this value. Default is 0. If set to None the test is skipped. 325 timeout: (optional) Timeout per try in seconds. 326 retries: (optional) Number of retries to attempt. 327 328 Returns: 329 The output of the shell command as a string. 330 331 Raises: 332 device_errors.AdbCommandFailedError: If the exit status doesn't match 333 |expect_status|. 334``` 335 336 337### AdbWrapper.StartShell 338 339Starts a subprocess on the device and returns a handle to the process. 340``` 341 Args: 342 args: A sequence of program arguments. The executable to run is the first 343 item in the sequence. 344 345 Returns: 346 An instance of subprocess.Popen associated with the live process. 347``` 348 349 350### AdbWrapper.Uninstall 351 352Remove the app |package| from the device. 353``` 354 Args: 355 package: The package to uninstall. 356 keep_data: (optional) If set keep the data and cache directories. 357 timeout: (optional) Timeout per try in seconds. 358 retries: (optional) Number of retries to attempt. 359``` 360 361 362### AdbWrapper.WaitForDevice 363 364Block until the device is online. 365``` 366 Args: 367 timeout: (optional) Timeout per try in seconds. 368 retries: (optional) Number of retries to attempt. 369``` 370 371 372### AdbWrapper.\_\_eq\_\_ 373 374Consider instances equal if they refer to the same device. 375``` 376 Args: 377 other: The instance to compare equality with. 378 379 Returns: 380 True if the instances are considered equal, false otherwise. 381``` 382 383 384### AdbWrapper.\_\_init\_\_ 385 386Initializes the AdbWrapper. 387``` 388 Args: 389 device_serial: The device serial number as a string. 390``` 391 392 393### AdbWrapper.\_\_repr\_\_ 394 395### AdbWrapper.\_\_str\_\_ 396 397The string representation of an instance. 398``` 399 Returns: 400 The device serial number as a string. 401``` 402 403 404## DeviceStat 405 406DeviceStat(st\_mode, st\_size, st\_time) 407### DeviceStat.\_\_getnewargs\_\_ 408 409Return self as a plain tuple. Used by copy and pickle. 410### DeviceStat.\_\_getstate\_\_ 411 412Exclude the OrderedDict from pickling 413### DeviceStat.\_\_repr\_\_ 414 415Return a nicely formatted representation string 416### VerifyLocalFileExists 417 418Verifies a local file exists. 419``` 420 Args: 421 path: Path to the local file. 422 423 Raises: 424 IOError: If the file doesn't exist. 425``` 426 427 428