mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-05 19:39:32 +00:00
Add emulator-boot-timeout parameter (#326)
* Add emulator-boot-timeout parameter * Update action-types.yml
This commit is contained in:
@@ -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 = '';
|
||||
|
||||
Reference in New Issue
Block a user