Skip to content

Commit

Permalink
Timeout for emulator boot
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed May 8, 2024
1 parent 1a1d600 commit 01c9757
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions emulator-run-cmd/src/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class Emulator {
async waitForBoot(timeout: number): Promise<boolean> {
for (let countdown = timeout; countdown > 0; countdown--) {
if (countdown == 0) {
console.error("Timeout waiting for the emulator")
console.error("EMU Timeout waiting for the emulator " + timeout)
return false
}
try {
let output = await this.execAdbCommand("shell getprop sys.boot_completed")
if (output.trim() == '1') {
console.log("EMU Emulator booted " + (timeout - countdown) + "s")
countdown = 0
console.log("Emulator booted")
return true
}
} catch (e) {
Expand All @@ -60,11 +60,11 @@ export class Emulator {
}
}

console.log("Sleeping for 1s")
await sleep(1000)
countdown--
console.log("EMU Sleeping for 1s " + (timeout - countdown) + "s")
}
console.log("Timeout waiting for emulator to boot. Exiting")
console.log("EMU Timeout waiting for emulator to boot. Exiting")
return false
}

Expand Down
8 changes: 4 additions & 4 deletions install-sdk/src/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class Emulator {
async waitForBoot(timeout: number): Promise<boolean> {
for (let countdown = timeout; countdown > 0; countdown--) {
if (countdown == 0) {
console.error("Timeout waiting for the emulator")
console.error("SDK Timeout waiting for the emulator " + timeout)
return false
}
try {
let output = await this.execAdbCommand("shell getprop sys.boot_completed")
if (output.trim() == '1') {
console.log("SDK Emulator booted " + (timeout - countdown) + "s")
countdown = 0
console.log("Emulator booted")
return true
}
} catch (e) {
Expand All @@ -60,11 +60,11 @@ export class Emulator {
}
}

console.log("Sleeping for 1s")
await sleep(1000)
countdown--
console.log("SDK Sleeping for 1s " + (timeout - countdown) + "s")
}
console.log("Timeout waiting for emulator to boot. Exiting")
console.log("SDK Timeout waiting for emulator to boot. Exiting")
return false
}

Expand Down

0 comments on commit 01c9757

Please sign in to comment.