forked from appium/appium-ios-remotexpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.ts
More file actions
377 lines (334 loc) · 14.7 KB
/
Copy pathservices.ts
File metadata and controls
377 lines (334 loc) · 14.7 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import {
DEFAULT_TUNNEL_SERVICE_WAIT_MS,
resolveTunnelService,
resolveTunnelServicePorts,
} from './lib/tunnel/tunnel-service-resolver.js';
import type {DVTInstruments, SyslogService as SyslogServiceType, XCTestServices} from './lib/types.js';
import {AccessibilityAuditService} from './services/ios/accessibility-audit/index.js';
import AfcService from './services/ios/afc/index.js';
import {AppService} from './services/ios/app-service/index.js';
import {type Service} from './services/ios/base-service.js';
import {ConfigurationService} from './services/ios/configuration/index.js';
import {CrashReportsService} from './services/ios/crash-reports/index.js';
import {DeviceControlService} from './services/ios/device-control/index.js';
import {CoreDeviceInfoService} from './services/ios/device-info/index.js';
import DiagnosticsService from './services/ios/diagnostic-service/index.js';
import {DisplayService} from './services/ios/display/index.js';
import {DVTSecureSocketProxyService} from './services/ios/dvt/index.js';
import {ActivityTraceTap} from './services/ios/dvt/instruments/activity-trace-tap.js';
import {ApplicationListing} from './services/ios/dvt/instruments/application-listing.js';
import {ConditionInducer} from './services/ios/dvt/instruments/condition-inducer.js';
import {DeviceInfo} from './services/ios/dvt/instruments/device-info.js';
import {EnergyMonitor} from './services/ios/dvt/instruments/energy-monitor.js';
import {Graphics} from './services/ios/dvt/instruments/graphics.js';
import {LocationSimulation} from './services/ios/dvt/instruments/location-simulation.js';
import {NetworkMonitor} from './services/ios/dvt/instruments/network-monitor.js';
import {Notifications} from './services/ios/dvt/instruments/notifications.js';
import {ProcessControl} from './services/ios/dvt/instruments/process-control.js';
import {Screenshot} from './services/ios/dvt/instruments/screenshot.js';
import {Sysmontap} from './services/ios/dvt/instruments/sysmontap.js';
import {HidIndigoService} from './services/ios/hid-indigo/index.js';
import {HouseArrestService} from './services/ios/house-arrest/index.js';
import {InstallationProxyService} from './services/ios/installation-proxy/index.js';
import {MisagentService} from './services/ios/misagent/index.js';
import {MobileConfigService} from './services/ios/mobile-config/index.js';
import MobileImageMounterService from './services/ios/mobile-image-mounter/index.js';
import {NotificationProxyService} from './services/ios/notification-proxy/index.js';
import {PasteboardService} from './services/ios/pasteboard/index.js';
import {PowerAssertionService} from './services/ios/power-assertion/index.js';
import {SpringBoardService} from './services/ios/springboard-service/index.js';
import SyslogService from './services/ios/syslog-service/index.js';
import {DvtTestmanagedProxyService} from './services/ios/testmanagerd/index.js';
import {WebInspectorService} from './services/ios/webinspector/index.js';
import ZipConduitService from './services/ios/zipconduit/index.js';
export {getAvailableDevices, getTunnelForDevice} from './lib/tunnel/tunnel-availability.js';
const SERVICE_WAIT_MS = DEFAULT_TUNNEL_SERVICE_WAIT_MS;
/**
* Start the diagnostics service for the given device UDID.
*/
export async function startDiagnosticsService(udid: string): Promise<DiagnosticsService> {
await requireCatalogService(udid, DiagnosticsService.RSD_SERVICE_NAME);
return new DiagnosticsService(udid);
}
/**
* Start the notification proxy service for the given device UDID.
*/
export async function startNotificationProxyService(udid: string): Promise<NotificationProxyService> {
await requireCatalogService(udid, NotificationProxyService.RSD_SERVICE_NAME);
return new NotificationProxyService(udid);
}
/**
* Start the mobile configuration service for the given device UDID.
*/
export async function startMobileConfigService(udid: string): Promise<MobileConfigService> {
await requireCatalogService(udid, MobileConfigService.RSD_SERVICE_NAME);
return new MobileConfigService(udid);
}
/**
* Start the mobile image mounter service for the given device UDID.
*/
export async function startMobileImageMounterService(udid: string): Promise<MobileImageMounterService> {
await requireCatalogService(udid, MobileImageMounterService.RSD_SERVICE_NAME);
return new MobileImageMounterService(udid);
}
/**
* Start the SpringBoard service for the given device UDID.
*/
export async function startSpringboardService(udid: string): Promise<SpringBoardService> {
await requireCatalogService(udid, SpringBoardService.RSD_SERVICE_NAME);
return new SpringBoardService(udid);
}
/**
* Start the misagent service for the given device UDID.
*/
export async function startMisagentService(udid: string): Promise<MisagentService> {
await requireCatalogService(udid, MisagentService.RSD_SERVICE_NAME);
return new MisagentService(udid);
}
/**
* Start the power assertion service for the given device UDID.
*/
export async function startPowerAssertionService(udid: string): Promise<PowerAssertionService> {
await requireCatalogService(udid, PowerAssertionService.RSD_SERVICE_NAME);
return new PowerAssertionService(udid);
}
/**
* Start the CoreDevice HID Indigo service for the given device UDID.
*/
export async function startHidIndigoService(udid: string): Promise<HidIndigoService> {
await requireCatalogService(udid, HidIndigoService.RSD_SERVICE_NAME);
return new HidIndigoService(udid);
}
/**
* Start the CoreDevice AppService for the given device UDID.
*
* Provides app and process management (list apps, launch apps, list processes,
* signal processes, uninstall apps) over RemoteXPC.
*/
export async function startAppService(udid: string): Promise<AppService> {
await requireCatalogService(udid, AppService.RSD_SERVICE_NAME);
return new AppService(udid);
}
/**
* Start the CoreDevice pasteboard service for the given device UDID.
*/
export async function startPasteboardService(udid: string): Promise<PasteboardService> {
await requireCatalogService(udid, PasteboardService.RSD_SERVICE_NAME);
return new PasteboardService(udid);
}
/**
* Start the CoreDevice DeviceInfo service for the given device UDID.
*
* Queries device identity and state (device/display info, lock state, and
* MobileGestalt values) over RemoteXPC — the backend used by `devicectl`.
*/
export async function startCoreDeviceInfoService(udid: string): Promise<CoreDeviceInfoService> {
await requireCatalogService(udid, CoreDeviceInfoService.RSD_SERVICE_NAME);
return new CoreDeviceInfoService(udid);
}
/**
* Start the accessibility audit service for the given device UDID — the DTX
* backend behind Xcode's Accessibility Inspector. Exposes the device's
* accessibility settings and audit catalogue.
*/
export async function startAccessibilityAuditService(udid: string): Promise<AccessibilityAuditService> {
await requireCatalogService(udid, AccessibilityAuditService.RSD_SERVICE_NAME);
return AccessibilityAuditService.start(udid);
}
/**
* Start the CoreDevice device-control service for the given device UDID.
*/
export async function startDeviceControlService(udid: string): Promise<DeviceControlService> {
await requireCatalogService(udid, DeviceControlService.RSD_SERVICE_NAME);
return new DeviceControlService(udid);
}
/**
* Start the CoreDevice configuration service for the given device UDID.
*
* Reads and writes appearance and accessibility knobs (dark/light mode, Dynamic
* Type text size, Reduce Motion / Transparency, Increase Contrast, color
* filters, layout-debug borders, iOS 26 liquid-glass opacity) over RemoteXPC.
*/
export async function startConfigurationService(udid: string): Promise<ConfigurationService> {
await requireCatalogService(udid, ConfigurationService.RSD_SERVICE_NAME);
return new ConfigurationService(udid);
}
/**
* Start the CoreDevice display service for the given device UDID.
*
* Negotiates live HEVC screen and system-audio streams over RTP — the backend
* behind Xcode's device mirroring. Streaming requires iOS 27.0+; the capability
* queries work on older versions, so check
* {@link DisplayService.isStreamingSupported} first.
*/
export async function startDisplayService(udid: string): Promise<DisplayService> {
await requireCatalogService(udid, DisplayService.RSD_SERVICE_NAME);
return new DisplayService(udid);
}
const RSD_SYSLOG_BINARY_SERVICE_NAME = 'com.apple.os_trace_relay.shim.remote';
const RSD_SYSLOG_TEXT_SERVICE_NAME = 'com.apple.syslog_relay.shim.remote';
/** Options for {@link startXCTestServices}. */
export interface StartXCTestServicesOptions {
/** Also resolve and return an InstallationProxyService for app lookup. */
includeInstallationProxy?: boolean;
}
/**
* Start the syslog service for the given device UDID.
* Validates the os_trace_relay shim is present in the tunnel catalog.
*/
export async function startSyslogService(udid: string): Promise<SyslogServiceType> {
await requireCatalogService(udid, RSD_SYSLOG_BINARY_SERVICE_NAME);
return new SyslogService(udid);
}
/**
* Resolve the syslog binary service (os_trace_relay RemoteXPC shim).
*/
export async function startSyslogBinaryService(
udid: string,
): Promise<{syslogService: SyslogServiceType; serviceDescriptor: Service}> {
return startSyslogWithServiceName(udid, RSD_SYSLOG_BINARY_SERVICE_NAME);
}
/**
* Resolve the syslog text-relay service (iOS 18+ RemoteXPC shim).
*/
export async function startSyslogTextService(
udid: string,
): Promise<{syslogService: SyslogServiceType; serviceDescriptor: Service}> {
return startSyslogWithServiceName(udid, RSD_SYSLOG_TEXT_SERVICE_NAME);
}
/**
* Start AFC service over RemoteXPC shim.
*/
export async function startAfcService(udid: string): Promise<AfcService> {
await requireCatalogService(udid, AfcService.RSD_SERVICE_NAME);
return new AfcService(udid);
}
/**
* Start streaming zip_conduit service over RemoteXPC shim.
*/
export async function startZipConduitService(udid: string): Promise<ZipConduitService> {
await requireCatalogService(udid, ZipConduitService.RSD_SERVICE_NAME);
return new ZipConduitService(udid);
}
/**
* Start CrashReportsService over RemoteXPC shim.
*/
export async function startCrashReportsService(udid: string): Promise<CrashReportsService> {
await requireCatalogServices(udid, [
CrashReportsService.RSD_COPY_MOBILE_NAME,
CrashReportsService.RSD_CRASH_MOVER_NAME,
]);
return new CrashReportsService(udid);
}
/**
* Start the house arrest service for the given device UDID.
*/
export async function startHouseArrestService(udid: string): Promise<HouseArrestService> {
await requireCatalogService(udid, HouseArrestService.RSD_SERVICE_NAME);
return new HouseArrestService(udid);
}
/**
* Start the installation proxy service for the given device UDID.
*/
export async function startInstallationProxyService(udid: string): Promise<InstallationProxyService> {
await requireCatalogService(udid, InstallationProxyService.RSD_SERVICE_NAME);
return new InstallationProxyService(udid);
}
/**
* Start the web inspector service for the given device UDID.
*/
export async function startWebInspectorService(udid: string): Promise<WebInspectorService> {
await requireCatalogService(udid, WebInspectorService.RSD_SERVICE_NAME);
return new WebInspectorService(udid);
}
/**
* Start the DVT secure socket proxy service and instrument clients.
*/
export async function startDVTService(udid: string): Promise<DVTInstruments> {
await requireCatalogService(udid, DVTSecureSocketProxyService.RSD_SERVICE_NAME);
const dvtService = new DVTSecureSocketProxyService(udid);
await dvtService.connect();
return {
dvtService,
locationSimulation: new LocationSimulation(dvtService),
conditionInducer: new ConditionInducer(dvtService),
screenshot: new Screenshot(dvtService),
appListing: new ApplicationListing(dvtService),
graphics: new Graphics(dvtService),
deviceInfo: new DeviceInfo(dvtService),
notification: new Notifications(dvtService),
networkMonitor: new NetworkMonitor(dvtService),
processControl: new ProcessControl(dvtService),
sysmontap: new Sysmontap(dvtService),
energyMonitor: new EnergyMonitor(dvtService),
activityTraceTap: new ActivityTraceTap(dvtService),
};
}
/**
* Start the testmanagerd service for the given device UDID.
*/
export async function startTestmanagerdService(udid: string): Promise<DvtTestmanagedProxyService> {
await requireCatalogService(udid, DvtTestmanagedProxyService.RSD_SERVICE_NAME);
const testmanagerdService = new DvtTestmanagedProxyService(udid);
await testmanagerdService.connect();
return testmanagerdService;
}
/**
* Start all services needed for an XCTest session using one registry catalog read.
*/
export async function startXCTestServices(udid: string, options?: StartXCTestServicesOptions): Promise<XCTestServices> {
const serviceNames = [DvtTestmanagedProxyService.RSD_SERVICE_NAME, DVTSecureSocketProxyService.RSD_SERVICE_NAME];
if (options?.includeInstallationProxy) {
serviceNames.push(InstallationProxyService.RSD_SERVICE_NAME);
}
await requireCatalogServices(udid, serviceNames);
let execTestmanagerd: DvtTestmanagedProxyService | null = null;
let controlTestmanagerd: DvtTestmanagedProxyService | null = null;
let dvtService: DVTSecureSocketProxyService | null = null;
let installationProxy: InstallationProxyService | undefined;
try {
execTestmanagerd = new DvtTestmanagedProxyService(udid);
await execTestmanagerd.connect();
controlTestmanagerd = new DvtTestmanagedProxyService(udid);
await controlTestmanagerd.connect();
dvtService = new DVTSecureSocketProxyService(udid);
await dvtService.connect();
if (options?.includeInstallationProxy) {
installationProxy = new InstallationProxyService(udid);
}
} catch (err) {
installationProxy?.close();
await dvtService?.close().catch(() => {});
await controlTestmanagerd?.close().catch(() => {});
await execTestmanagerd?.close().catch(() => {});
throw err;
}
const processControl = new ProcessControl(dvtService);
return {
execTestmanagerd,
controlTestmanagerd,
dvtService,
processControl,
installationProxy,
};
}
async function requireCatalogService(udid: string, serviceName: string): Promise<void> {
await resolveTunnelService(udid, serviceName, {waitMs: SERVICE_WAIT_MS});
}
async function requireCatalogServices(udid: string, serviceNames: string[]): Promise<void> {
await resolveTunnelServicePorts(udid, serviceNames, {
waitMs: SERVICE_WAIT_MS,
});
}
async function startSyslogWithServiceName(
udid: string,
serviceName: string,
): Promise<{syslogService: SyslogServiceType; serviceDescriptor: Service}> {
const {port} = await resolveTunnelService(udid, serviceName, {
waitMs: SERVICE_WAIT_MS,
});
return {
syslogService: new SyslogService(udid),
serviceDescriptor: {serviceName, port: String(port)},
};
}