Chromium Code Reviews| Index: build/android/pylib/utils/emulator.py |
| diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py |
| index df77c52e64654731aa735640700ff520382851a4..2a87582c4ca62182632d8de5c63b6372793515de 100755 |
| --- a/build/android/pylib/utils/emulator.py |
| +++ b/build/android/pylib/utils/emulator.py |
| @@ -14,6 +14,7 @@ Assumes system environment ANDROID_NDK_ROOT has been set. |
| import logging |
| import os |
| +import shutil |
| import signal |
| import subprocess |
| import sys |
| @@ -160,7 +161,7 @@ class Emulator(object): |
| # Time to wait for a "wait for boot complete" (property set on device). |
| _WAITFORBOOT_TIMEOUT = 300 |
| - def __init__(self, avd_name, abi='x86'): |
| + def __init__(self, avd_name, abi): |
| """Init an Emulator. |
| Args: |
| @@ -187,25 +188,55 @@ class Emulator(object): |
| Return avd_name. |
| """ |
| + |
| + if self.abi == 'arm': |
| + abi_option = 'armeabi-v7a' |
| + else: |
| + abi_option = 'x86' |
| + |
| avd_command = [ |
| self.android, |
| '--silent', |
| 'create', 'avd', |
| '--name', self.avd_name, |
| - '--abi', self.abi, |
| + '--abi', abi_option, |
| '--target', API_TARGET, |
| - '-c', '128M', |
| '--force', |
| ] |
| avd_process = subprocess.Popen(args=avd_command, |
| - stdin=subprocess.PIPE, |
| - stdout=subprocess.PIPE, |
| - stderr=subprocess.STDOUT) |
| - avd_process.stdin.write('no\n') |
| - avd_process.wait() |
| + stdin=subprocess.PIPE) |
| + avd_process.communicate('no\n') |
| + |
| logging.info('Create AVD command: %s', ' '.join(avd_command)) |
| + |
| + # Setup test device as default Galaxy Nexus AVD |
| + avd_config_dir = os.path.join(constants.CHROME_DIR, 'build', 'android', |
| + 'avd_configs') |
| + avd_config_ini = os.path.join(avd_config_dir, |
| + 'AVD_for_Galaxy_Nexus_by_Google_%s.avd' % |
| + self.abi, 'config.ini') |
| + |
| + # Replace current configuration with default Galaxy Nexus config. |
| + avds_dir = os.path.join(os.path.expanduser('~'), '.android', 'avd') |
| + ini_file = os.path.join(avds_dir, '%s.ini' % self.avd_name) |
| + new_config_ini = os.path.join(avds_dir, '%s.avd' % self.avd_name, |
| + 'config.ini') |
| + |
| + # Remove non-standard configuration files |
|
pasko-google - do not use
2013/04/09 08:41:45
Why are they non-standard? We rather cleanup befor
navabi
2013/04/09 16:46:51
"non-standard" is not the correct phrasing. The co
|
| + os.unlink(ini_file) |
| + os.unlink(new_config_ini) |
| + |
| + # Create new configuration files with Galaxy Nexus by Google settings. |
| + with open(ini_file, 'w') as new_ini: |
| + new_ini.write('avd.ini.encoding=ISO-8859-1\n') |
| + new_ini.write('target=%s\n' % API_TARGET) |
| + new_ini.write('path=%s/%s.avd\n' % (avds_dir, self.avd_name)) |
| + new_ini.write('path.rel=avd/%s.avd\n' % self.avd_name) |
| + |
| + shutil.copy(avd_config_ini, new_config_ini) |
| return self.avd_name |
| + |
| def _DeleteAVD(self): |
| """Delete the AVD of this emulator.""" |
| avd_command = [ |
| @@ -213,13 +244,11 @@ class Emulator(object): |
| '--silent', |
| 'delete', |
| 'avd', |
| - '--name', self.avd, |
| + '--name', self.avd_name, |
| ] |
| - avd_process = subprocess.Popen(args=avd_command, |
| - stdout=subprocess.PIPE, |
| - stderr=subprocess.STDOUT) |
| logging.info('Delete AVD command: %s', ' '.join(avd_command)) |
| - avd_process.wait() |
| + cmd_helper.GetCmdOutput(avd_command) |
| + |
| def Launch(self, kill_all_emulators): |
| """Launches the emulator asynchronously. Call ConfirmLaunch() to ensure the |