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

Side by Side Diff: build/android/pylib/utils/emulator.py

Issue 1092703002: [Android] More old_interface conversions in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perezju comments Created 5 years, 8 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 | « build/android/pylib/monkey/test_runner.py ('k') | no next file » | 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 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
11 import logging 11 import logging
12 import os 12 import os
13 import signal 13 import signal
14 import subprocess 14 import subprocess
15 import time 15 import time
16 16
17 # TODO(craigdh): Move these pylib dependencies to pylib/utils/. 17 # TODO(craigdh): Move these pylib dependencies to pylib/utils/.
18 from pylib import android_commands 18 from pylib import android_commands
19 from pylib import cmd_helper 19 from pylib import cmd_helper
20 from pylib import constants 20 from pylib import constants
21 from pylib import pexpect 21 from pylib import pexpect
22 from pylib.device import device_errors
22 from pylib.device import device_utils 23 from pylib.device import device_utils
23 from pylib.utils import time_profile 24 from pylib.utils import time_profile
24 25
25 import errors 26 import errors
26 import run_command 27 import run_command
27 28
28 # SD card size 29 # SD card size
29 SDCARD_SIZE = '512M' 30 SDCARD_SIZE = '512M'
30 31
31 # Template used to generate config.ini files for the emulator 32 # Template used to generate config.ini files for the emulator
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 def ConfirmLaunch(self, wait_for_boot=False): 388 def ConfirmLaunch(self, wait_for_boot=False):
388 """Confirm the emulator launched properly. 389 """Confirm the emulator launched properly.
389 390
390 Loop on a wait-for-device with a very small timeout. On each 391 Loop on a wait-for-device with a very small timeout. On each
391 timeout, check the emulator process is still alive. 392 timeout, check the emulator process is still alive.
392 After confirming a wait-for-device can be successful, make sure 393 After confirming a wait-for-device can be successful, make sure
393 it returns the right answer. 394 it returns the right answer.
394 """ 395 """
395 seconds_waited = 0 396 seconds_waited = 0
396 number_of_waits = 2 # Make sure we can wfd twice 397 number_of_waits = 2 # Make sure we can wfd twice
397 # TODO(jbudorick) Un-handroll this in the implementation switch. 398
398 adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device') 399 device = device_utils.DeviceUtils(self.device_serial)
399 while seconds_waited < self._LAUNCH_TIMEOUT: 400 while seconds_waited < self._LAUNCH_TIMEOUT:
400 try: 401 try:
401 run_command.RunCommand(adb_cmd, 402 device.adb.WaitForDevice(
402 timeout_time=self._WAITFORDEVICE_TIMEOUT, 403 timeout=self._WAITFORDEVICE_TIMEOUT, retries=1)
403 retry_count=1)
404 number_of_waits -= 1 404 number_of_waits -= 1
405 if not number_of_waits: 405 if not number_of_waits:
406 break 406 break
407 except errors.WaitForResponseTimedOutError: 407 except device_errors.CommandTimeoutError:
408 seconds_waited += self._WAITFORDEVICE_TIMEOUT 408 seconds_waited += self._WAITFORDEVICE_TIMEOUT
409 adb_cmd = "adb -s %s %s" % (self.device_serial, 'kill-server') 409 device.adb.KillServer()
410 run_command.RunCommand(adb_cmd)
411 self.popen.poll() 410 self.popen.poll()
412 if self.popen.returncode != None: 411 if self.popen.returncode != None:
413 raise EmulatorLaunchException('EMULATOR DIED') 412 raise EmulatorLaunchException('EMULATOR DIED')
413
414 if seconds_waited >= self._LAUNCH_TIMEOUT: 414 if seconds_waited >= self._LAUNCH_TIMEOUT:
415 raise EmulatorLaunchException('TIMEOUT with wait-for-device') 415 raise EmulatorLaunchException('TIMEOUT with wait-for-device')
416
416 logging.info('Seconds waited on wait-for-device: %d', seconds_waited) 417 logging.info('Seconds waited on wait-for-device: %d', seconds_waited)
417 if wait_for_boot: 418 if wait_for_boot:
418 # Now that we checked for obvious problems, wait for a boot complete. 419 # Now that we checked for obvious problems, wait for a boot complete.
419 # Waiting for the package manager is sometimes problematic. 420 # Waiting for the package manager is sometimes problematic.
420 # TODO(jbudorick) Convert this once waiting for the package manager and 421 device.WaitUntilFullyBooted(timeout=self._WAITFORBOOT_TIMEOUT)
421 # the external storage is no longer problematic.
422 d = device_utils.DeviceUtils(self.device_serial)
423 d.old_interface.WaitForSystemBootCompleted(self._WAITFORBOOT_TIMEOUT)
424 422
425 def Shutdown(self): 423 def Shutdown(self):
426 """Shuts down the process started by launch.""" 424 """Shuts down the process started by launch."""
427 self._DeleteAVD() 425 self._DeleteAVD()
428 if self.popen: 426 if self.popen:
429 self.popen.poll() 427 self.popen.poll()
430 if self.popen.returncode == None: 428 if self.popen.returncode == None:
431 self.popen.kill() 429 self.popen.kill()
432 self.popen = None 430 self.popen = None
433 431
434 def _ShutdownOnSignal(self, _signum, _frame): 432 def _ShutdownOnSignal(self, _signum, _frame):
435 logging.critical('emulator _ShutdownOnSignal') 433 logging.critical('emulator _ShutdownOnSignal')
436 for sig in self._SIGNALS: 434 for sig in self._SIGNALS:
437 signal.signal(sig, signal.SIG_DFL) 435 signal.signal(sig, signal.SIG_DFL)
438 self.Shutdown() 436 self.Shutdown()
439 raise KeyboardInterrupt # print a stack 437 raise KeyboardInterrupt # print a stack
440 438
441 def _InstallKillHandler(self): 439 def _InstallKillHandler(self):
442 """Install a handler to kill the emulator when we exit unexpectedly.""" 440 """Install a handler to kill the emulator when we exit unexpectedly."""
443 for sig in self._SIGNALS: 441 for sig in self._SIGNALS:
444 signal.signal(sig, self._ShutdownOnSignal) 442 signal.signal(sig, self._ShutdownOnSignal)
OLDNEW
« no previous file with comments | « build/android/pylib/monkey/test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698