summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authornavabi@google.com <navabi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 01:55:31 +0000
committernavabi@google.com <navabi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 01:55:31 +0000
commit4dc4aeae2ccf360592b6f1f63d0af9271895111d (patch)
tree4a69ca2f62fb5dfc62593e96074a2fb82a92ac81 /build
parentdda09bb85b5edff392b47ba48e464295afda4612 (diff)
downloadchromium_src-4dc4aeae2ccf360592b6f1f63d0af9271895111d.zip
chromium_src-4dc4aeae2ccf360592b6f1f63d0af9271895111d.tar.gz
chromium_src-4dc4aeae2ccf360592b6f1f63d0af9271895111d.tar.bz2
Fix AVD configuration and defaults based on dogfooder input.
I have worked with a couple developers to dogfood the installation and running of AVD's using the build/android scripts. The following suggestions have been taken are are implemented by this change: - Use configuration of AVD for Galaxy Nexus by Google as default config - allows developers to use software keyboard - uses the Galaxy Nexus skin with Back/Home/Apps buttons at bottom - Defaults (one x86 AVD) are printed on the help page - Does not require virtualization support for ARM emulator (only x86) BUG=164911 Review URL: https://chromiumcodereview.appspot.com/13543008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/avd.py16
-rw-r--r--build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_arm.avd/config.ini30
-rw-r--r--build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_x86.avd/config.ini29
-rwxr-xr-xbuild/android/install_emulator_deps.py4
-rwxr-xr-xbuild/android/pylib/utils/emulator.py65
5 files changed, 118 insertions, 26 deletions
diff --git a/build/android/avd.py b/build/android/avd.py
index c9da30f..2685c59 100755
--- a/build/android/avd.py
+++ b/build/android/avd.py
@@ -23,20 +23,18 @@ from pylib.utils import emulator
def main(argv):
# ANDROID_SDK_ROOT needs to be set to the location of the SDK used to launch
# the emulator to find the system images upon launch.
- emulator_sdk = os.path.join(constants.EMULATOR_SDK_ROOT, 'android_tools',
- 'sdk')
+ emulator_sdk = os.path.join(constants.EMULATOR_SDK_ROOT,
+ 'android_tools', 'sdk')
os.environ['ANDROID_SDK_ROOT'] = emulator_sdk
opt_parser = optparse.OptionParser(description='AVD script.')
opt_parser.add_option('-n', '--num', dest='emulator_count',
- help='Number of emulators to launch.',
+ help='Number of emulators to launch (default is 1).',
type='int', default='1')
- opt_parser.add_option('--abi', default='arm',
- help='Platform of emulators to launch.')
+ opt_parser.add_option('--abi', default='x86',
+ help='Platform of emulators to launch (x86 default).')
options, _ = opt_parser.parse_args(argv[1:])
- if options.abi == 'arm':
- options.abi = 'armeabi-v7a'
logging.basicConfig(level=logging.INFO,
format='# %(asctime)-15s: %(message)s')
@@ -45,8 +43,8 @@ def main(argv):
# Check if KVM is enabled for x86 AVD's and check for x86 system images.
if options.abi =='x86':
if not install_emulator_deps.CheckKVM():
- logging.critical('ERROR: KVM must be enabled in BIOS, and installed. Run '
- 'install_emulator_deps.py')
+ logging.critical('ERROR: KVM must be enabled in BIOS, and installed. '
+ 'Enable KVM in BIOS and run install_emulator_deps.py')
return 1
elif not install_emulator_deps.CheckX86Image():
logging.critical('ERROR: System image for x86 AVD not installed. Run '
diff --git a/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_arm.avd/config.ini b/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_arm.avd/config.ini
new file mode 100644
index 0000000..27f196f
--- /dev/null
+++ b/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_arm.avd/config.ini
@@ -0,0 +1,30 @@
+avd.ini.encoding=ISO-8859-1
+hw.dPad=no
+hw.lcd.density=320
+sdcard.size=512M
+hw.cpu.arch=arm
+hw.device.hash=-708107041
+hw.camera.back=none
+disk.dataPartition.size=200M
+hw.gpu.enabled=yes
+skin.dynamic=yes
+skin.path=720x1280
+hw.keyboard=yes
+hw.cpu.model=cortex-a8
+hw.ramSize=1024
+hw.device.manufacturer=Google
+hw.sdCard=yes
+hw.mainKeys=no
+hw.accelerometer=yes
+skin.name=720x1280
+abi.type=armeabi-v7a
+hw.trackBall=no
+hw.device.name=Galaxy Nexus
+hw.battery=yes
+hw.sensors.proximity=yes
+image.sysdir.1=system-images/android-17/armeabi-v7a/
+hw.sensors.orientation=yes
+hw.audioInput=yes
+hw.camera.front=none
+hw.gps=yes
+vm.heapSize=128
diff --git a/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_x86.avd/config.ini b/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_x86.avd/config.ini
new file mode 100644
index 0000000..36a8e8c
--- /dev/null
+++ b/build/android/avd_configs/AVD_for_Galaxy_Nexus_by_Google_x86.avd/config.ini
@@ -0,0 +1,29 @@
+avd.ini.encoding=ISO-8859-1
+hw.dPad=no
+hw.lcd.density=320
+sdcard.size=512M
+hw.cpu.arch=x86
+hw.device.hash=-708107041
+hw.camera.back=none
+disk.dataPartition.size=200M
+hw.gpu.enabled=yes
+skin.path=720x1280
+skin.dynamic=yes
+hw.keyboard=yes
+hw.ramSize=1024
+hw.device.manufacturer=Google
+hw.sdCard=yes
+hw.mainKeys=no
+hw.accelerometer=yes
+skin.name=720x1280
+abi.type=x86
+hw.trackBall=no
+hw.device.name=Galaxy Nexus
+hw.battery=yes
+hw.sensors.proximity=yes
+image.sysdir.1=system-images/android-17/x86/
+hw.sensors.orientation=yes
+hw.audioInput=yes
+hw.camera.front=none
+hw.gps=yes
+vm.heapSize=128
diff --git a/build/android/install_emulator_deps.py b/build/android/install_emulator_deps.py
index bb544c2..c7445a1 100755
--- a/build/android/install_emulator_deps.py
+++ b/build/android/install_emulator_deps.py
@@ -13,7 +13,6 @@ install and enable KVM, if virtualization has been enabled in the BIOS.
import logging
import os
import shutil
-import subprocess
import sys
from pylib import cmd_helper
@@ -62,6 +61,7 @@ def CheckKVM():
try:
return not cmd_helper.RunCmd(['kvm-ok'])
except OSError:
+ logging.info('kvm-ok not installed')
return False
@@ -133,6 +133,8 @@ def main(argv):
else:
GetSDK()
+ logging.info('Emulator deps for ARM emulator complete.')
+
if CheckX86Image():
logging.info('system-images directory already exists.')
else:
diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py
index d2943549..535be20 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
@@ -24,6 +25,7 @@ import time_profile
from pylib import android_commands
from pylib import cmd_helper
from pylib import constants
+from pylib import pexpect
import errors
import run_command
@@ -47,7 +49,7 @@ def _KillAllEmulators():
if not emulators:
return
for emu_name in emulators:
- cmd_helper.GetCmdOutput(['adb', '-s', emu_name, 'emu', 'kill'])
+ cmd_helper.RunCmd(['adb', '-s', emu_name, 'emu', 'kill'])
logging.info('Emulator killing is async; give a few seconds for all to die.')
for i in range(5):
if not android_commands.GetEmulators():
@@ -67,7 +69,7 @@ def DeleteAllTempAVDs():
for avd_name in avds:
if 'run_tests_avd' in avd_name:
cmd = ['android', '-s', 'delete', 'avd', '--name', avd_name]
- cmd_helper.GetCmdOutput(cmd)
+ cmd_helper.RunCmd(cmd)
logging.info('Delete AVD %s' % avd_name)
@@ -160,7 +162,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 +189,58 @@ 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()
- logging.info('Create AVD command: %s', ' '.join(avd_command))
+ avd_cmd_str = ' '.join(avd_command)
+ logging.info('Create AVD command: %s', avd_cmd_str)
+ avd_process = pexpect.spawn(avd_cmd_str)
+
+ # Instead of creating a custom profile, we overwrite config files.
+ avd_process.expect('Do you wish to create a custom hardware profile')
+ avd_process.sendline('no\n')
+ avd_process.expect('Created AVD \'%s\'' % self.avd_name)
+
+ # 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 config files with defaults to replace with Google's GN settings.
+ 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 = [
@@ -215,11 +250,9 @@ class Emulator(object):
'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.RunCmd(avd_command)
+
def Launch(self, kill_all_emulators):
"""Launches the emulator asynchronously. Call ConfirmLaunch() to ensure the