summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/android/pylib/utils/emulator.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py
index 0d66b8d..41b675f 100644
--- a/build/android/pylib/utils/emulator.py
+++ b/build/android/pylib/utils/emulator.py
@@ -27,12 +27,14 @@ DEFAULT_SDCARD_SIZE = '512M'
# Default internal storage (MB) of emulator image
DEFAULT_STORAGE_SIZE = '1024M'
-# Each emulator has 60 secs of wait time for launching
-BOOT_WAIT_INTERVALS = 6
-BOOT_WAIT_INTERVAL_TIME = 10
+# Each emulator has 30 secs of wait time for launching
+_BOOT_WAIT_INTERVALS = 3
+_BOOT_WAIT_INTERVAL_TIME = 10
# Path for avd files and avd dir
-BASE_AVD_DIR = os.path.expanduser(os.path.join('~', '.android', 'avd'))
+_BASE_AVD_DIR = os.path.expanduser(os.path.join('~', '.android', 'avd'))
+_TOOLS_ANDROID_PATH = os.path.join(constants.ANDROID_SDK_ROOT,
+ 'tools', 'android')
# Template used to generate config.ini files for the emulator
CONFIG_TEMPLATE = """avd.ini.encoding=ISO-8859-1
@@ -98,7 +100,7 @@ def WaitForEmulatorLaunch(num):
Arg:
num: the amount of emulators to wait.
"""
- for _ in range(num*BOOT_WAIT_INTERVALS):
+ for _ in range(num*_BOOT_WAIT_INTERVALS):
emulators = [device_utils.DeviceUtils(a)
for a in adb_wrapper.AdbWrapper.Devices()
if a.is_emulator]
@@ -106,9 +108,9 @@ def WaitForEmulatorLaunch(num):
logging.info('All %d emulators launched', num)
return
logging.info(
- 'Waiting for %d emulators, %d of them launched: [%s], ',
- num, len(emulators), ' '.join([str(x) for x in emulators]))
- time.sleep(BOOT_WAIT_INTERVAL_TIME)
+ 'Waiting for %d emulators, %d of them already launched', num,
+ len(emulators))
+ time.sleep(_BOOT_WAIT_INTERVAL_TIME)
raise Exception("Expected %d emulators, %d launched within time limit" %
(num, len(emulators)))
@@ -146,7 +148,7 @@ def DeleteAllTempAVDs():
return
for avd_name in avds:
if 'run_tests_avd' in avd_name:
- cmd = ['android', '-s', 'delete', 'avd', '--name', avd_name]
+ cmd = [_TOOLS_ANDROID_PATH, '-s', 'delete', 'avd', '--name', avd_name]
cmd_helper.RunCmd(cmd)
logging.info('Delete AVD %s', avd_name)
@@ -285,7 +287,7 @@ class Emulator(object):
"""
android_sdk_root = constants.ANDROID_SDK_ROOT
self.emulator = os.path.join(android_sdk_root, 'tools', 'emulator')
- self.android = os.path.join(android_sdk_root, 'tools', 'android')
+ self.android = _TOOLS_ANDROID_PATH
self.popen = None
self.device_serial = None
self.abi = abi
@@ -339,8 +341,8 @@ class Emulator(object):
avd_process.expect('Created AVD \'%s\'' % self.avd_name)
# Replace current configuration with default Galaxy Nexus config.
- ini_file = os.path.join(BASE_AVD_DIR, '%s.ini' % self.avd_name)
- new_config_ini = os.path.join(BASE_AVD_DIR, '%s.avd' % self.avd_name,
+ ini_file = os.path.join(_BASE_AVD_DIR, '%s.ini' % self.avd_name)
+ new_config_ini = os.path.join(_BASE_AVD_DIR, '%s.avd' % self.avd_name,
'config.ini')
# Remove config files with defaults to replace with Google's GN settings.
@@ -351,7 +353,7 @@ class Emulator(object):
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' % (BASE_AVD_DIR, self.avd_name))
+ new_ini.write('path=%s/%s.avd\n' % (_BASE_AVD_DIR, self.avd_name))
new_ini.write('path.rel=avd/%s.avd\n' % self.avd_name)
custom_config = CONFIG_TEMPLATE
@@ -385,9 +387,9 @@ class Emulator(object):
This serves as a work around for '-partition-size' and '-wipe-data'
"""
- userdata_img = os.path.join(BASE_AVD_DIR, '%s.avd' % self.avd_name,
+ userdata_img = os.path.join(_BASE_AVD_DIR, '%s.avd' % self.avd_name,
'userdata.img')
- userdata_qemu_img = os.path.join(BASE_AVD_DIR, '%s.avd' % self.avd_name,
+ userdata_qemu_img = os.path.join(_BASE_AVD_DIR, '%s.avd' % self.avd_name,
'userdata-qemu.img')
resize_cmd = ['resize2fs', userdata_img, '%s' % storage_size]
logging.info('Resizing userdata.img to ideal size')