Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: build/android/pylib/device/adb_wrapper.py

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """This module wraps Android's adb tool. 5 """This module wraps Android's adb tool.
6 6
7 This is a thin wrapper around the adb interface. Any additional complexity 7 This is a thin wrapper around the adb interface. Any additional complexity
8 should be delegated to a higher level (ex. DeviceUtils). 8 should be delegated to a higher level (ex. DeviceUtils).
9 """ 9 """
10 10
11 import errno 11 import errno
12 import logging
12 import os 13 import os
13 14
14 from pylib import cmd_helper 15 from pylib import cmd_helper
15 from pylib import constants 16 from pylib import constants
16 from pylib.device import decorators 17 from pylib.device import decorators
17 from pylib.device import device_errors 18 from pylib.device import device_errors
18 from pylib.utils import timeout_retry 19 from pylib.utils import timeout_retry
19 20
20 21
21 _DEFAULT_TIMEOUT = 30 22 _DEFAULT_TIMEOUT = 30
(...skipping 15 matching lines...) Expand all
37 38
38 class AdbWrapper(object): 39 class AdbWrapper(object):
39 """A wrapper around a local Android Debug Bridge executable.""" 40 """A wrapper around a local Android Debug Bridge executable."""
40 41
41 def __init__(self, device_serial): 42 def __init__(self, device_serial):
42 """Initializes the AdbWrapper. 43 """Initializes the AdbWrapper.
43 44
44 Args: 45 Args:
45 device_serial: The device serial number as a string. 46 device_serial: The device serial number as a string.
46 """ 47 """
48 if not device_serial:
49 raise ValueError('A device serial must be specified')
47 self._device_serial = str(device_serial) 50 self._device_serial = str(device_serial)
48 51
49 # pylint: disable=unused-argument 52 # pylint: disable=unused-argument
50 @classmethod 53 @classmethod
51 @decorators.WithTimeoutAndRetries 54 @decorators.WithTimeoutAndRetries
52 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): 55 def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None,
53 cmd = [constants.GetAdbPath()] + arg_list 56 check_error=True):
54 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( 57 cmd = [constants.GetAdbPath()]
55 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime()) 58 if device_serial is not None:
56 if exit_code != 0: 59 cmd.extend(['-s', device_serial])
60 cmd.extend(args)
61 status, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
62 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime())
63 if status != 0:
57 raise device_errors.AdbCommandFailedError( 64 raise device_errors.AdbCommandFailedError(
58 cmd, 'returned non-zero exit code %d and output %r' % 65 args, output, status, device_serial)
59 (exit_code, output))
60 # This catches some errors, including when the device drops offline; 66 # This catches some errors, including when the device drops offline;
61 # unfortunately adb is very inconsistent with error reporting so many 67 # unfortunately adb is very inconsistent with error reporting so many
62 # command failures present differently. 68 # command failures present differently.
63 if check_error and output[:len('error:')] == 'error:': 69 if check_error and output.startswith('error:'):
64 raise device_errors.AdbCommandFailedError(arg_list, output) 70 raise device_errors.AdbCommandFailedError(args, output)
65 return output 71 return output
66 # pylint: enable=unused-argument 72 # pylint: enable=unused-argument
67 73
68 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True): 74 def _RunDeviceAdbCmd(self, args, timeout, retries, check_error=True):
69 """Runs an adb command on the device associated with this object. 75 """Runs an adb command on the device associated with this object.
70 76
71 Args: 77 Args:
72 arg_list: A list of arguments to adb. 78 args: A list of arguments to adb.
73 timeout: Timeout in seconds. 79 timeout: Timeout in seconds.
74 retries: Number of retries. 80 retries: Number of retries.
75 check_error: Check that the command doesn't return an error message. This 81 check_error: Check that the command doesn't return an error message. This
76 does NOT check the return code of shell commands. 82 does NOT check the exit status of shell commands.
77 83
78 Returns: 84 Returns:
79 The output of the command. 85 The output of the command.
80 """ 86 """
81 return self._RunAdbCmd( 87 return self._RunAdbCmd(args, timeout=timeout, retries=retries,
82 ['-s', self._device_serial] + arg_list, timeout=timeout, 88 device_serial=self._device_serial,
83 retries=retries, check_error=check_error) 89 check_error=check_error)
84 90
85 def __eq__(self, other): 91 def __eq__(self, other):
86 """Consider instances equal if they refer to the same device. 92 """Consider instances equal if they refer to the same device.
87 93
88 Args: 94 Args:
89 other: The instance to compare equality with. 95 other: The instance to compare equality with.
90 96
91 Returns: 97 Returns:
92 True if the instances are considered equal, false otherwise. 98 True if the instances are considered equal, false otherwise.
93 """ 99 """
(...skipping 16 matching lines...) Expand all
110 """Get the list of active attached devices. 116 """Get the list of active attached devices.
111 117
112 Args: 118 Args:
113 timeout: (optional) Timeout per try in seconds. 119 timeout: (optional) Timeout per try in seconds.
114 retries: (optional) Number of retries to attempt. 120 retries: (optional) Number of retries to attempt.
115 121
116 Yields: 122 Yields:
117 AdbWrapper instances. 123 AdbWrapper instances.
118 """ 124 """
119 output = cls._RunAdbCmd(['devices'], timeout=timeout, retries=retries) 125 output = cls._RunAdbCmd(['devices'], timeout=timeout, retries=retries)
120 lines = [line.split() for line in output.split('\n')] 126 lines = [line.split() for line in output.splitlines()]
121 return [AdbWrapper(line[0]) for line in lines 127 return [AdbWrapper(line[0]) for line in lines
122 if len(line) == 2 and line[1] == 'device'] 128 if len(line) == 2 and line[1] == 'device']
123 129
124 def GetDeviceSerial(self): 130 def GetDeviceSerial(self):
125 """Gets the device serial number associated with this object. 131 """Gets the device serial number associated with this object.
126 132
127 Returns: 133 Returns:
128 Device serial number as a string. 134 Device serial number as a string.
129 """ 135 """
130 return self._device_serial 136 return self._device_serial
131 137
132 def Push(self, local, remote, timeout=60*5, retries=_DEFAULT_RETRIES): 138 def Push(self, local, remote, timeout=60*5, retries=_DEFAULT_RETRIES):
133 """Pushes a file from the host to the device. 139 """Pushes a file from the host to the device.
134 140
135 Args: 141 Args:
136 local: Path on the host filesystem. 142 local: Path on the host filesystem.
137 remote: Path on the device filesystem. 143 remote: Path on the device filesystem.
138 timeout: (optional) Timeout per try in seconds. 144 timeout: (optional) Timeout per try in seconds.
139 retries: (optional) Number of retries to attempt. 145 retries: (optional) Number of retries to attempt.
140 """ 146 """
141 _VerifyLocalFileExists(local) 147 _VerifyLocalFileExists(local)
142 self._DeviceAdbCmd(['push', local, remote], timeout, retries) 148 self._RunDeviceAdbCmd(['push', local, remote], timeout, retries)
143 149
144 def Pull(self, remote, local, timeout=60*5, retries=_DEFAULT_RETRIES): 150 def Pull(self, remote, local, timeout=60*5, retries=_DEFAULT_RETRIES):
145 """Pulls a file from the device to the host. 151 """Pulls a file from the device to the host.
146 152
147 Args: 153 Args:
148 remote: Path on the device filesystem. 154 remote: Path on the device filesystem.
149 local: Path on the host filesystem. 155 local: Path on the host filesystem.
150 timeout: (optional) Timeout per try in seconds. 156 timeout: (optional) Timeout per try in seconds.
151 retries: (optional) Number of retries to attempt. 157 retries: (optional) Number of retries to attempt.
152 """ 158 """
153 self._DeviceAdbCmd(['pull', remote, local], timeout, retries) 159 self._RunDeviceAdbCmd(['pull', remote, local], timeout, retries)
154 _VerifyLocalFileExists(local) 160 _VerifyLocalFileExists(local)
155 161
156 def Shell(self, command, expect_rc=0, timeout=_DEFAULT_TIMEOUT, 162 def Shell(self, command, expect_status=0, timeout=_DEFAULT_TIMEOUT,
157 retries=_DEFAULT_RETRIES): 163 retries=_DEFAULT_RETRIES):
158 """Runs a shell command on the device. 164 """Runs a shell command on the device.
159 165
160 Args: 166 Args:
161 command: The shell command to run. 167 command: A string with the shell command to run.
162 expect_rc: (optional) Check that the command's return code matches this 168 expect_status: (optional) Check that the command's exit status matches
163 value. Default is 0. If set to None the test is skipped. 169 this value. Default is 0. If set to None the test is skipped.
164 timeout: (optional) Timeout per try in seconds. 170 timeout: (optional) Timeout per try in seconds.
165 retries: (optional) Number of retries to attempt. 171 retries: (optional) Number of retries to attempt.
166 172
167 Returns: 173 Returns:
168 The output of the shell command as a string. 174 The output of the shell command as a string.
169 175
170 Raises: 176 Raises:
171 device_errors.AdbCommandFailedError: If the return code doesn't match 177 device_errors.AdbCommandFailedError: If the exit status doesn't match
172 |expect_rc|. 178 |expect_status|.
173 """ 179 """
174 if expect_rc is None: 180 if expect_status is None:
175 actual_command = command 181 args = ['shell', command]
176 else: 182 else:
177 actual_command = '%s; echo %%$?;' % command.rstrip() 183 args = ['shell', '%s; echo %%$?;' % command.rstrip()]
178 output = self._DeviceAdbCmd( 184 output = self._RunDeviceAdbCmd(args, timeout, retries, check_error=False)
179 ['shell', actual_command], timeout, retries, check_error=False) 185 if expect_status is not None:
180 if expect_rc is not None:
181 output_end = output.rfind('%') 186 output_end = output.rfind('%')
182 if output_end < 0: 187 if output_end < 0:
183 # causes the string for rc to become empty and also raise a ValueError 188 # causes the status string to become empty and raise a ValueError
184 output_end = len(output) 189 output_end = len(output)
185 190
186 try: 191 try:
187 rc = int(output[output_end+1:]) 192 status = int(output[output_end+1:])
188 except ValueError: 193 except ValueError:
194 logging.warning('exit status of shell command %r missing.', command)
189 raise device_errors.AdbCommandFailedError( 195 raise device_errors.AdbCommandFailedError(
190 ['shell'], 'command %r on device produced output %r where no' 196 args, output, device_serial=self._device_serial)
191 ' valid return code was found' % (actual_command, output),
192 self._device_serial)
193
194 output = output[:output_end] 197 output = output[:output_end]
195 if rc != expect_rc: 198 if status != expect_status:
196 raise device_errors.AdbShellCommandFailedError( 199 raise device_errors.AdbCommandFailedError(
197 command, rc, output, self._device_serial) 200 args, output, status, self._device_serial)
198 return output 201 return output
199 202
200 def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT, 203 def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT,
201 retries=_DEFAULT_RETRIES): 204 retries=_DEFAULT_RETRIES):
202 """Get the logcat output. 205 """Get the logcat output.
203 206
204 Args: 207 Args:
205 filter_spec: (optional) Spec to filter the logcat. 208 filter_spec: (optional) Spec to filter the logcat.
206 timeout: (optional) Timeout per try in seconds. 209 timeout: (optional) Timeout per try in seconds.
207 retries: (optional) Number of retries to attempt. 210 retries: (optional) Number of retries to attempt.
208 211
209 Returns: 212 Returns:
210 logcat output as a string. 213 logcat output as a string.
211 """ 214 """
212 cmd = ['logcat'] 215 cmd = ['logcat']
213 if filter_spec is not None: 216 if filter_spec is not None:
214 cmd.append(filter_spec) 217 cmd.append(filter_spec)
215 return self._DeviceAdbCmd(cmd, timeout, retries, check_error=False) 218 return self._RunDeviceAdbCmd(cmd, timeout, retries, check_error=False)
216 219
217 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, 220 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT,
218 retries=_DEFAULT_RETRIES): 221 retries=_DEFAULT_RETRIES):
219 """Forward socket connections from the local socket to the remote socket. 222 """Forward socket connections from the local socket to the remote socket.
220 223
221 Sockets are specified by one of: 224 Sockets are specified by one of:
222 tcp:<port> 225 tcp:<port>
223 localabstract:<unix domain socket name> 226 localabstract:<unix domain socket name>
224 localreserved:<unix domain socket name> 227 localreserved:<unix domain socket name>
225 localfilesystem:<unix domain socket name> 228 localfilesystem:<unix domain socket name>
226 dev:<character device name> 229 dev:<character device name>
227 jdwp:<process pid> (remote only) 230 jdwp:<process pid> (remote only)
228 231
229 Args: 232 Args:
230 local: The host socket. 233 local: The host socket.
231 remote: The device socket. 234 remote: The device socket.
232 timeout: (optional) Timeout per try in seconds. 235 timeout: (optional) Timeout per try in seconds.
233 retries: (optional) Number of retries to attempt. 236 retries: (optional) Number of retries to attempt.
234 """ 237 """
235 self._DeviceAdbCmd(['forward', str(local), str(remote)], timeout, retries) 238 self._RunDeviceAdbCmd(['forward', str(local), str(remote)], timeout,
239 retries)
236 240
237 def JDWP(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 241 def JDWP(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
238 """List of PIDs of processes hosting a JDWP transport. 242 """List of PIDs of processes hosting a JDWP transport.
239 243
240 Args: 244 Args:
241 timeout: (optional) Timeout per try in seconds. 245 timeout: (optional) Timeout per try in seconds.
242 retries: (optional) Number of retries to attempt. 246 retries: (optional) Number of retries to attempt.
243 247
244 Returns: 248 Returns:
245 A list of PIDs as strings. 249 A list of PIDs as strings.
246 """ 250 """
247 return [a.strip() for a in 251 return [a.strip() for a in
248 self._DeviceAdbCmd(['jdwp'], timeout, retries).split('\n')] 252 self._RunDeviceAdbCmd(['jdwp'], timeout, retries).split('\n')]
249 253
250 def Install(self, apk_path, forward_lock=False, reinstall=False, 254 def Install(self, apk_path, forward_lock=False, reinstall=False,
251 sd_card=False, timeout=60*2, retries=_DEFAULT_RETRIES): 255 sd_card=False, timeout=60*2, retries=_DEFAULT_RETRIES):
252 """Install an apk on the device. 256 """Install an apk on the device.
253 257
254 Args: 258 Args:
255 apk_path: Host path to the APK file. 259 apk_path: Host path to the APK file.
256 forward_lock: (optional) If set forward-locks the app. 260 forward_lock: (optional) If set forward-locks the app.
257 reinstall: (optional) If set reinstalls the app, keeping its data. 261 reinstall: (optional) If set reinstalls the app, keeping its data.
258 sd_card: (optional) If set installs on the SD card. 262 sd_card: (optional) If set installs on the SD card.
259 timeout: (optional) Timeout per try in seconds. 263 timeout: (optional) Timeout per try in seconds.
260 retries: (optional) Number of retries to attempt. 264 retries: (optional) Number of retries to attempt.
261 """ 265 """
262 _VerifyLocalFileExists(apk_path) 266 _VerifyLocalFileExists(apk_path)
263 cmd = ['install'] 267 cmd = ['install']
264 if forward_lock: 268 if forward_lock:
265 cmd.append('-l') 269 cmd.append('-l')
266 if reinstall: 270 if reinstall:
267 cmd.append('-r') 271 cmd.append('-r')
268 if sd_card: 272 if sd_card:
269 cmd.append('-s') 273 cmd.append('-s')
270 cmd.append(apk_path) 274 cmd.append(apk_path)
271 output = self._DeviceAdbCmd(cmd, timeout, retries) 275 output = self._RunDeviceAdbCmd(cmd, timeout, retries)
272 if 'Success' not in output: 276 if 'Success' not in output:
273 raise device_errors.AdbCommandFailedError(cmd, output) 277 raise device_errors.AdbCommandFailedError(
278 cmd, output, device_serial=self._device_serial)
274 279
275 def Uninstall(self, package, keep_data=False, timeout=_DEFAULT_TIMEOUT, 280 def Uninstall(self, package, keep_data=False, timeout=_DEFAULT_TIMEOUT,
276 retries=_DEFAULT_RETRIES): 281 retries=_DEFAULT_RETRIES):
277 """Remove the app |package| from the device. 282 """Remove the app |package| from the device.
278 283
279 Args: 284 Args:
280 package: The package to uninstall. 285 package: The package to uninstall.
281 keep_data: (optional) If set keep the data and cache directories. 286 keep_data: (optional) If set keep the data and cache directories.
282 timeout: (optional) Timeout per try in seconds. 287 timeout: (optional) Timeout per try in seconds.
283 retries: (optional) Number of retries to attempt. 288 retries: (optional) Number of retries to attempt.
284 """ 289 """
285 cmd = ['uninstall'] 290 cmd = ['uninstall']
286 if keep_data: 291 if keep_data:
287 cmd.append('-k') 292 cmd.append('-k')
288 cmd.append(package) 293 cmd.append(package)
289 output = self._DeviceAdbCmd(cmd, timeout, retries) 294 output = self._RunDeviceAdbCmd(cmd, timeout, retries)
290 if 'Failure' in output: 295 if 'Failure' in output:
291 raise device_errors.AdbCommandFailedError(cmd, output) 296 raise device_errors.AdbCommandFailedError(
297 cmd, output, device_serial=self._device_serial)
292 298
293 def Backup(self, path, packages=None, apk=False, shared=False, 299 def Backup(self, path, packages=None, apk=False, shared=False,
294 nosystem=True, include_all=False, timeout=_DEFAULT_TIMEOUT, 300 nosystem=True, include_all=False, timeout=_DEFAULT_TIMEOUT,
295 retries=_DEFAULT_RETRIES): 301 retries=_DEFAULT_RETRIES):
296 """Write an archive of the device's data to |path|. 302 """Write an archive of the device's data to |path|.
297 303
298 Args: 304 Args:
299 path: Local path to store the backup file. 305 path: Local path to store the backup file.
300 packages: List of to packages to be backed up. 306 packages: List of to packages to be backed up.
301 apk: (optional) If set include the .apk files in the archive. 307 apk: (optional) If set include the .apk files in the archive.
(...skipping 10 matching lines...) Expand all
312 if shared: 318 if shared:
313 cmd.append('-shared') 319 cmd.append('-shared')
314 if nosystem: 320 if nosystem:
315 cmd.append('-nosystem') 321 cmd.append('-nosystem')
316 if include_all: 322 if include_all:
317 cmd.append('-all') 323 cmd.append('-all')
318 if packages: 324 if packages:
319 cmd.extend(packages) 325 cmd.extend(packages)
320 assert bool(packages) ^ bool(include_all), ( 326 assert bool(packages) ^ bool(include_all), (
321 'Provide \'packages\' or set \'include_all\' but not both.') 327 'Provide \'packages\' or set \'include_all\' but not both.')
322 ret = self._DeviceAdbCmd(cmd, timeout, retries) 328 ret = self._RunDeviceAdbCmd(cmd, timeout, retries)
323 _VerifyLocalFileExists(path) 329 _VerifyLocalFileExists(path)
324 return ret 330 return ret
325 331
326 def Restore(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 332 def Restore(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
327 """Restore device contents from the backup archive. 333 """Restore device contents from the backup archive.
328 334
329 Args: 335 Args:
330 path: Host path to the backup archive. 336 path: Host path to the backup archive.
331 timeout: (optional) Timeout per try in seconds. 337 timeout: (optional) Timeout per try in seconds.
332 retries: (optional) Number of retries to attempt. 338 retries: (optional) Number of retries to attempt.
333 """ 339 """
334 _VerifyLocalFileExists(path) 340 _VerifyLocalFileExists(path)
335 self._DeviceAdbCmd(['restore'] + [path], timeout, retries) 341 self._RunDeviceAdbCmd(['restore'] + [path], timeout, retries)
336 342
337 def WaitForDevice(self, timeout=60*5, retries=_DEFAULT_RETRIES): 343 def WaitForDevice(self, timeout=60*5, retries=_DEFAULT_RETRIES):
338 """Block until the device is online. 344 """Block until the device is online.
339 345
340 Args: 346 Args:
341 timeout: (optional) Timeout per try in seconds. 347 timeout: (optional) Timeout per try in seconds.
342 retries: (optional) Number of retries to attempt. 348 retries: (optional) Number of retries to attempt.
343 """ 349 """
344 self._DeviceAdbCmd(['wait-for-device'], timeout, retries) 350 self._RunDeviceAdbCmd(['wait-for-device'], timeout, retries)
345 351
346 def GetState(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 352 def GetState(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
347 """Get device state. 353 """Get device state.
348 354
349 Args: 355 Args:
350 timeout: (optional) Timeout per try in seconds. 356 timeout: (optional) Timeout per try in seconds.
351 retries: (optional) Number of retries to attempt. 357 retries: (optional) Number of retries to attempt.
352 358
353 Returns: 359 Returns:
354 One of 'offline', 'bootloader', or 'device'. 360 One of 'offline', 'bootloader', or 'device'.
355 """ 361 """
356 return self._DeviceAdbCmd(['get-state'], timeout, retries).strip() 362 return self._RunDeviceAdbCmd(['get-state'], timeout, retries).strip()
357 363
358 def GetDevPath(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 364 def GetDevPath(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
359 """Gets the device path. 365 """Gets the device path.
360 366
361 Args: 367 Args:
362 timeout: (optional) Timeout per try in seconds. 368 timeout: (optional) Timeout per try in seconds.
363 retries: (optional) Number of retries to attempt. 369 retries: (optional) Number of retries to attempt.
364 370
365 Returns: 371 Returns:
366 The device path (e.g. usb:3-4) 372 The device path (e.g. usb:3-4)
367 """ 373 """
368 return self._DeviceAdbCmd(['get-devpath'], timeout, retries) 374 return self._RunDeviceAdbCmd(['get-devpath'], timeout, retries)
369 375
370 def Remount(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 376 def Remount(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
371 """Remounts the /system partition on the device read-write.""" 377 """Remounts the /system partition on the device read-write."""
372 self._DeviceAdbCmd(['remount'], timeout, retries) 378 self._RunDeviceAdbCmd(['remount'], timeout, retries)
373 379
374 def Reboot(self, to_bootloader=False, timeout=60*5, 380 def Reboot(self, to_bootloader=False, timeout=60*5,
375 retries=_DEFAULT_RETRIES): 381 retries=_DEFAULT_RETRIES):
376 """Reboots the device. 382 """Reboots the device.
377 383
378 Args: 384 Args:
379 to_bootloader: (optional) If set reboots to the bootloader. 385 to_bootloader: (optional) If set reboots to the bootloader.
380 timeout: (optional) Timeout per try in seconds. 386 timeout: (optional) Timeout per try in seconds.
381 retries: (optional) Number of retries to attempt. 387 retries: (optional) Number of retries to attempt.
382 """ 388 """
383 if to_bootloader: 389 if to_bootloader:
384 cmd = ['reboot-bootloader'] 390 cmd = ['reboot-bootloader']
385 else: 391 else:
386 cmd = ['reboot'] 392 cmd = ['reboot']
387 self._DeviceAdbCmd(cmd, timeout, retries) 393 self._RunDeviceAdbCmd(cmd, timeout, retries)
388 394
389 def Root(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): 395 def Root(self, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
390 """Restarts the adbd daemon with root permissions, if possible. 396 """Restarts the adbd daemon with root permissions, if possible.
391 397
392 Args: 398 Args:
393 timeout: (optional) Timeout per try in seconds. 399 timeout: (optional) Timeout per try in seconds.
394 retries: (optional) Number of retries to attempt. 400 retries: (optional) Number of retries to attempt.
395 """ 401 """
396 output = self._DeviceAdbCmd(['root'], timeout, retries) 402 output = self._RunDeviceAdbCmd(['root'], timeout, retries)
397 if 'cannot' in output: 403 if 'cannot' in output:
398 raise device_errors.AdbCommandFailedError(['root'], output) 404 raise device_errors.AdbCommandFailedError(
399 405 ['root'], output, device_serial=self._device_serial)
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698