assistsx-js 0.0.2048 → 0.0.2049
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.
- package/dist/AssistsX.d.ts +12 -0
- package/dist/AssistsX.js +22 -0
- package/dist/AssistsXAsync.d.ts +16 -0
- package/dist/AssistsXAsync.js +22 -0
- package/dist/CallMethod.d.ts +2 -0
- package/dist/CallMethod.js +2 -0
- package/package.json +1 -1
- package/src/AssistsX.ts +976 -954
- package/src/AssistsXAsync.ts +1044 -1012
- package/src/CallMethod.ts +62 -60
package/src/AssistsXAsync.ts
CHANGED
|
@@ -10,1085 +10,1117 @@ import { generateUUID } from "./Utils";
|
|
|
10
10
|
import { AppInfo } from "./AppInfo";
|
|
11
11
|
import { DeviceInfo } from "./DeviceInfo";
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
AssistsX,
|
|
14
|
+
callbacks,
|
|
15
|
+
WebFloatingWindowOptions,
|
|
16
|
+
HttpRequestOptions,
|
|
17
|
+
HttpResponse,
|
|
18
18
|
} from "./AssistsX";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 截图识别位置信息
|
|
22
22
|
*/
|
|
23
23
|
export interface RecognizeTextInScreenshotPosition {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
text: string;
|
|
25
|
+
left: number;
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* 截图识别结果
|
|
35
35
|
*/
|
|
36
36
|
export interface RecognizeTextInScreenshotResult {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
fullText: string;
|
|
38
|
+
processingTimeMillis: number;
|
|
39
|
+
positions: RecognizeTextInScreenshotPosition[];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* 截图识别区域参数
|
|
44
44
|
*/
|
|
45
45
|
export interface RecognizeTextRegion {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
left?: number;
|
|
47
|
+
top?: number;
|
|
48
|
+
right?: number;
|
|
49
|
+
bottom?: number;
|
|
50
|
+
width?: number;
|
|
51
|
+
height?: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* 联系人信息
|
|
56
56
|
*/
|
|
57
57
|
export interface Contact {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
phoneNumbers: string[];
|
|
61
|
+
emails: string[];
|
|
62
|
+
address: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export class AssistsXAsync {
|
|
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
|
-
|
|
66
|
+
/**
|
|
67
|
+
* 执行异步调用
|
|
68
|
+
* @param method 方法名
|
|
69
|
+
* @param args 参数对象
|
|
70
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
71
|
+
* @returns Promise<调用响应>
|
|
72
|
+
*/
|
|
73
|
+
private static async asyncCall(
|
|
74
|
+
method: string,
|
|
75
|
+
{
|
|
76
|
+
args,
|
|
77
|
+
node,
|
|
78
|
+
nodes,
|
|
79
|
+
timeout = 30,
|
|
80
|
+
}: { args?: any; node?: Node; nodes?: Node[]; timeout?: number } = {}
|
|
81
|
+
): Promise<CallResponse> {
|
|
82
|
+
const uuid = generateUUID();
|
|
83
|
+
const params = {
|
|
84
|
+
method,
|
|
85
|
+
arguments: args ? args : undefined,
|
|
86
|
+
node: node ? node : undefined,
|
|
87
|
+
nodes: nodes ? nodes : undefined,
|
|
88
|
+
callbackId: uuid,
|
|
89
|
+
};
|
|
90
|
+
const promise = new Promise((resolve) => {
|
|
91
|
+
callbacks.set(uuid, (data: string) => {
|
|
92
|
+
resolve(data);
|
|
93
|
+
});
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
// 超时后删除回调函数
|
|
96
|
+
callbacks.delete(uuid);
|
|
97
|
+
resolve(new CallResponse(0, null, uuid));
|
|
98
|
+
}, timeout * 1000);
|
|
99
|
+
});
|
|
100
|
+
const result = window.assistsxAsync.call(JSON.stringify(params));
|
|
101
|
+
const promiseResult = await promise;
|
|
102
|
+
if (typeof promiseResult === "string") {
|
|
103
|
+
const responseData = JSON.parse(promiseResult);
|
|
104
|
+
const response = new CallResponse(
|
|
105
|
+
responseData.code,
|
|
106
|
+
responseData.data,
|
|
107
|
+
responseData.callbackId
|
|
108
|
+
);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
throw new Error("Call failed");
|
|
110
112
|
}
|
|
111
|
-
throw new Error("Call failed");
|
|
112
|
-
}
|
|
113
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
|
-
|
|
114
|
+
/**
|
|
115
|
+
* 设置悬浮窗标志
|
|
116
|
+
* @param flags 标志
|
|
117
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
118
|
+
* @returns 是否设置成功
|
|
119
|
+
*/
|
|
120
|
+
public static async setOverlayFlags(
|
|
121
|
+
flags: number,
|
|
122
|
+
timeout?: number
|
|
123
|
+
): Promise<boolean> {
|
|
124
|
+
const response = await this.asyncCall(CallMethod.setOverlayFlags, {
|
|
125
|
+
args: { flags: flags },
|
|
126
|
+
timeout,
|
|
127
|
+
});
|
|
128
|
+
return response.getDataOrDefault(false);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 设置悬浮窗标志
|
|
132
|
+
* @param flags 标志
|
|
133
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
134
|
+
* @returns 是否设置成功
|
|
135
|
+
*/
|
|
136
|
+
public static async setOverlayFlagList(
|
|
137
|
+
flags: number[],
|
|
138
|
+
timeout?: number
|
|
139
|
+
): Promise<boolean> {
|
|
140
|
+
const response = await this.asyncCall(CallMethod.setOverlayFlags, {
|
|
141
|
+
args: { flags: flags },
|
|
142
|
+
timeout,
|
|
143
|
+
});
|
|
144
|
+
return response.getDataOrDefault(false);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 获取所有符合条件的节点
|
|
148
|
+
* @param filterClass 类名过滤
|
|
149
|
+
* @param filterViewId 视图ID过滤
|
|
150
|
+
* @param filterDes 描述过滤
|
|
151
|
+
* @param filterText 文本过滤
|
|
152
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
153
|
+
* @returns 节点数组
|
|
154
|
+
*/
|
|
155
|
+
public static async getAllNodes({
|
|
156
|
+
filterClass,
|
|
157
|
+
filterViewId,
|
|
158
|
+
filterDes,
|
|
159
|
+
filterText,
|
|
160
|
+
timeout,
|
|
161
|
+
}: {
|
|
162
|
+
filterClass?: string;
|
|
163
|
+
filterViewId?: string;
|
|
164
|
+
filterDes?: string;
|
|
165
|
+
filterText?: string;
|
|
166
|
+
timeout?: number;
|
|
167
|
+
} = {}): Promise<Node[]> {
|
|
168
|
+
const response = await this.asyncCall(CallMethod.getAllNodes, {
|
|
169
|
+
args: { filterClass, filterViewId, filterDes, filterText },
|
|
170
|
+
timeout,
|
|
171
|
+
});
|
|
172
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
173
|
+
}
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
175
|
+
/**
|
|
176
|
+
* 设置节点文本
|
|
177
|
+
* @param node 目标节点
|
|
178
|
+
* @param text 要设置的文本
|
|
179
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
180
|
+
* @returns 是否设置成功
|
|
181
|
+
*/
|
|
182
|
+
public static async setNodeText(
|
|
183
|
+
node: Node,
|
|
184
|
+
text: string,
|
|
185
|
+
timeout?: number
|
|
186
|
+
): Promise<boolean> {
|
|
187
|
+
const response = await this.asyncCall(CallMethod.setNodeText, {
|
|
188
|
+
args: { text },
|
|
189
|
+
node,
|
|
190
|
+
timeout,
|
|
191
|
+
});
|
|
192
|
+
return response.getDataOrDefault(false);
|
|
193
|
+
}
|
|
194
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
|
-
|
|
195
|
+
/**
|
|
196
|
+
* 对指定节点进行截图
|
|
197
|
+
* @param nodes 要截图的节点数组
|
|
198
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
199
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
200
|
+
* @returns 截图路径数组
|
|
201
|
+
*/
|
|
202
|
+
public static async takeScreenshotNodes(
|
|
203
|
+
nodes: Node[],
|
|
204
|
+
overlayHiddenScreenshotDelayMillis: number = 250,
|
|
205
|
+
timeout?: number
|
|
206
|
+
): Promise<string[]> {
|
|
207
|
+
const response = await this.asyncCall(CallMethod.takeScreenshot, {
|
|
208
|
+
nodes,
|
|
209
|
+
args: { overlayHiddenScreenshotDelayMillis },
|
|
210
|
+
timeout,
|
|
211
|
+
});
|
|
212
|
+
const data = response.getDataOrDefault("");
|
|
213
|
+
return data.images;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 截图识别文本
|
|
217
|
+
* @param param0 识别参数
|
|
218
|
+
* @returns 截图识别结果
|
|
219
|
+
*/
|
|
220
|
+
public static async recognizeTextInScreenshot(
|
|
221
|
+
targetText: string,
|
|
222
|
+
options: {
|
|
223
|
+
rotationDegrees?: number;
|
|
224
|
+
overlayHiddenScreenshotDelayMillis?: number;
|
|
225
|
+
restoreOverlay?: boolean;
|
|
226
|
+
region?: RecognizeTextRegion;
|
|
227
|
+
timeout?: number;
|
|
228
|
+
} = {}
|
|
229
|
+
): Promise<RecognizeTextInScreenshotResult> {
|
|
230
|
+
const {
|
|
231
|
+
rotationDegrees = 0,
|
|
232
|
+
overlayHiddenScreenshotDelayMillis = 250,
|
|
233
|
+
restoreOverlay = true,
|
|
234
|
+
region,
|
|
235
|
+
timeout,
|
|
236
|
+
} = options;
|
|
237
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
|
-
|
|
238
|
+
const response = await this.asyncCall(
|
|
239
|
+
CallMethod.recognizeTextInScreenshot,
|
|
240
|
+
{
|
|
241
|
+
args: {
|
|
242
|
+
targetText,
|
|
243
|
+
rotationDegrees,
|
|
244
|
+
overlayHiddenScreenshotDelayMillis,
|
|
245
|
+
restoreOverlay,
|
|
246
|
+
region,
|
|
247
|
+
},
|
|
248
|
+
timeout,
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
return response.getDataOrDefault({
|
|
252
|
+
fullText: "",
|
|
253
|
+
processingTimeMillis: 0,
|
|
254
|
+
positions: [],
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
public static async scanQR(timeout?: number): Promise<string> {
|
|
258
|
+
const response = await this.asyncCall(CallMethod.scanQR, { timeout });
|
|
259
|
+
const data = response.getDataOrDefault({ value: "" });
|
|
260
|
+
return data.value;
|
|
261
|
+
}
|
|
262
|
+
public static async loadWebViewOverlay(
|
|
263
|
+
url: string,
|
|
264
|
+
options: WebFloatingWindowOptions & { timeout?: number } = {}
|
|
265
|
+
): Promise<any> {
|
|
266
|
+
const {
|
|
267
|
+
initialWidth,
|
|
268
|
+
initialHeight,
|
|
269
|
+
minWidth,
|
|
270
|
+
minHeight,
|
|
271
|
+
maxWidth,
|
|
272
|
+
maxHeight,
|
|
273
|
+
initialCenter,
|
|
274
|
+
timeout,
|
|
275
|
+
} = options;
|
|
276
|
+
const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
|
|
277
|
+
args: {
|
|
278
|
+
url,
|
|
279
|
+
initialWidth,
|
|
280
|
+
initialHeight,
|
|
281
|
+
minWidth,
|
|
282
|
+
minHeight,
|
|
283
|
+
maxWidth,
|
|
284
|
+
maxHeight,
|
|
285
|
+
initialCenter,
|
|
286
|
+
},
|
|
287
|
+
timeout,
|
|
288
|
+
});
|
|
289
|
+
const data = response.getDataOrDefault({});
|
|
290
|
+
return data;
|
|
291
|
+
}
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
293
|
+
/**
|
|
294
|
+
* 点击节点
|
|
295
|
+
* @param node 要点击的节点
|
|
296
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
297
|
+
* @returns 是否点击成功
|
|
298
|
+
*/
|
|
299
|
+
public static async click(node: Node, timeout?: number): Promise<boolean> {
|
|
300
|
+
const response = await this.asyncCall(CallMethod.click, { node, timeout });
|
|
301
|
+
return response.getDataOrDefault(false);
|
|
302
|
+
}
|
|
303
303
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
304
|
+
/**
|
|
305
|
+
* 长按节点
|
|
306
|
+
* @param node 要长按的节点
|
|
307
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
308
|
+
* @returns 是否长按成功
|
|
309
|
+
*/
|
|
310
|
+
public static async longClick(
|
|
311
|
+
node: Node,
|
|
312
|
+
timeout?: number
|
|
313
|
+
): Promise<boolean> {
|
|
314
|
+
const response = await this.asyncCall(CallMethod.longClick, {
|
|
315
|
+
node,
|
|
316
|
+
timeout,
|
|
317
|
+
});
|
|
318
|
+
return response.getDataOrDefault(false);
|
|
319
|
+
}
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
321
|
+
/**
|
|
322
|
+
* 启动应用
|
|
323
|
+
* @param packageName 应用包名
|
|
324
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
325
|
+
* @returns 是否启动成功
|
|
326
|
+
*/
|
|
327
|
+
public static async launchApp(
|
|
328
|
+
packageName: string,
|
|
329
|
+
timeout?: number
|
|
330
|
+
): Promise<boolean> {
|
|
331
|
+
const response = await this.asyncCall(CallMethod.launchApp, {
|
|
332
|
+
args: { packageName },
|
|
333
|
+
timeout,
|
|
334
|
+
});
|
|
335
|
+
return response.getDataOrDefault(false);
|
|
336
|
+
}
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
338
|
+
/**
|
|
339
|
+
* 获取当前应用包名
|
|
340
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
341
|
+
* @returns 包名
|
|
342
|
+
*/
|
|
343
|
+
public static async getPackageName(timeout?: number): Promise<string> {
|
|
344
|
+
const response = await this.asyncCall(CallMethod.getPackageName, {
|
|
345
|
+
timeout,
|
|
346
|
+
});
|
|
347
|
+
return response.getDataOrDefault("");
|
|
348
|
+
}
|
|
349
349
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
350
|
+
/**
|
|
351
|
+
* 显示悬浮提示
|
|
352
|
+
* @param text 提示文本
|
|
353
|
+
* @param delay 显示时长(毫秒)
|
|
354
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
355
|
+
* @returns 是否显示成功
|
|
356
|
+
*/
|
|
357
|
+
public static async overlayToast(
|
|
358
|
+
text: string,
|
|
359
|
+
delay: number = 2000,
|
|
360
|
+
timeout?: number
|
|
361
|
+
): Promise<boolean> {
|
|
362
|
+
const response = await this.asyncCall(CallMethod.overlayToast, {
|
|
363
|
+
args: { text, delay },
|
|
364
|
+
timeout,
|
|
365
|
+
});
|
|
366
|
+
return response.getDataOrDefault(false);
|
|
367
|
+
}
|
|
368
368
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
369
|
+
/**
|
|
370
|
+
* 通过ID查找节点
|
|
371
|
+
* @param id 节点ID
|
|
372
|
+
* @param filterClass 类名过滤
|
|
373
|
+
* @param filterText 文本过滤
|
|
374
|
+
* @param filterDes 描述过滤
|
|
375
|
+
* @param node 父节点范围
|
|
376
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
377
|
+
* @returns 节点数组
|
|
378
|
+
*/
|
|
379
|
+
public static async findById(
|
|
380
|
+
id: string,
|
|
381
|
+
{
|
|
382
|
+
filterClass,
|
|
383
|
+
filterText,
|
|
384
|
+
filterDes,
|
|
385
|
+
node,
|
|
386
|
+
timeout,
|
|
387
|
+
}: {
|
|
388
|
+
filterClass?: string;
|
|
389
|
+
filterText?: string;
|
|
390
|
+
filterDes?: string;
|
|
391
|
+
node?: Node;
|
|
392
|
+
timeout?: number;
|
|
393
|
+
} = {}
|
|
394
|
+
): Promise<Node[]> {
|
|
395
|
+
const response = await this.asyncCall(CallMethod.findById, {
|
|
396
|
+
args: { id, filterClass, filterText, filterDes },
|
|
397
|
+
node,
|
|
398
|
+
timeout,
|
|
399
|
+
});
|
|
400
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
401
|
+
}
|
|
402
402
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
403
|
+
/**
|
|
404
|
+
* 通过文本查找节点
|
|
405
|
+
* @param text 要查找的文本
|
|
406
|
+
* @param filterClass 类名过滤
|
|
407
|
+
* @param filterViewId 视图ID过滤
|
|
408
|
+
* @param filterDes 描述过滤
|
|
409
|
+
* @param node 父节点范围
|
|
410
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
411
|
+
* @returns 节点数组
|
|
412
|
+
*/
|
|
413
|
+
public static async findByText(
|
|
414
|
+
text: string,
|
|
415
|
+
{
|
|
416
|
+
filterClass,
|
|
417
|
+
filterViewId,
|
|
418
|
+
filterDes,
|
|
419
|
+
node,
|
|
420
|
+
timeout,
|
|
421
|
+
}: {
|
|
422
|
+
filterClass?: string;
|
|
423
|
+
filterViewId?: string;
|
|
424
|
+
filterDes?: string;
|
|
425
|
+
node?: Node;
|
|
426
|
+
timeout?: number;
|
|
427
|
+
} = {}
|
|
428
|
+
): Promise<Node[]> {
|
|
429
|
+
const response = await this.asyncCall(CallMethod.findByText, {
|
|
430
|
+
args: { text, filterClass, filterViewId, filterDes },
|
|
431
|
+
node,
|
|
432
|
+
timeout,
|
|
433
|
+
});
|
|
434
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
435
|
+
}
|
|
436
436
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
437
|
+
/**
|
|
438
|
+
* 通过标签查找节点
|
|
439
|
+
* @param className 类名
|
|
440
|
+
* @param filterText 文本过滤
|
|
441
|
+
* @param filterViewId 视图ID过滤
|
|
442
|
+
* @param filterDes 描述过滤
|
|
443
|
+
* @param node 父节点范围
|
|
444
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
445
|
+
* @returns 节点数组
|
|
446
|
+
*/
|
|
447
|
+
public static async findByTags(
|
|
448
|
+
className: string,
|
|
449
|
+
{
|
|
450
|
+
filterText,
|
|
451
|
+
filterViewId,
|
|
452
|
+
filterDes,
|
|
453
|
+
node,
|
|
454
|
+
timeout,
|
|
455
|
+
}: {
|
|
456
|
+
filterText?: string;
|
|
457
|
+
filterViewId?: string;
|
|
458
|
+
filterDes?: string;
|
|
459
|
+
node?: Node;
|
|
460
|
+
timeout?: number;
|
|
461
|
+
} = {}
|
|
462
|
+
): Promise<Node[]> {
|
|
463
|
+
const response = await this.asyncCall(CallMethod.findByTags, {
|
|
464
|
+
args: { className, filterText, filterViewId, filterDes },
|
|
465
|
+
node,
|
|
466
|
+
timeout,
|
|
467
|
+
});
|
|
468
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
469
|
+
}
|
|
470
470
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
471
|
+
/**
|
|
472
|
+
* 查找所有匹配文本的节点
|
|
473
|
+
* @param text 要查找的文本
|
|
474
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
475
|
+
* @returns 节点数组
|
|
476
|
+
*/
|
|
477
|
+
public static async findByTextAllMatch(
|
|
478
|
+
text: string,
|
|
479
|
+
timeout?: number
|
|
480
|
+
): Promise<Node[]> {
|
|
481
|
+
const response = await this.asyncCall(CallMethod.findByTextAllMatch, {
|
|
482
|
+
args: { text },
|
|
483
|
+
timeout,
|
|
484
|
+
});
|
|
485
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
486
|
+
}
|
|
487
487
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
488
|
+
/**
|
|
489
|
+
* 检查是否包含指定文本
|
|
490
|
+
* @param text 要检查的文本
|
|
491
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
492
|
+
* @returns 是否包含
|
|
493
|
+
*/
|
|
494
|
+
public static async containsText(
|
|
495
|
+
text: string,
|
|
496
|
+
timeout?: number
|
|
497
|
+
): Promise<boolean> {
|
|
498
|
+
const response = await this.asyncCall(CallMethod.containsText, {
|
|
499
|
+
args: { text },
|
|
500
|
+
timeout,
|
|
501
|
+
});
|
|
502
|
+
return response.getDataOrDefault(false);
|
|
503
|
+
}
|
|
504
504
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
505
|
+
/**
|
|
506
|
+
* 获取所有文本
|
|
507
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
508
|
+
* @returns 文本数组
|
|
509
|
+
*/
|
|
510
|
+
public static async getAllText(timeout?: number): Promise<string[]> {
|
|
511
|
+
const response = await this.asyncCall(CallMethod.getAllText, { timeout });
|
|
512
|
+
return response.getDataOrDefault("[]");
|
|
513
|
+
}
|
|
514
514
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
515
|
+
/**
|
|
516
|
+
* 查找第一个匹配标签的父节点
|
|
517
|
+
* @param className 类名
|
|
518
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
519
|
+
* @returns 父节点
|
|
520
|
+
*/
|
|
521
|
+
public static async findFirstParentByTags(
|
|
522
|
+
node: Node,
|
|
523
|
+
className: string,
|
|
524
|
+
timeout?: number
|
|
525
|
+
): Promise<Node> {
|
|
526
|
+
const response = await this.asyncCall(CallMethod.findFirstParentByTags, {
|
|
527
|
+
args: { className },
|
|
528
|
+
node,
|
|
529
|
+
timeout,
|
|
530
|
+
});
|
|
531
|
+
return Node.create(response.getDataOrDefault("{}"));
|
|
532
|
+
}
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
534
|
+
/**
|
|
535
|
+
* 获取节点的所有子节点
|
|
536
|
+
* @param node 父节点
|
|
537
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
538
|
+
* @returns 子节点数组
|
|
539
|
+
*/
|
|
540
|
+
public static async getNodes(node: Node, timeout?: number): Promise<Node[]> {
|
|
541
|
+
const response = await this.asyncCall(CallMethod.getNodes, {
|
|
542
|
+
node,
|
|
543
|
+
timeout,
|
|
544
|
+
});
|
|
545
|
+
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
546
|
+
}
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
548
|
+
/**
|
|
549
|
+
* 获取节点的直接子节点
|
|
550
|
+
* @param node 父节点
|
|
551
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
552
|
+
* @returns 子节点数组
|
|
553
|
+
*/
|
|
554
|
+
public static async getChildren(
|
|
555
|
+
node: Node,
|
|
556
|
+
timeout?: number
|
|
557
|
+
): Promise<Node[]> {
|
|
558
|
+
const response = await this.asyncCall(CallMethod.getChildren, {
|
|
559
|
+
node,
|
|
560
|
+
timeout,
|
|
561
|
+
});
|
|
562
|
+
return Node.fromJSONArray(response.getDataOrDefault([]));
|
|
563
|
+
}
|
|
564
564
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
565
|
+
/**
|
|
566
|
+
* 查找第一个可点击的父节点
|
|
567
|
+
* @param node 起始节点
|
|
568
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
569
|
+
* @returns 可点击的父节点
|
|
570
|
+
*/
|
|
571
|
+
public static async findFirstParentClickable(
|
|
572
|
+
node: Node,
|
|
573
|
+
timeout?: number
|
|
574
|
+
): Promise<Node> {
|
|
575
|
+
const response = await this.asyncCall(CallMethod.findFirstParentClickable, {
|
|
576
|
+
node,
|
|
577
|
+
timeout,
|
|
578
|
+
});
|
|
579
|
+
return Node.create(response.getDataOrDefault("{}"));
|
|
580
|
+
}
|
|
581
581
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
582
|
+
/**
|
|
583
|
+
* 获取节点在屏幕中的边界
|
|
584
|
+
* @param node 目标节点
|
|
585
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
586
|
+
* @returns 边界对象
|
|
587
|
+
*/
|
|
588
|
+
public static async getBoundsInScreen(
|
|
589
|
+
node: Node,
|
|
590
|
+
timeout?: number
|
|
591
|
+
): Promise<Bounds> {
|
|
592
|
+
const response = await this.asyncCall(CallMethod.getBoundsInScreen, {
|
|
593
|
+
node,
|
|
594
|
+
timeout,
|
|
595
|
+
});
|
|
596
|
+
return Bounds.fromData(response.getDataOrDefault({}));
|
|
597
|
+
}
|
|
598
598
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
599
|
+
/**
|
|
600
|
+
* 检查节点是否可见
|
|
601
|
+
* @param node 目标节点
|
|
602
|
+
* @param compareNode 比较节点
|
|
603
|
+
* @param isFullyByCompareNode 是否完全可见
|
|
604
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
605
|
+
* @returns 是否可见
|
|
606
|
+
*/
|
|
607
|
+
public static async isVisible(
|
|
608
|
+
node: Node,
|
|
609
|
+
{
|
|
610
|
+
compareNode,
|
|
611
|
+
isFullyByCompareNode,
|
|
612
|
+
timeout,
|
|
613
|
+
}: {
|
|
614
|
+
compareNode?: Node;
|
|
615
|
+
isFullyByCompareNode?: boolean;
|
|
616
|
+
timeout?: number;
|
|
617
|
+
} = {}
|
|
618
|
+
): Promise<boolean> {
|
|
619
|
+
const response = await this.asyncCall(CallMethod.isVisible, {
|
|
620
|
+
node,
|
|
621
|
+
args: { compareNode, isFullyByCompareNode },
|
|
622
|
+
timeout,
|
|
623
|
+
});
|
|
624
|
+
return response.getDataOrDefault(false);
|
|
625
|
+
}
|
|
626
626
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
627
|
+
/**
|
|
628
|
+
* 执行点击手势
|
|
629
|
+
* @param x 横坐标
|
|
630
|
+
* @param y 纵坐标
|
|
631
|
+
* @param duration 持续时间
|
|
632
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
633
|
+
* @returns 是否成功
|
|
634
|
+
*/
|
|
635
|
+
public static async clickByGesture(
|
|
636
|
+
x: number,
|
|
637
|
+
y: number,
|
|
638
|
+
duration: number,
|
|
639
|
+
timeout?: number
|
|
640
|
+
): Promise<boolean> {
|
|
641
|
+
const response = await this.asyncCall(CallMethod.clickByGesture, {
|
|
642
|
+
args: { x, y, duration },
|
|
643
|
+
timeout,
|
|
644
|
+
});
|
|
645
|
+
return response.getDataOrDefault(false);
|
|
646
|
+
}
|
|
647
647
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
648
|
+
/**
|
|
649
|
+
* 返回操作
|
|
650
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
651
|
+
* @returns 是否成功
|
|
652
|
+
*/
|
|
653
|
+
public static async back(timeout?: number): Promise<boolean> {
|
|
654
|
+
const response = await this.asyncCall(CallMethod.back, { timeout });
|
|
655
|
+
return response.getDataOrDefault(false);
|
|
656
|
+
}
|
|
657
657
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
658
|
+
/**
|
|
659
|
+
* 回到主页
|
|
660
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
661
|
+
* @returns 是否成功
|
|
662
|
+
*/
|
|
663
|
+
public static async home(timeout?: number): Promise<boolean> {
|
|
664
|
+
const response = await this.asyncCall(CallMethod.home, { timeout });
|
|
665
|
+
return response.getDataOrDefault(false);
|
|
666
|
+
}
|
|
667
667
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
668
|
+
/**
|
|
669
|
+
* 打开通知栏
|
|
670
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
671
|
+
* @returns 是否成功
|
|
672
|
+
*/
|
|
673
|
+
public static async notifications(timeout?: number): Promise<boolean> {
|
|
674
|
+
const response = await this.asyncCall(CallMethod.notifications, {
|
|
675
|
+
timeout,
|
|
676
|
+
});
|
|
677
|
+
return response.getDataOrDefault(false);
|
|
678
|
+
}
|
|
679
679
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
680
|
+
/**
|
|
681
|
+
* 显示最近应用
|
|
682
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
683
|
+
* @returns 是否成功
|
|
684
|
+
*/
|
|
685
|
+
public static async recentApps(timeout?: number): Promise<boolean> {
|
|
686
|
+
const response = await this.asyncCall(CallMethod.recentApps, { timeout });
|
|
687
|
+
return response.getDataOrDefault(false);
|
|
688
|
+
}
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
690
|
+
/**
|
|
691
|
+
* 在节点中粘贴文本
|
|
692
|
+
* @param node 目标节点
|
|
693
|
+
* @param text 要粘贴的文本
|
|
694
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
695
|
+
* @returns 是否成功
|
|
696
|
+
*/
|
|
697
|
+
public static async paste(
|
|
698
|
+
node: Node,
|
|
699
|
+
text: string,
|
|
700
|
+
timeout?: number
|
|
701
|
+
): Promise<boolean> {
|
|
702
|
+
const response = await this.asyncCall(CallMethod.paste, {
|
|
703
|
+
args: { text },
|
|
704
|
+
node,
|
|
705
|
+
timeout,
|
|
706
|
+
});
|
|
707
|
+
return response.getDataOrDefault(false);
|
|
708
|
+
}
|
|
709
|
+
public static async focus(node: Node, timeout?: number): Promise<boolean> {
|
|
710
|
+
const response = await this.asyncCall(CallMethod.focus, { node, timeout });
|
|
711
|
+
return response.getDataOrDefault(false);
|
|
712
|
+
}
|
|
713
713
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
714
|
+
/**
|
|
715
|
+
* 选择文本
|
|
716
|
+
* @param node 目标节点
|
|
717
|
+
* @param selectionStart 选择起始位置
|
|
718
|
+
* @param selectionEnd 选择结束位置
|
|
719
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
720
|
+
* @returns 是否成功
|
|
721
|
+
*/
|
|
722
|
+
public static async selectionText(
|
|
723
|
+
node: Node,
|
|
724
|
+
selectionStart: number,
|
|
725
|
+
selectionEnd: number,
|
|
726
|
+
timeout?: number
|
|
727
|
+
): Promise<boolean> {
|
|
728
|
+
const response = await this.asyncCall(CallMethod.selectionText, {
|
|
729
|
+
args: { selectionStart, selectionEnd },
|
|
730
|
+
node,
|
|
731
|
+
timeout,
|
|
732
|
+
});
|
|
733
|
+
return response.getDataOrDefault(false);
|
|
734
|
+
}
|
|
735
735
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
736
|
+
/**
|
|
737
|
+
* 向前滚动
|
|
738
|
+
* @param node 可滚动节点
|
|
739
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
740
|
+
* @returns 是否成功
|
|
741
|
+
*/
|
|
742
|
+
public static async scrollForward(
|
|
743
|
+
node: Node,
|
|
744
|
+
timeout?: number
|
|
745
|
+
): Promise<boolean> {
|
|
746
|
+
const response = await this.asyncCall(CallMethod.scrollForward, {
|
|
747
|
+
node,
|
|
748
|
+
timeout,
|
|
749
|
+
});
|
|
750
|
+
return response.getDataOrDefault(false);
|
|
751
|
+
}
|
|
752
752
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
753
|
+
/**
|
|
754
|
+
* 向后滚动
|
|
755
|
+
* @param node 可滚动节点
|
|
756
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
757
|
+
* @returns 是否成功
|
|
758
|
+
*/
|
|
759
|
+
public static async scrollBackward(
|
|
760
|
+
node: Node,
|
|
761
|
+
timeout?: number
|
|
762
|
+
): Promise<boolean> {
|
|
763
|
+
const response = await this.asyncCall(CallMethod.scrollBackward, {
|
|
764
|
+
node,
|
|
765
|
+
timeout,
|
|
766
|
+
});
|
|
767
|
+
return response.getDataOrDefault(false);
|
|
768
|
+
}
|
|
769
769
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
770
|
+
/**
|
|
771
|
+
* 对节点执行点击手势
|
|
772
|
+
* @param node 目标节点
|
|
773
|
+
* @param offsetX X轴偏移
|
|
774
|
+
* @param offsetY Y轴偏移
|
|
775
|
+
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
776
|
+
* @param clickDuration 点击持续时间
|
|
777
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
778
|
+
* @returns 是否成功
|
|
779
|
+
*/
|
|
780
|
+
public static async clickNodeByGesture(
|
|
781
|
+
node: Node,
|
|
782
|
+
{
|
|
783
|
+
offsetX,
|
|
784
|
+
offsetY,
|
|
785
|
+
switchWindowIntervalDelay,
|
|
786
|
+
clickDuration,
|
|
787
|
+
timeout,
|
|
788
|
+
}: {
|
|
789
|
+
offsetX?: number;
|
|
790
|
+
offsetY?: number;
|
|
791
|
+
switchWindowIntervalDelay?: number;
|
|
792
|
+
clickDuration?: number;
|
|
793
|
+
timeout?: number;
|
|
794
|
+
} = {}
|
|
795
|
+
): Promise<boolean> {
|
|
796
|
+
const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
|
|
797
|
+
node,
|
|
798
|
+
args: { offsetX, offsetY, switchWindowIntervalDelay, clickDuration },
|
|
799
|
+
timeout,
|
|
800
|
+
});
|
|
801
|
+
return response.getDataOrDefault(false);
|
|
802
|
+
}
|
|
803
803
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
804
|
+
/**
|
|
805
|
+
* 对节点执行双击手势
|
|
806
|
+
* @param node 目标节点
|
|
807
|
+
* @param offsetX X轴偏移
|
|
808
|
+
* @param offsetY Y轴偏移
|
|
809
|
+
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
810
|
+
* @param clickDuration 点击持续时间
|
|
811
|
+
* @param clickInterval 点击间隔
|
|
812
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
813
|
+
* @returns 是否成功
|
|
814
|
+
*/
|
|
815
|
+
public static async doubleClickNodeByGesture(
|
|
816
|
+
node: Node,
|
|
817
|
+
{
|
|
818
|
+
offsetX,
|
|
819
|
+
offsetY,
|
|
820
|
+
switchWindowIntervalDelay,
|
|
821
|
+
clickDuration,
|
|
822
|
+
clickInterval,
|
|
823
|
+
timeout,
|
|
824
|
+
}: {
|
|
825
|
+
offsetX?: number;
|
|
826
|
+
offsetY?: number;
|
|
827
|
+
switchWindowIntervalDelay?: number;
|
|
828
|
+
clickDuration?: number;
|
|
829
|
+
clickInterval?: number;
|
|
830
|
+
timeout?: number;
|
|
831
|
+
} = {}
|
|
832
|
+
): Promise<boolean> {
|
|
833
|
+
const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
|
|
834
|
+
node,
|
|
835
|
+
args: {
|
|
836
|
+
offsetX,
|
|
837
|
+
offsetY,
|
|
838
|
+
switchWindowIntervalDelay,
|
|
839
|
+
clickDuration,
|
|
840
|
+
clickInterval,
|
|
841
|
+
},
|
|
842
|
+
timeout,
|
|
843
|
+
});
|
|
844
|
+
return response.getDataOrDefault(false);
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* 执行线型手势
|
|
848
|
+
* @param startPoint
|
|
849
|
+
* @param endPoint
|
|
850
|
+
* @param param2
|
|
851
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
852
|
+
* @returns
|
|
853
|
+
*/
|
|
854
|
+
public static async performLinearGesture(
|
|
855
|
+
startPoint: { x: number; y: number },
|
|
856
|
+
endPoint: { x: number; y: number },
|
|
857
|
+
{ duration, timeout }: { duration?: number; timeout?: number } = {}
|
|
858
|
+
): Promise<boolean> {
|
|
859
|
+
const response = await this.asyncCall(CallMethod.performLinearGesture, {
|
|
860
|
+
args: { startPoint, endPoint, duration },
|
|
861
|
+
timeout,
|
|
862
|
+
});
|
|
863
|
+
return response.getDataOrDefault(false);
|
|
864
|
+
}
|
|
865
|
+
public static async longPressNodeByGestureAutoPaste(
|
|
866
|
+
node: Node,
|
|
867
|
+
text: string,
|
|
868
|
+
{
|
|
869
|
+
matchedPackageName,
|
|
870
|
+
matchedText,
|
|
871
|
+
timeoutMillis,
|
|
872
|
+
longPressDuration,
|
|
873
|
+
timeout,
|
|
874
|
+
}: {
|
|
875
|
+
matchedPackageName?: string;
|
|
876
|
+
matchedText?: string;
|
|
877
|
+
timeoutMillis?: number;
|
|
878
|
+
longPressDuration?: number;
|
|
879
|
+
timeout?: number;
|
|
880
|
+
} = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
|
|
881
|
+
): Promise<boolean> {
|
|
882
|
+
const response = await this.asyncCall(
|
|
883
|
+
CallMethod.longPressGestureAutoPaste,
|
|
884
|
+
{
|
|
885
|
+
node,
|
|
886
|
+
args: {
|
|
887
|
+
text,
|
|
888
|
+
matchedPackageName,
|
|
889
|
+
matchedText,
|
|
890
|
+
timeoutMillis,
|
|
891
|
+
longPressDuration,
|
|
892
|
+
},
|
|
893
|
+
timeout,
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
return response.getDataOrDefault(false);
|
|
897
|
+
}
|
|
898
898
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
899
|
+
public static async longPressGestureAutoPaste(
|
|
900
|
+
point: { x: number; y: number },
|
|
901
|
+
text: string,
|
|
902
|
+
{
|
|
903
|
+
matchedPackageName,
|
|
904
|
+
matchedText,
|
|
905
|
+
timeoutMillis,
|
|
906
|
+
longPressDuration,
|
|
907
|
+
timeout,
|
|
908
|
+
}: {
|
|
909
|
+
matchedPackageName?: string;
|
|
910
|
+
matchedText?: string;
|
|
911
|
+
timeoutMillis?: number;
|
|
912
|
+
longPressDuration?: number;
|
|
913
|
+
timeout?: number;
|
|
914
|
+
} = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
|
|
915
|
+
): Promise<boolean> {
|
|
916
|
+
const response = await this.asyncCall(
|
|
917
|
+
CallMethod.longPressGestureAutoPaste,
|
|
918
|
+
{
|
|
919
|
+
args: {
|
|
920
|
+
point,
|
|
921
|
+
text,
|
|
922
|
+
matchedPackageName,
|
|
923
|
+
matchedText,
|
|
924
|
+
timeoutMillis,
|
|
925
|
+
longPressDuration,
|
|
926
|
+
},
|
|
927
|
+
timeout,
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
return response.getDataOrDefault(false);
|
|
931
|
+
}
|
|
932
|
+
public static async getAppInfo(
|
|
933
|
+
packageName: string,
|
|
934
|
+
timeout?: number
|
|
935
|
+
): Promise<AppInfo> {
|
|
936
|
+
const response = await this.asyncCall(CallMethod.getAppInfo, {
|
|
937
|
+
args: { packageName },
|
|
938
|
+
timeout,
|
|
939
|
+
});
|
|
940
|
+
return AppInfo.fromJSON(response.getDataOrDefault({}));
|
|
941
|
+
}
|
|
942
|
+
public static async getUniqueDeviceId(timeout?: number): Promise<any> {
|
|
943
|
+
const response = await this.asyncCall(CallMethod.getUniqueDeviceId, {
|
|
944
|
+
timeout,
|
|
945
|
+
});
|
|
946
|
+
return response.getDataOrDefault("");
|
|
947
|
+
}
|
|
948
|
+
public static async getAndroidID(timeout?: number): Promise<any> {
|
|
949
|
+
const response = await this.asyncCall(CallMethod.getAndroidID, { timeout });
|
|
950
|
+
return response.getDataOrDefault("");
|
|
951
|
+
}
|
|
952
|
+
public static async getMacAddress(timeout?: number): Promise<any> {
|
|
953
|
+
const response = await this.asyncCall(CallMethod.getMacAddress, {
|
|
954
|
+
timeout,
|
|
955
|
+
});
|
|
956
|
+
return response.getDataOrDefault({});
|
|
957
|
+
}
|
|
958
|
+
public static async getDeviceInfo(timeout?: number): Promise<DeviceInfo> {
|
|
959
|
+
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
960
|
+
timeout,
|
|
961
|
+
});
|
|
962
|
+
return DeviceInfo.fromJSON(response.getDataOrDefault({}));
|
|
963
|
+
}
|
|
964
964
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
965
|
+
/**
|
|
966
|
+
* 获取屏幕尺寸
|
|
967
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
968
|
+
* @returns 屏幕尺寸对象
|
|
969
|
+
*/
|
|
970
|
+
public static async getScreenSize(timeout?: number): Promise<any> {
|
|
971
|
+
const response = await this.asyncCall(CallMethod.getScreenSize, {
|
|
972
|
+
timeout,
|
|
973
|
+
});
|
|
974
|
+
return response.getDataOrDefault("{}");
|
|
975
|
+
}
|
|
976
976
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
977
|
+
/**
|
|
978
|
+
* 获取应用窗口尺寸
|
|
979
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
980
|
+
* @returns 应用窗口尺寸对象
|
|
981
|
+
*/
|
|
982
|
+
public static async getAppScreenSize(timeout?: number): Promise<any> {
|
|
983
|
+
const response = await this.asyncCall(CallMethod.getAppScreenSize, {
|
|
984
|
+
timeout,
|
|
985
|
+
});
|
|
986
|
+
return response.getDataOrDefault("{}");
|
|
987
|
+
}
|
|
988
988
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
989
|
+
/**
|
|
990
|
+
* 在浏览器中打开URL
|
|
991
|
+
* @param url 要打开的URL
|
|
992
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
993
|
+
* @returns 是否成功打开
|
|
994
|
+
*/
|
|
995
|
+
public static async openUrlInBrowser(
|
|
996
|
+
url: string,
|
|
997
|
+
timeout?: number
|
|
998
|
+
): Promise<boolean> {
|
|
999
|
+
const response = await this.asyncCall(CallMethod.openUrlInBrowser, {
|
|
1000
|
+
args: { url },
|
|
1001
|
+
timeout,
|
|
1002
|
+
});
|
|
1003
|
+
return response.getDataOrDefault(false);
|
|
1004
|
+
}
|
|
1005
|
+
public static async download(
|
|
1006
|
+
url: string,
|
|
1007
|
+
timeout?: number
|
|
1008
|
+
): Promise<string | null | undefined> {
|
|
1009
|
+
const response = await this.asyncCall(CallMethod.download, {
|
|
1010
|
+
args: { url },
|
|
1011
|
+
timeout,
|
|
1012
|
+
});
|
|
1013
|
+
return response.getDataOrDefault(null);
|
|
1014
|
+
}
|
|
1015
|
+
public static async audioPlayFromFile(
|
|
1016
|
+
filePath: string,
|
|
1017
|
+
{
|
|
1018
|
+
volume = undefined,
|
|
1019
|
+
useAbsoluteVolume = false,
|
|
1020
|
+
timeout = 30,
|
|
1021
|
+
}: {
|
|
1022
|
+
volume?: number;
|
|
1023
|
+
useAbsoluteVolume?: boolean;
|
|
1024
|
+
timeout?: number;
|
|
1025
|
+
}
|
|
1026
|
+
): Promise<string | null | undefined> {
|
|
1027
|
+
const response = await this.asyncCall(CallMethod.audioPlayFromFile, {
|
|
1028
|
+
args: { filePath, volume, useAbsoluteVolume },
|
|
1029
|
+
timeout,
|
|
1030
|
+
});
|
|
1031
|
+
return response.getDataOrDefault(null);
|
|
1032
|
+
}
|
|
1033
|
+
public static async audioStop({
|
|
1034
|
+
timeout = 30,
|
|
1021
1035
|
}: {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1036
|
+
timeout?: number;
|
|
1037
|
+
}): Promise<boolean | null | undefined> {
|
|
1038
|
+
const response = await this.asyncCall(CallMethod.audioStop, {
|
|
1039
|
+
timeout,
|
|
1040
|
+
});
|
|
1041
|
+
return response.getDataOrDefault(false);
|
|
1025
1042
|
}
|
|
1026
|
-
): Promise<string | null | undefined> {
|
|
1027
|
-
const response = await this.asyncCall(CallMethod.audioPlayFromFile, {
|
|
1028
|
-
args: { filePath, volume, useAbsoluteVolume },
|
|
1029
|
-
timeout,
|
|
1030
|
-
});
|
|
1031
|
-
return response.getDataOrDefault(null);
|
|
1032
|
-
}
|
|
1033
|
-
public static async audioStop({
|
|
1034
|
-
timeout = 30,
|
|
1035
|
-
}: {
|
|
1036
|
-
timeout?: number;
|
|
1037
|
-
}): Promise<boolean | null | undefined> {
|
|
1038
|
-
const response = await this.asyncCall(CallMethod.audioStop, {
|
|
1039
|
-
timeout,
|
|
1040
|
-
});
|
|
1041
|
-
return response.getDataOrDefault(false);
|
|
1042
|
-
}
|
|
1043
1043
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* 播放系统电话铃声
|
|
1046
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
1047
|
+
* @returns 播放结果消息
|
|
1048
|
+
*/
|
|
1049
|
+
public static async audioPlayRingtone({
|
|
1050
|
+
timeout = 30,
|
|
1051
|
+
}: {
|
|
1052
|
+
timeout?: number;
|
|
1053
|
+
}): Promise<string> {
|
|
1054
|
+
const response = await this.asyncCall(CallMethod.audioPlayRingtone, {
|
|
1055
|
+
timeout,
|
|
1056
|
+
});
|
|
1057
|
+
return response.getDataOrDefault("");
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* 停止播放系统电话铃声
|
|
1062
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
1063
|
+
* @returns 停止结果消息
|
|
1064
|
+
*/
|
|
1065
|
+
public static async audioStopRingtone({
|
|
1066
|
+
timeout = 30,
|
|
1067
|
+
}: {
|
|
1068
|
+
timeout?: number;
|
|
1069
|
+
}): Promise<string> {
|
|
1070
|
+
const response = await this.asyncCall(CallMethod.audioStopRingtone, {
|
|
1071
|
+
timeout,
|
|
1072
|
+
});
|
|
1073
|
+
return response.getDataOrDefault("");
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* 添加联系人
|
|
1078
|
+
* @param name 联系人姓名(必填)
|
|
1079
|
+
* @param phoneNumber 电话号码(必填)
|
|
1080
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
1081
|
+
* @returns 是否添加成功
|
|
1082
|
+
*/
|
|
1083
|
+
public static async addContact(
|
|
1084
|
+
name: string,
|
|
1085
|
+
phoneNumber: string,
|
|
1086
|
+
timeout?: number
|
|
1087
|
+
): Promise<boolean> {
|
|
1088
|
+
const response = await this.asyncCall(CallMethod.addContact, {
|
|
1089
|
+
args: { name, phoneNumber },
|
|
1090
|
+
timeout,
|
|
1091
|
+
});
|
|
1092
|
+
return response.getDataOrDefault(false);
|
|
1093
|
+
}
|
|
1062
1094
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1095
|
+
/**
|
|
1096
|
+
* 获取所有联系人
|
|
1097
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
1098
|
+
* @returns 联系人列表
|
|
1099
|
+
*/
|
|
1100
|
+
public static async getAllContacts(timeout?: number): Promise<Contact[]> {
|
|
1101
|
+
const response = await this.asyncCall(CallMethod.getAllContacts, {
|
|
1102
|
+
timeout,
|
|
1103
|
+
});
|
|
1104
|
+
return response.getDataOrDefault([]);
|
|
1105
|
+
}
|
|
1074
1106
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* 发送HTTP请求
|
|
1109
|
+
* @param options 请求选项
|
|
1110
|
+
* @returns HTTP响应
|
|
1111
|
+
*/
|
|
1112
|
+
// public static async httpRequest(
|
|
1113
|
+
// options: HttpRequestOptions
|
|
1114
|
+
// ): Promise<HttpResponse> {
|
|
1115
|
+
// const { url, method = "GET", headers, body, timeout = 30 } = options;
|
|
1116
|
+
// const response = await this.asyncCall(CallMethod.httpRequest, {
|
|
1117
|
+
// args: { url, method, headers, body, timeout },
|
|
1118
|
+
// });
|
|
1119
|
+
// return response.getDataOrDefault({
|
|
1120
|
+
// statusCode: -1,
|
|
1121
|
+
// statusMessage: "",
|
|
1122
|
+
// body: "",
|
|
1123
|
+
// headers: {},
|
|
1124
|
+
// });
|
|
1125
|
+
// }
|
|
1094
1126
|
}
|