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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 375973002: Allow provision_devices to work on the L-release preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jbudorick comments Created 6 years, 5 months 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 | « no previous file | third_party/android_testrunner/README.chromium » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 # pylint: disable-all 9 # pylint: disable-all
10 10
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 def GetExternalStorage(self): 388 def GetExternalStorage(self):
389 if not self._external_storage: 389 if not self._external_storage:
390 self._external_storage = self.RunShellCommand('echo $EXTERNAL_STORAGE')[0] 390 self._external_storage = self.RunShellCommand('echo $EXTERNAL_STORAGE')[0]
391 if not self._external_storage: 391 if not self._external_storage:
392 raise device_errors.CommandFailedError( 392 raise device_errors.CommandFailedError(
393 ['shell', "'echo $EXTERNAL_STORAGE'"], 393 ['shell', "'echo $EXTERNAL_STORAGE'"],
394 'Unable to find $EXTERNAL_STORAGE') 394 'Unable to find $EXTERNAL_STORAGE')
395 return self._external_storage 395 return self._external_storage
396 396
397 def WaitForDevicePm(self): 397 def WaitForDevicePm(self, timeout=120):
398 """Blocks until the device's package manager is available. 398 """Blocks until the device's package manager is available.
399 399
400 To workaround http://b/5201039, we restart the shell and retry if the 400 To workaround http://b/5201039, we restart the shell and retry if the
401 package manager isn't back after 120 seconds. 401 package manager isn't back after 120 seconds.
402 402
403 Raises: 403 Raises:
404 errors.WaitForResponseTimedOutError after max retries reached. 404 errors.WaitForResponseTimedOutError after max retries reached.
405 """ 405 """
406 last_err = None 406 last_err = None
407 retries = 3 407 retries = 3
408 while retries: 408 while retries:
409 try: 409 try:
410 self._adb.WaitForDevicePm() 410 self._adb.WaitForDevicePm(wait_time=timeout)
411 return # Success 411 return # Success
412 except errors.WaitForResponseTimedOutError as e: 412 except errors.WaitForResponseTimedOutError as e:
413 last_err = e 413 last_err = e
414 logging.warning('Restarting and retrying after timeout: %s', e) 414 logging.warning('Restarting and retrying after timeout: %s', e)
415 retries -= 1 415 retries -= 1
416 self.RestartShell() 416 self.RestartShell()
417 raise last_err # Only reached after max retries, re-raise the last error. 417 raise last_err # Only reached after max retries, re-raise the last error.
418 418
419 def RestartShell(self): 419 def RestartShell(self):
420 """Restarts the shell on the device. Does not block for it to return.""" 420 """Restarts the shell on the device. Does not block for it to return."""
(...skipping 18 matching lines...) Expand all
439 retries = 1 439 retries = 1
440 # Wait for the device to disappear. 440 # Wait for the device to disappear.
441 while retries < 10 and self.IsOnline(): 441 while retries < 10 and self.IsOnline():
442 time.sleep(1) 442 time.sleep(1)
443 retries += 1 443 retries += 1
444 else: 444 else:
445 self.RestartShell() 445 self.RestartShell()
446 timeout = 120 446 timeout = 120
447 # To run tests we need at least the package manager and the sd card (or 447 # To run tests we need at least the package manager and the sd card (or
448 # other external storage) to be ready. 448 # other external storage) to be ready.
449 self.WaitForDevicePm() 449 self.WaitForDevicePm(timeout)
450 self.WaitForSdCardReady(timeout) 450 self.WaitForSdCardReady(timeout)
451 451
452 def Shutdown(self): 452 def Shutdown(self):
453 """Shuts down the device.""" 453 """Shuts down the device."""
454 self._adb.SendCommand('reboot -p') 454 self._adb.SendCommand('reboot -p')
455 self._system_properties = system_properties.SystemProperties(self.Adb()) 455 self._system_properties = system_properties.SystemProperties(self.Adb())
456 456
457 def Uninstall(self, package): 457 def Uninstall(self, package):
458 """Uninstalls the specified package from the device. 458 """Uninstalls the specified package from the device.
459 459
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 """ 1968 """
1969 def __init__(self, output): 1969 def __init__(self, output):
1970 self._output = output 1970 self._output = output
1971 1971
1972 def write(self, data): 1972 def write(self, data):
1973 data = data.replace('\r\r\n', '\n') 1973 data = data.replace('\r\r\n', '\n')
1974 self._output.write(data) 1974 self._output.write(data)
1975 1975
1976 def flush(self): 1976 def flush(self):
1977 self._output.flush() 1977 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | third_party/android_testrunner/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698