Skip to content

Commit 788944f

Browse files
committed
docs(android): name the instrumentation takeover that retires the previous helper
1 parent 7113e97 commit 788944f

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

‎packages/platform-android/src/__tests__/fill-verification.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Fill reads the live hierarchy four times per attempt (one pre-action target read plus the
2-
// 0/150/350 ms settling samples). Android permits ONE UiAutomation owner, so a command-scoped
3-
// capture stops the automation-helper session after every one of those reads and the next read
4-
// pays a fresh `am instrument` start. These tests pin who owns the helper session across the
5-
// samples — not what the samples conclude, which fill-diagnostics/input-actions-fill own.
2+
// 0/150/350 ms settling samples). `am instrument` force-stops whatever is already instrumenting the
3+
// helper package, so a command-scoped capture stops the automation-helper session after every one of
4+
// those reads and the next read pays a fresh `am instrument` start. These tests pin who owns the
5+
// helper session across the samples — not what the samples conclude, which
6+
// fill-diagnostics/input-actions-fill own.
67

78
import { afterEach, beforeEach, test } from 'vitest';
89
import './test-utils/android-host-test-setup.ts';

‎packages/platform-android/src/snapshot-helper-session-lifecycle.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* Who owns the device's UiAutomation right now, and how that ownership starts and ends.
33
*
4-
* Android permits ONE UiAutomation owner, so a live helper session is device-exclusive state: this
5-
* module is the only place that starts one, hands it out, and retires it. Commands run OVER a
6-
* session (snapshot capture, gestures) live in `snapshot-helper-session.ts`; they acquire through
7-
* here and never reach the registry themselves.
4+
* `am instrument` force-stops whatever is already instrumenting the helper package, so a live helper
5+
* session is device-exclusive state: this module is the only place that starts one, hands it out, and
6+
* retires it. Commands run OVER a session (snapshot capture, gestures) live in
7+
* `snapshot-helper-session.ts`; they acquire through here and never reach the registry themselves.
88
*/
99
import type { AndroidAdbProcess } from './adb-executor.ts';
1010
import { requireAndroidAdbHost } from './adb-host.ts';

‎packages/platform-android/src/snapshot-helper-session.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ async function captureFromAndroidSnapshotHelperSession(params: {
8686
}
8787

8888
// Touch commands piggyback on a live snapshot session so gestures do not restart instrumentation
89-
// (Android permits one UiAutomation owner). They never start a session: without one, callers use
90-
// the same helper APK through a one-shot `am instrument` run instead.
89+
// (a second instrumentation for the helper package would force-stop the session that has it). They
90+
// never start a session: without one, callers use the same helper APK through a one-shot
91+
// `am instrument` run instead.
9192
export async function runAndroidSnapshotHelperSessionTouchCommand(params: {
9293
deviceKey: string;
9394
action: 'gesture' | 'viewport';

‎packages/platform-android/src/snapshot-helper-types.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export const ANDROID_SNAPSHOT_HELPER_COMMAND_TIMEOUT_MS = 30_000;
2626
/**
2727
* Who releases the helper's persistent instrumentation session.
2828
*
29-
* Android permits ONE UiAutomation owner, so a `command`-scoped call stops the session when it
30-
* finishes and the next helper call pays a fresh `am instrument` start plus the UiAutomation
31-
* connect wait. `daemon-session` hands that release to session teardown
32-
* (`stopSessionAndroidSnapshotHelper`), which every Android session runs, so consecutive commands
33-
* in one session share one warm helper. Device-scoped work stays `command` so nothing squats
34-
* UiAutomation once the command returns.
29+
* `am instrument` force-stops whatever is already instrumenting the helper package, so a
30+
* `command`-scoped call stops the session when it finishes and the next helper call pays a fresh
31+
* `am instrument` start plus the UiAutomation connect wait. `daemon-session` hands that release to
32+
* session teardown (`stopSessionAndroidSnapshotHelper`), which every Android session runs, so
33+
* consecutive commands in one session share one warm helper. Device-scoped work stays `command` so
34+
* nothing squats UiAutomation once the command returns.
3535
*/
3636
export type AndroidHelperSessionScope = 'command' | 'daemon-session';
3737

0 commit comments

Comments
 (0)