fixed app launcher commmand

This commit is contained in:
user
2026-03-28 20:17:44 +02:00
parent 3e018d60f9
commit 7c210ffe8f
2 changed files with 68 additions and 9 deletions

View File

@@ -22,17 +22,34 @@ export class AndroidCommandExecutor {
["-s", serial, "shell", "am", "force-stop", packageName],
{ allowFailure: true },
);
await this.run([
"-s",
const launchActivity = await this.resolveLauncherActivity(
serial,
"shell",
"monkey",
"-p",
packageName,
"-c",
"android.intent.category.LAUNCHER",
"1",
]);
);
if (launchActivity) {
await this.run([
"-s",
serial,
"shell",
"am",
"start",
"-n",
launchActivity,
]);
} else {
await this.run([
"-s",
serial,
"shell",
"monkey",
"-p",
packageName,
"-c",
"android.intent.category.LAUNCHER",
"1",
]);
}
return { serial };
}
@@ -54,4 +71,41 @@ export class AndroidCommandExecutor {
throw error;
}
}
private async resolveLauncherActivity(
serial: string,
packageName: string,
): Promise<string | null> {
const result = await this.run(
[
"-s",
serial,
"shell",
"cmd",
"package",
"resolve-activity",
"--brief",
"-a",
"android.intent.action.MAIN",
"-c",
"android.intent.category.LAUNCHER",
packageName,
],
{ allowFailure: true },
);
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
const lines = output
.split("\n")
.map((line) => line.trim())
.filter(Boolean);
for (const line of lines) {
if (line.includes("/") && !line.startsWith("priority=")) {
return line;
}
}
return null;
}
}

View File

@@ -102,3 +102,8 @@ Update rule:
- Updated frontend session polling to use the new no-touch validity path and avoid stale query cache via forced refresh behavior.
- Added frontend session end command to explicitly release the linked device on session teardown/ejection.
- Updated admin link revoke flow to release the linked device after revocation so revoked sessions do not leave devices stuck `inUse`.
### 15 — Orchestrator App Launch Robustness
- Updated Android launch flow in orchestrator to resolve launcher activity via `cmd package resolve-activity` and launch with `am start -n <activity>`.
- Kept `monkey` as fallback only when launcher activity cannot be resolved, reducing redroid/device-specific `monkey` failures during session prepare.