Add emulator-boot-timeout parameter (#326)

* Add emulator-boot-timeout parameter

* Update action-types.yml
This commit is contained in:
Dmitry Koplyarov
2023-03-09 00:44:31 +00:00
committed by GitHub
parent bad4154821
commit 743ec40c5b
6 changed files with 22 additions and 11 deletions
+4 -5
View File
@@ -1,8 +1,6 @@
import * as exec from '@actions/exec';
import * as fs from 'fs';
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
/**
* Creates and launches a new AVD instance with the specified configurations.
*/
@@ -18,6 +16,7 @@ export async function launchEmulator(
diskSize: string,
avdName: string,
forceAvdCreation: boolean,
emulatorBootTimeout: number,
emulatorOptions: string,
disableAnimations: boolean,
disableSpellChecker: boolean,
@@ -77,7 +76,7 @@ export async function launchEmulator(
});
// wait for emulator to complete booting
await waitForDevice();
await waitForDevice(emulatorBootTimeout);
await exec.exec(`adb shell input keyevent 82`);
if (disableAnimations) {
@@ -114,11 +113,11 @@ export async function killEmulator(): Promise<void> {
/**
* Wait for emulator to boot.
*/
async function waitForDevice(): Promise<void> {
async function waitForDevice(emulatorBootTimeout: number): Promise<void> {
let booted = false;
let attempts = 0;
const retryInterval = 2; // retry every 2 seconds
const maxAttempts = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
const maxAttempts = emulatorBootTimeout / 2;
while (!booted) {
try {
let result = '';
+5
View File
@@ -89,6 +89,10 @@ async function run() {
const forceAvdCreation = forceAvdCreationInput === 'true';
console.log(`force avd creation: ${forceAvdCreation}`);
// Emulator boot timeout seconds
const emulatorBootTimeout = parseInt(core.getInput('emulator-boot-timeout'), 10);
console.log(`Emulator boot timeout: ${emulatorBootTimeout}`);
// emulator options
const emulatorOptions = core.getInput('emulator-options').trim();
console.log(`emulator options: ${emulatorOptions}`);
@@ -205,6 +209,7 @@ async function run() {
diskSize,
avdName,
forceAvdCreation,
emulatorBootTimeout,
emulatorOptions,
disableAnimations,
disableSpellchecker,