mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
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:
+11
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user