Skip to content

Commit

Permalink
chore: Perform boot readiness validation via reboot_readiness service…
Browse files Browse the repository at this point in the history
… on API 31+ (appium#659)
  • Loading branch information
mykola-mokhnach committed May 22, 2023
1 parent 1753429 commit c98fbcd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/tools/system-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,27 @@ systemCallMethods.getVersion = _.memoize(async function getVersion () {
* @throws {Error} If the emulator is not ready within the given timeout.
*/
systemCallMethods.waitForEmulatorReady = async function waitForEmulatorReady (timeoutMs = 20000) {
if (await this.getApiLevel() >= 31) {
let reason;
try {
await waitForCondition(async () => {
try {
reason = await this.shell(['cmd', 'reboot_readiness', 'check-subsystems-state', '--list-blocking']);
return _.includes(reason, 'Subsystem state: true');
} catch (err) {
log.debug(`Waiting for emulator startup. Intermediate error: ${err.message}`);
return false;
}
}, {
waitMs: timeoutMs,
intervalMs: 1000,
});
return;
} catch (e) {
throw new Error(`Emulator is not ready within ${timeoutMs}ms${reason ? ('. Reason: ' + reason) : ''}`);
}
}

const requiredServicesRe = REQUIRED_SERVICES.map((name) => new RegExp(`\\b${name}:`));
let services;
try {
Expand Down

0 comments on commit c98fbcd

Please sign in to comment.