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