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..558d54c0c621e3d4700b8c71ee062bb7e4496f89 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,14 +188,19 @@ 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, |
@@ -203,7 +209,35 @@ class Emulator(object): |
stderr=subprocess.STDOUT) |
avd_process.stdin.write('no\n') |
avd_process.wait() |
frankf
2013/04/05 21:05:48
This can cause a deadlock. Don't call subprocess d
navabi
2013/04/08 21:41:56
I can change the others, but in this case, we have
Isaac (away)
2013/04/08 21:45:52
I'm not sure this can cause deadlock, but what abo
navabi
2013/04/08 22:04:51
Done.
cjhopman
2013/04/09 00:17:26
Search for "deadlock" at http://docs.python.org/2/
|
+ |
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_ini = os.path.join(avd_config_dir, |
+ 'AVD_for_Galaxy_Nexus_by_Google_%s.ini' % |
pasko-google - do not use
2013/04/05 09:41:05
spacing nit:
align under the previous argument
navabi
2013/04/08 21:41:56
Done.
|
+ self.abi) |
+ 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') |
+ new_ini = 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') |
+ |
+ os.unlink(new_ini) |
+ os.unlink(new_config_ini) |
+ shutil.copy(avd_ini, new_ini) |
+ shutil.copy(avd_config_ini, new_config_ini) |
+ |
+ replace_sed = 's/AVD_for_Galaxy_Nexus_by_Google_%s/%s/g' % (self.abi, |
+ self.avd_name) |
+ replace_name = subprocess.Popen(['sed', '-i', replace_sed, new_ini]) |
pasko-google - do not use
2013/04/05 09:41:05
Instead of copying, replacing with sed via subproc
nyquist
2013/04/05 20:49:35
And if line-wrapping, etc. becomes ugly, consider
navabi
2013/04/08 21:41:56
Done.
|
+ replace_name.wait() |
+ |
return self.avd_name |
def _DeleteAVD(self): |