Repository navigation
Expand file tree
/
Copy pathandroid-adb.ts
More file actions
88 lines (73 loc) · 3.95 KB
/
Copy pathandroid-adb.ts
File metadata and controls
88 lines (73 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { withMethodScope } from '@agent-device/kernel/scoped-provider';
import '../platform-runtime-android-adb-host.ts';
import * as mechanics from '@agent-device/platform-android/mechanics';
import { withSdkCommandHost } from './command-host.ts';
import type { AndroidAdbExecutor } from '@agent-device/platform-android/mechanics';
import type { AppStateRuntimeResult } from '@agent-device/contracts/app-state-runtime';
export type {
AndroidAdbExecutor,
AndroidAdbExecutorOptions,
AndroidAdbProvider,
AndroidPortReverseEndpoint,
AndroidKeyboardDismissResult,
AndroidKeyboardState,
} from '@agent-device/platform-android/mechanics';
export type { ShellWord } from '@agent-device/kernel/device-shell';
export const runAndroidShell: typeof mechanics.runAndroidShell = (...args) =>
withSdkCommandHost(() => mechanics.runAndroidShell(...args));
export const runAndroidExecOut: typeof mechanics.runAndroidExecOut = (...args) =>
withSdkCommandHost(() => mechanics.runAndroidExecOut(...args));
export const runAdbShell: typeof mechanics.runAdbShell = (...args) =>
withSdkCommandHost(() => mechanics.runAdbShell(...args));
export const runAdbExecOut: typeof mechanics.runAdbExecOut = (...args) =>
withSdkCommandHost(() => mechanics.runAdbExecOut(...args));
export const listAndroidAppsWithAdb: typeof mechanics.listAndroidAppsWithAdb = (...args) =>
withSdkCommandHost(() => mechanics.listAndroidAppsWithAdb(...args));
export const forceStopAndroidAppWithAdb: typeof mechanics.forceStopAndroidAppWithAdb = (...args) =>
withSdkCommandHost(() => mechanics.forceStopAndroidAppWithAdb(...args));
export const openAndroidAppWithAdb: typeof mechanics.openAndroidAppWithAdb = (...args) =>
withSdkCommandHost(() => mechanics.openAndroidAppWithAdb(...args));
export const captureAndroidLogcatWithAdb: typeof mechanics.captureAndroidLogcatWithAdb = (
...args
) => withSdkCommandHost(() => mechanics.captureAndroidLogcatWithAdb(...args));
export const dismissAndroidKeyboardWithAdb: typeof mechanics.dismissAndroidKeyboardWithAdb = (
...args
) => withSdkCommandHost(() => mechanics.dismissAndroidKeyboardWithAdb(...args));
export const getAndroidKeyboardStatusWithAdb: typeof mechanics.getAndroidKeyboardStatusWithAdb = (
...args
) => withSdkCommandHost(() => mechanics.getAndroidKeyboardStatusWithAdb(...args));
export const readAndroidClipboardWithAdb: typeof mechanics.readAndroidClipboardWithAdb = (
...args
) => withSdkCommandHost(() => mechanics.readAndroidClipboardWithAdb(...args));
export const writeAndroidClipboardWithAdb: typeof mechanics.writeAndroidClipboardWithAdb = (
...args
) => withSdkCommandHost(() => mechanics.writeAndroidClipboardWithAdb(...args));
export function createAndroidPortReverseManager(
provider: mechanics.AndroidAdbProvider | AndroidAdbExecutor,
): ReturnType<typeof mechanics.createAndroidPortReverseManager>;
export function createAndroidPortReverseManager(
...args: Parameters<typeof mechanics.createAndroidPortReverseManager>
): ReturnType<typeof mechanics.createAndroidPortReverseManager>;
export function createAndroidPortReverseManager(
provider: mechanics.AndroidAdbProvider | AndroidAdbExecutor,
options?: Parameters<typeof mechanics.createAndroidPortReverseManager>[1],
): ReturnType<typeof mechanics.createAndroidPortReverseManager> {
return withSdkCommandHost((host) => {
const manager =
options && typeof provider === 'function'
? mechanics.createAndroidPortReverseManager(provider, options)
: mechanics.createAndroidPortReverseManager(provider);
return mechanics.scopeAndroidPortReverseManager(manager, (target) =>
withMethodScope(target, (task) => withSdkCommandHost(task, host)),
);
});
}
export async function getAndroidAppStateWithAdb(
adb: AndroidAdbExecutor,
signal?: AbortSignal,
): Promise<AppStateRuntimeResult> {
return await withSdkCommandHost(async () => {
const { getAndroidAppStateWithAdb: read } = await import('../platform-runtime.ts');
return await read(adb, signal);
});
}