(device: DeviceInfo, app: string)
| 643 | } |
| 644 | |
| 645 | export async function closeAndroidApp(device: DeviceInfo, app: string): Promise<void> { |
| 646 | const trimmed = app.trim(); |
| 647 | if (trimmed.toLowerCase() === 'settings') { |
| 648 | await runAndroidAdb(device, ['shell', 'am', 'force-stop', 'com.android.settings']); |
| 649 | await waitForAndroidPackageStopped(device, 'com.android.settings'); |
| 650 | return; |
| 651 | } |
| 652 | const resolved = await resolveAndroidApp(device, app); |
| 653 | if (resolved.type === 'intent') { |
| 654 | throw new AppError('INVALID_ARGS', 'Close requires a package name, not an intent'); |
| 655 | } |
| 656 | await runAndroidAdb(device, ['shell', 'am', 'force-stop', resolved.value]); |
| 657 | await waitForAndroidPackageStopped(device, resolved.value); |
| 658 | } |
| 659 | |
| 660 | async function waitForAndroidPackageStopped( |
| 661 | device: DeviceInfo, |
no test coverage detected