MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / doModalAndroid

Function doModalAndroid

apps/automated/src/tk-unit.ts:413–455  ·  view source on GitHub ↗
(quitLoop: () => boolean, timeoutSec: number, shouldThrow: boolean = true)

Source from the content-addressed store, hash-verified

411}
412
413function doModalAndroid(quitLoop: () => boolean, timeoutSec: number, shouldThrow: boolean = true) {
414 if (!quitLoop) {
415 return;
416 }
417
418 prepareModal();
419
420 const queue = android.os.Looper.myQueue();
421
422 let quit = false;
423 let timeout = false;
424 setTimeout(() => {
425 quit = true;
426 timeout = true;
427 }, timeoutSec * 1000);
428
429 let msg;
430
431 while (!quit) {
432 msg = nextMethod.invoke(queue, null);
433 if (msg) {
434 const target = targetField.get(msg);
435 if (!target) {
436 quit = true;
437 } else {
438 target.dispatchMessage(msg);
439 }
440
441 if (sdkVersion < 21) {
442 //https://code.google.com/p/android-test-kit/issues/detail?id=84
443 msg.recycle();
444 }
445 }
446
447 if (shouldThrow && timeout) {
448 throw new Error('waitUntilReady Timeout.');
449 }
450
451 if (!quit && quitLoop()) {
452 quit = true;
453 }
454 }
455}

Callers 1

waitUntilReadyFunction · 0.85

Calls 3

prepareModalFunction · 0.85
getMethod · 0.65
setTimeoutFunction · 0.50

Tested by

no test coverage detected