Skip to content

feat: add ADB timeout option passed to startActivity function #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/android/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const help = `
--target <id> ........... Use a specific target
--connect ............... Tie process to app process
--forward <port:port> ... Forward a port from device to host
--timeout <timeout> ..... ADB timeout in miliseconds
Default is 5000
`;

export async function run(args: readonly string[]): Promise<void> {
Expand Down
3 changes: 2 additions & 1 deletion src/android/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function run(args: readonly string[]): Promise<void> {
const sdk = await getSDK();
const apkPath = getOptionValue(args, '--app');
const forwardedPorts = getOptionValues(args, '--forward');
const timeout = Number.parseFloat(getOptionValue(args, '--timeout', '5000'));

const ports: Ports[] = [];

Expand Down Expand Up @@ -74,7 +75,7 @@ export async function run(args: readonly string[]): Promise<void> {
await installApkToDevice(sdk, device, apkPath, appId);

log(`Starting application activity ${appId}/${activityName}...\n`);
await startActivity(sdk, device, appId, activityName);
await startActivity(sdk, device, appId, activityName, timeout);

log(`Run Successful\n`);

Expand Down
3 changes: 2 additions & 1 deletion src/android/utils/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ export async function startActivity(
device: Device,
packageName: string,
activityName: string,
timeout: number,
): Promise<void> {
const debug = Debug(`${modulePrefix}:${startActivity.name}`);
const args = ['-s', device.serial, 'shell', 'am', 'start', '-W', '-n', `${packageName}/${activityName}`];

debug('Invoking adb with args: %O', args);
await execAdb(sdk, args, { timeout: 5000 });
await execAdb(sdk, args, { timeout: timeout });
}

export function parseAdbDevices(output: string): Device[] {
Expand Down