Commit c86b2fc3 authored by Haiyang Pan's avatar Haiyang Pan Committed by Commit Bot

emulator: edit config.ini instead of hardware-qemu.ini during avd Install.

This fixes sdcard mounting and avd fastboot.

Emulator reads config.ini for the configuration, not hardware-qemu.ini.
(The latter one is auto-generated and gets updated when applicable.)

Also, change made to hardware-qemu.ini could invalidate the snapshot and leads
to a cold boot, which is not desired.
It is because emulator will not use the quickboot snapshot unless
hardware-qemu.ini and hardware.ini from quickboot snapshot are equal

Bug: 922145, 1057811
Change-Id: Ie913e907148e64fcc7ba4188529578b739fa1f3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153762Reviewed-by: default avatarBen Pastene <bpastene@chromium.org>
Commit-Queue: Haiyang Pan <hypan@google.com>
Cr-Commit-Position: refs/heads/master@{#759901}
parent 08aa981d
......@@ -403,14 +403,14 @@ class AvdConfig(object):
android_avd_home = os.path.join(self._emulator_home, 'avd')
avd_dir = os.path.join(android_avd_home, '%s.avd' % self._config.avd_name)
hardware_qemu_path = os.path.join(avd_dir, 'hardware-qemu.ini')
if os.path.exists(hardware_qemu_path):
with open(hardware_qemu_path) as hardware_qemu_file:
hardware_qemu_contents = ini.load(hardware_qemu_file)
config_path = os.path.join(avd_dir, 'config.ini')
if os.path.exists(config_path):
with open(config_path) as config_file:
config_contents = ini.load(config_file)
else:
hardware_qemu_contents = {}
config_contents = {}
hardware_qemu_contents['hw.sdCard'] = 'true'
config_contents['hw.sdCard'] = 'true'
if self._config.avd_settings.sdcard.size:
sdcard_path = os.path.join(avd_dir, 'cr-sdcard.img')
if not os.path.exists(sdcard_path):
......@@ -423,10 +423,10 @@ class AvdConfig(object):
]
cmd_helper.RunCmd(mksdcard_cmd)
hardware_qemu_contents['hw.sdCard.path'] = sdcard_path
config_contents['hw.sdCard.path'] = sdcard_path
with open(hardware_qemu_path, 'w') as hardware_qemu_file:
ini.dump(hardware_qemu_contents, hardware_qemu_file)
with open(config_path, 'w') as config_file:
ini.dump(config_contents, config_file)
def _Initialize(self):
if self._initialized:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment