Add support for providing any emulator launch options as action input. Remove headless input which might overlap with emulator-options.

This commit is contained in:
Yang Chen
2019-12-07 17:48:02 +11:00
committed by ychescale9
parent 0d46bc07bd
commit 0d276b963a
10 changed files with 50 additions and 69 deletions
+11 -4
View File
@@ -22,7 +22,7 @@ const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`;
/**
* Creates and launches a new AVD instance with the specified configurations.
*/
function launchEmulator(apiLevel, target, arch, profile, headless, disableAnimations) {
function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations) {
return __awaiter(this, void 0, void 0, function* () {
// create a new AVD
if (profile.trim() !== '') {
@@ -35,8 +35,15 @@ function launchEmulator(apiLevel, target, arch, profile, headless, disableAnimat
}
// start emulator
console.log('Starting emulator.');
const noWindow = headless ? '-no-window' : '';
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${noWindow} -no-snapshot -noaudio -no-boot-anim &"`);
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], {
listeners: {
stderr: (data) => {
if (data.toString().includes('invalid command-line parameter')) {
throw new Error(data.toString());
}
}
}
});
// wait for emulator to complete booting
yield waitForDevice();
yield exec.exec(`${ADB_PATH} shell input keyevent 82`);
@@ -91,7 +98,7 @@ function waitForDevice() {
}
}
catch (error) {
console.error(error.message);
console.log(error.message);
}
if (attempts < maxAttemps) {
yield delay(retryInterval * 1000);