appium-ios-remotexpc 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -0
  3. package/build/src/index.d.ts +2 -1
  4. package/build/src/index.d.ts.map +1 -1
  5. package/build/src/index.js +1 -0
  6. package/build/src/lib/types.d.ts +30 -0
  7. package/build/src/lib/types.d.ts.map +1 -1
  8. package/build/src/lib/types.js +2 -0
  9. package/build/src/services/index.d.ts +3 -1
  10. package/build/src/services/index.d.ts.map +1 -1
  11. package/build/src/services/index.js +3 -1
  12. package/build/src/services/ios/afc/codec.d.ts +46 -0
  13. package/build/src/services/ios/afc/codec.d.ts.map +1 -0
  14. package/build/src/services/ios/afc/codec.js +263 -0
  15. package/build/src/services/ios/afc/constants.d.ts +11 -0
  16. package/build/src/services/ios/afc/constants.d.ts.map +1 -0
  17. package/build/src/services/ios/afc/constants.js +22 -0
  18. package/build/src/services/ios/afc/enums.d.ts +66 -0
  19. package/build/src/services/ios/afc/enums.d.ts.map +1 -0
  20. package/build/src/services/ios/afc/enums.js +70 -0
  21. package/build/src/services/ios/afc/index.d.ts +72 -0
  22. package/build/src/services/ios/afc/index.d.ts.map +1 -0
  23. package/build/src/services/ios/afc/index.js +385 -0
  24. package/build/src/services/ios/afc/stream-utils.d.ts +14 -0
  25. package/build/src/services/ios/afc/stream-utils.d.ts.map +1 -0
  26. package/build/src/services/ios/afc/stream-utils.js +60 -0
  27. package/build/src/services/ios/power-assertion/index.d.ts +40 -0
  28. package/build/src/services/ios/power-assertion/index.d.ts.map +1 -0
  29. package/build/src/services/ios/power-assertion/index.js +64 -0
  30. package/build/src/services.d.ts +8 -1
  31. package/build/src/services.d.ts.map +1 -1
  32. package/build/src/services.js +25 -0
  33. package/package.json +3 -1
  34. package/src/index.ts +4 -0
  35. package/src/lib/types.ts +34 -0
  36. package/src/services/index.ts +4 -0
  37. package/src/services/ios/afc/codec.ts +365 -0
  38. package/src/services/ios/afc/constants.ts +29 -0
  39. package/src/services/ios/afc/enums.ts +70 -0
  40. package/src/services/ios/afc/index.ts +511 -0
  41. package/src/services/ios/afc/stream-utils.ts +102 -0
  42. package/src/services/ios/power-assertion/index.ts +100 -0
  43. package/src/services.ts +33 -0
