| OLD | NEW |
| 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 start and stop Android emulator. | 5 """Provides an interface to start and stop Android emulator. |
| 6 | 6 |
| 7 Emulator: The class provides the methods to launch/shutdown the emulator with | 7 Emulator: The class provides the methods to launch/shutdown the emulator with |
| 8 the android virtual device named 'avd_armeabi' . | 8 the android virtual device named 'avd_armeabi' . |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 def ConfirmLaunch(self, wait_for_boot=False): | 387 def ConfirmLaunch(self, wait_for_boot=False): |
| 388 """Confirm the emulator launched properly. | 388 """Confirm the emulator launched properly. |
| 389 | 389 |
| 390 Loop on a wait-for-device with a very small timeout. On each | 390 Loop on a wait-for-device with a very small timeout. On each |
| 391 timeout, check the emulator process is still alive. | 391 timeout, check the emulator process is still alive. |
| 392 After confirming a wait-for-device can be successful, make sure | 392 After confirming a wait-for-device can be successful, make sure |
| 393 it returns the right answer. | 393 it returns the right answer. |
| 394 """ | 394 """ |
| 395 seconds_waited = 0 | 395 seconds_waited = 0 |
| 396 number_of_waits = 2 # Make sure we can wfd twice | 396 number_of_waits = 2 # Make sure we can wfd twice |
| 397 # TODO(jbudorick) Un-handroll this in the implementation switch. |
| 397 adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device') | 398 adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device') |
| 398 while seconds_waited < self._LAUNCH_TIMEOUT: | 399 while seconds_waited < self._LAUNCH_TIMEOUT: |
| 399 try: | 400 try: |
| 400 run_command.RunCommand(adb_cmd, | 401 run_command.RunCommand(adb_cmd, |
| 401 timeout_time=self._WAITFORDEVICE_TIMEOUT, | 402 timeout_time=self._WAITFORDEVICE_TIMEOUT, |
| 402 retry_count=1) | 403 retry_count=1) |
| 403 number_of_waits -= 1 | 404 number_of_waits -= 1 |
| 404 if not number_of_waits: | 405 if not number_of_waits: |
| 405 break | 406 break |
| 406 except errors.WaitForResponseTimedOutError: | 407 except errors.WaitForResponseTimedOutError: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 434 logging.critical('emulator _ShutdownOnSignal') | 435 logging.critical('emulator _ShutdownOnSignal') |
| 435 for sig in self._SIGNALS: | 436 for sig in self._SIGNALS: |
| 436 signal.signal(sig, signal.SIG_DFL) | 437 signal.signal(sig, signal.SIG_DFL) |
| 437 self.Shutdown() | 438 self.Shutdown() |
| 438 raise KeyboardInterrupt # print a stack | 439 raise KeyboardInterrupt # print a stack |
| 439 | 440 |
| 440 def _InstallKillHandler(self): | 441 def _InstallKillHandler(self): |
| 441 """Install a handler to kill the emulator when we exit unexpectedly.""" | 442 """Install a handler to kill the emulator when we exit unexpectedly.""" |
| 442 for sig in self._SIGNALS: | 443 for sig in self._SIGNALS: |
| 443 signal.signal(sig, self._ShutdownOnSignal) | 444 signal.signal(sig, self._ShutdownOnSignal) |
| OLD | NEW |