@@ -0,0 +1,100 @@
1
+ import { logger } from '@appium/support';
2
+
3
+ import type {
4
+ PlistDictionary,
5
+ PowerAssertionService as PowerAssertionServiceInterface,
6
+ } from '../../../lib/types.js';
7
+ import { ServiceConnection } from '../../../service-connection.js';
8
+ import { BaseService } from '../base-service.js';
9
+
10
+ const log = logger.getLogger('PowerAssertionService');
11
+
12
+ /**
13
+ * Power assertion types that can be used to prevent system sleep
14
+ */
15
+ export enum PowerAssertionType {
16
+ WIRELESS_SYNC = 'AMDPowerAssertionTypeWirelessSync',
17
+ PREVENT_USER_IDLE_SYSTEM_SLEEP = 'PreventUserIdleSystemSleep',
18
+ PREVENT_SYSTEM_SLEEP = 'PreventSystemSleep',
19
+ }
20
+
21
+ /**
22
+ * Options for power assertion creation
23
+ */
24
+ export interface PowerAssertionOptions {
25
+ type: PowerAssertionType;
26
+ name: string;
27
+ timeout: number; // timeout in seconds
28
+ details?: string;
29
+ }
30
+
31
+ /**
32
+ * PowerAssertionService provides an API to create power assertions.
33
+ */
34
+ class PowerAssertionService
35
+ extends BaseService
36
+ implements PowerAssertionServiceInterface
37
+ {
38
+ static readonly RSD_SERVICE_NAME =
39
+ 'com.apple.mobile.assertion_agent.shim.remote';
40
+
41
+ private _conn: ServiceConnection | null = null;
42
+
43
+ /**
44
+ * Create a power assertion to prevent system sleep
45
+ * @param options Options for creating the power assertion
46
+ * @returns Promise that resolves when the assertion is created
47
+ */
48
+ async createPowerAssertion(options: PowerAssertionOptions): Promise<void> {
49
+ if (!this._conn) {
50
+ this._conn = await this.connectToPowerAssertionService();
51
+ }
52
+
53
+ const request = this.buildCreateAssertionRequest(options);
54
+ await this._conn.sendPlistRequest(request);
55
+ log.info(
56
+ `Power assertion created: type="${options.type}", name="${options.name}", timeout=${options.timeout}s`,
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Close the connection to the power assertion service
62
+ */
63
+ async close(): Promise<void> {
64
+ if (this._conn) {
65
+ await this._conn.close();
66
+ this._conn = null;
67
+ log.debug('Power assertion service connection closed');
68
+ }
69
+ }
70
+
71
+ private async connectToPowerAssertionService(): Promise<ServiceConnection> {
72
+ const service = {
73
+ serviceName: PowerAssertionService.RSD_SERVICE_NAME,
74
+ port: this.address[1].toString(),
75
+ };
76
+ log.debug(
77
+ `Connecting to power assertion service at ${this.address[0]}:${this.address[1]}`,
78
+ );
79
+ return await this.startLockdownService(service);
80
+ }
81
+
82
+ private buildCreateAssertionRequest(
83
+ options: PowerAssertionOptions,
84
+ ): PlistDictionary {
85
+ const request: PlistDictionary = {
86
+ CommandKey: 'CommandCreateAssertion',
87
+ AssertionTypeKey: options.type,
88
+ AssertionNameKey: options.name,
89
+ AssertionTimeoutKey: options.timeout,
90
+ };
91
+
92
+ if (options.details !== undefined) {
93
+ request.AssertionDetailKey = options.details;
94
+ }
95
+
96
+ return request;
97
+ }
98
+ }
99
+
100
+ export { PowerAssertionService };
package/src/services.ts CHANGED
@@ -8,14 +8,17 @@ import type {
8
8
  MobileConfigServiceWithConnection,
9
9
  MobileImageMounterServiceWithConnection,
10
10
  NotificationProxyServiceWithConnection,
11
+ PowerAssertionServiceWithConnection,
11
12
  SpringboardServiceWithConnection,
12
13
  SyslogService as SyslogServiceType,
13
14
  WebInspectorServiceWithConnection,
14
15
  } from './lib/types.js';
16
+ import AfcService from './services/ios/afc/index.js';
15
17
  import DiagnosticsService from './services/ios/diagnostic-service/index.js';
16
18
  import { MobileConfigService } from './services/ios/mobile-config/index.js';
17
19
  import MobileImageMounterService from './services/ios/mobile-image-mounter/index.js';
18
20
  import { NotificationProxyService } from './services/ios/notification-proxy/index.js';
21
+ import { PowerAssertionService } from './services/ios/power-assertion/index.js';
19
22
  import { SpringBoardService } from './services/ios/springboard-service/index.js';
20
23
  import SyslogService from './services/ios/syslog-service/index.js';
21
24
  import { WebInspectorService } from './services/ios/webinspector/index.js';
@@ -70,6 +73,7 @@ export async function startMobileConfigService(
70
73
  ]),
71
74
  };
72
75
  }
76
+
73
77
  export async function startMobileImageMounterService(
74
78
  udid: string,
75
79
  ): Promise<MobileImageMounterServiceWithConnection> {
@@ -102,6 +106,22 @@ export async function startSpringboardService(
102
106
  };
103
107
  }
104
108
 
109
+ export async function startPowerAssertionService(
110
+ udid: string,
111
+ ): Promise<PowerAssertionServiceWithConnection> {
112
+ const { remoteXPC, tunnelConnection } = await createRemoteXPCConnection(udid);
113
+ const powerAssertionService = remoteXPC.findService(
114
+ PowerAssertionService.RSD_SERVICE_NAME,
115
+ );
116
+ return {
117
+ remoteXPC: remoteXPC as RemoteXpcConnection,
118
+ powerAssertionService: new PowerAssertionService([
119
+ tunnelConnection.host,
120
+ parseInt(powerAssertionService.port, 10),
121
+ ]),
122
+ };
123
+ }
124
+
105
125
  export async function startSyslogService(
106
126
  udid: string,
107
127
  ): Promise<SyslogServiceType> {
@@ -109,6 +129,19 @@ export async function startSyslogService(
109
129
  return new SyslogService([tunnelConnection.host, tunnelConnection.port]);
110
130
  }
111
131
 
132
+ /**
133
+ * Start AFC service over RemoteXPC shim.
134
+ * Resolves the AFC service port via RemoteXPC and returns a ready-to-use AfcService instance.
135
+ */
136
+ export async function startAfcService(udid: string): Promise<AfcService> {
137
+ const { remoteXPC, tunnelConnection } = await createRemoteXPCConnection(udid);
138
+ const afcDescriptor = remoteXPC.findService(AfcService.RSD_SERVICE_NAME);
139
+ return new AfcService([
140
+ tunnelConnection.host,
141
+ parseInt(afcDescriptor.port, 10),
142
+ ]);
143
+ }
144
+
112
145
  export async function startWebInspectorService(
113
146
  udid: string,
114
147
  ): Promise<WebInspectorServiceWithConnection> {