appium-android-driver 5.14.7 → 6.0.1
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/CHANGELOG.md +7 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/{desired-caps.js → constraints.js} +103 -102
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +26 -19
- package/build/index.js +0 -51
- package/build/lib/android-helpers.d.ts +0 -136
- package/build/lib/android-helpers.d.ts.map +0 -1
- package/build/lib/android-helpers.js +0 -855
- package/build/lib/android-helpers.js.map +0 -1
- package/build/lib/commands/coverage.d.ts +0 -5
- package/build/lib/commands/coverage.d.ts.map +0 -1
- package/build/lib/commands/coverage.js +0 -19
- package/build/lib/commands/coverage.js.map +0 -1
- package/build/lib/desired-caps.d.ts +0 -353
- package/build/lib/desired-caps.d.ts.map +0 -1
- package/build/lib/desired-caps.js.map +0 -1
- package/build/lib/unlock-helpers.d.ts +0 -38
- package/build/lib/unlock-helpers.d.ts.map +0 -1
- package/build/lib/unlock-helpers.js +0 -266
- package/build/lib/unlock-helpers.js.map +0 -1
- package/build/lib/webview-helpers.d.ts +0 -224
- package/build/lib/webview-helpers.d.ts.map +0 -1
- package/build/lib/webview-helpers.js +0 -528
- package/build/lib/webview-helpers.js.map +0 -1
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @ts-check
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.commands = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const asyncbox_1 = require("asyncbox");
|
|
9
7
|
const support_1 = require("@appium/support");
|
|
10
|
-
const
|
|
8
|
+
const asyncbox_1 = require("asyncbox");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
11
10
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
const teen_process_1 = require("teen_process");
|
|
12
|
+
const mixins_1 = require("./mixins");
|
|
14
13
|
const RETRY_PAUSE = 300;
|
|
15
14
|
const RETRY_TIMEOUT = 5000;
|
|
16
15
|
const MAX_RECORDING_TIME_SEC = 60 * 3;
|
|
@@ -21,11 +20,21 @@ const SCREENRECORD_BINARY = 'screenrecord';
|
|
|
21
20
|
const DEFAULT_EXT = '.mp4';
|
|
22
21
|
const MIN_EMULATOR_API_LEVEL = 27;
|
|
23
22
|
const FFMPEG_BINARY = `ffmpeg${support_1.system.isWindows() ? '.exe' : ''}`;
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {string} localFile
|
|
26
|
+
* @param {string} [remotePath]
|
|
27
|
+
* @param {import('./types').StopScreenRecordingOpts} uploadOptions
|
|
28
|
+
* @returns {Promise<string>}
|
|
29
|
+
*/
|
|
30
|
+
async function uploadRecordedMedia(localFile, remotePath, uploadOptions = {}) {
|
|
25
31
|
if (lodash_1.default.isEmpty(remotePath)) {
|
|
26
32
|
return (await support_1.util.toInMemoryBase64(localFile)).toString();
|
|
27
33
|
}
|
|
28
34
|
const { user, pass, method, headers, fileFieldName, formFields } = uploadOptions;
|
|
35
|
+
/**
|
|
36
|
+
* @type {import('@appium/support').NetOptions & import('@appium/support').HttpUploadOptions}
|
|
37
|
+
*/
|
|
29
38
|
const options = {
|
|
30
39
|
method: method || 'PUT',
|
|
31
40
|
headers,
|
|
@@ -35,9 +44,14 @@ async function uploadRecordedMedia(localFile, remotePath = null, uploadOptions =
|
|
|
35
44
|
if (user && pass) {
|
|
36
45
|
options.auth = { user, pass };
|
|
37
46
|
}
|
|
38
|
-
await support_1.net.uploadFile(localFile, remotePath, options);
|
|
47
|
+
await support_1.net.uploadFile(localFile, /** @type {string} */ (remotePath), options);
|
|
39
48
|
return '';
|
|
40
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {ADB} adb
|
|
53
|
+
* @param {boolean} isEmulator
|
|
54
|
+
*/
|
|
41
55
|
async function verifyScreenRecordIsSupported(adb, isEmulator) {
|
|
42
56
|
const apiLevel = await adb.getApiLevel();
|
|
43
57
|
if (isEmulator && apiLevel < MIN_EMULATOR_API_LEVEL) {
|
|
@@ -47,11 +61,18 @@ async function verifyScreenRecordIsSupported(adb, isEmulator) {
|
|
|
47
61
|
throw new Error(`Screen recording not available on API Level ${apiLevel}. Minimum API Level is 19.`);
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
|
-
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {ADB} adb
|
|
67
|
+
* @param {import('@appium/types').StringRecord} recordingProperties
|
|
68
|
+
* @param {import('@appium/types').AppiumLogger} [log]
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
async function scheduleScreenRecord(adb, recordingProperties, log) {
|
|
51
72
|
if (recordingProperties.stopped) {
|
|
52
73
|
return;
|
|
53
74
|
}
|
|
54
|
-
const { timer, videoSize, bitRate, timeLimit, bugReport
|
|
75
|
+
const { timer, videoSize, bitRate, timeLimit, bugReport } = recordingProperties;
|
|
55
76
|
let currentTimeLimit = MAX_RECORDING_TIME_SEC;
|
|
56
77
|
if (support_1.util.hasValue(recordingProperties.currentTimeLimit)) {
|
|
57
78
|
const currentTimeLimitInt = parseInt(recordingProperties.currentTimeLimit, 10);
|
|
@@ -88,14 +109,17 @@ async function scheduleScreenRecord(adb, recordingProperties, log = null) {
|
|
|
88
109
|
await scheduleScreenRecord(adb, recordingProperties, log);
|
|
89
110
|
}
|
|
90
111
|
catch (e) {
|
|
91
|
-
log?.error(e.stack);
|
|
112
|
+
log?.error(/** @type {Error} */ (e).stack);
|
|
92
113
|
recordingProperties.stopped = true;
|
|
93
114
|
}
|
|
94
115
|
})();
|
|
95
116
|
});
|
|
96
117
|
await recordingProc.start(0);
|
|
97
118
|
try {
|
|
98
|
-
await (0, asyncbox_1.waitForCondition)(async () => await adb.fileExists(pathOnDevice), {
|
|
119
|
+
await (0, asyncbox_1.waitForCondition)(async () => await adb.fileExists(pathOnDevice), {
|
|
120
|
+
waitMs: RETRY_TIMEOUT,
|
|
121
|
+
intervalMs: RETRY_PAUSE,
|
|
122
|
+
});
|
|
99
123
|
}
|
|
100
124
|
catch (e) {
|
|
101
125
|
throw new Error(`The expected screen record file '${pathOnDevice}' does not exist after ${RETRY_TIMEOUT}ms. ` +
|
|
@@ -104,28 +128,37 @@ async function scheduleScreenRecord(adb, recordingProperties, log = null) {
|
|
|
104
128
|
recordingProperties.records.push(pathOnDevice);
|
|
105
129
|
recordingProperties.recordingProcess = recordingProc;
|
|
106
130
|
}
|
|
107
|
-
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* @param {string[]} mediaFiles
|
|
134
|
+
* @param {import('@appium/types').AppiumLogger} [log]
|
|
135
|
+
* @returns {Promise<string>}
|
|
136
|
+
*/
|
|
137
|
+
async function mergeScreenRecords(mediaFiles, log) {
|
|
108
138
|
try {
|
|
109
139
|
await support_1.fs.which(FFMPEG_BINARY);
|
|
110
140
|
}
|
|
111
141
|
catch (e) {
|
|
112
142
|
throw new Error(`${FFMPEG_BINARY} utility is not available in PATH. Please install it from https://www.ffmpeg.org/`);
|
|
113
143
|
}
|
|
114
|
-
const configContent = mediaFiles
|
|
115
|
-
.map((x) => `file '${x}'`)
|
|
116
|
-
.join('\n');
|
|
144
|
+
const configContent = mediaFiles.map((x) => `file '${x}'`).join('\n');
|
|
117
145
|
const configFile = path_1.default.resolve(path_1.default.dirname(mediaFiles[0]), 'config.txt');
|
|
118
146
|
await support_1.fs.writeFile(configFile, configContent, 'utf8');
|
|
119
147
|
log?.debug(`Generated ffmpeg merging config '${configFile}' with items:\n${configContent}`);
|
|
120
|
-
const result = path_1.default.resolve(path_1.default.dirname(mediaFiles[0]), `merge_${Math.floor(new Date())}${DEFAULT_EXT}`);
|
|
148
|
+
const result = path_1.default.resolve(path_1.default.dirname(mediaFiles[0]), `merge_${Math.floor(+new Date())}${DEFAULT_EXT}`);
|
|
121
149
|
const args = ['-safe', '0', '-f', 'concat', '-i', configFile, '-c', 'copy', result];
|
|
122
150
|
log?.info(`Initiating screen records merging using the command '${FFMPEG_BINARY} ${args.join(' ')}'`);
|
|
123
151
|
await (0, teen_process_1.exec)(FFMPEG_BINARY, args);
|
|
124
152
|
return result;
|
|
125
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* @param {ADB} adb
|
|
157
|
+
* @param {boolean} force
|
|
158
|
+
* @returns {Promise<boolean>}
|
|
159
|
+
*/
|
|
126
160
|
async function terminateBackgroundScreenRecording(adb, force = true) {
|
|
127
|
-
const pids = (await adb.getPIDsByName(SCREENRECORD_BINARY))
|
|
128
|
-
.map((p) => `${p}`);
|
|
161
|
+
const pids = (await adb.getPIDsByName(SCREENRECORD_BINARY)).map((p) => `${p}`);
|
|
129
162
|
if (lodash_1.default.isEmpty(pids)) {
|
|
130
163
|
return false;
|
|
131
164
|
}
|
|
@@ -138,185 +171,121 @@ async function terminateBackgroundScreenRecording(adb, force = true) {
|
|
|
138
171
|
return true;
|
|
139
172
|
}
|
|
140
173
|
catch (err) {
|
|
141
|
-
throw new Error(`Unable to stop the background screen recording: ${err.message}`);
|
|
174
|
+
throw new Error(`Unable to stop the background screen recording: ${ /** @type {Error} */(err).message}`);
|
|
142
175
|
}
|
|
143
176
|
}
|
|
144
177
|
/**
|
|
145
|
-
* @
|
|
146
|
-
*
|
|
147
|
-
* @property {?string} remotePath - The path to the remote location, where the captured video should be uploaded.
|
|
148
|
-
* The following protocols are supported: http/https, ftp.
|
|
149
|
-
* Null or empty string value (the default setting) means the content of resulting
|
|
150
|
-
* file should be encoded as Base64 and passed as the endpount response value.
|
|
151
|
-
* An exception will be thrown if the generated media file is too big to
|
|
152
|
-
* fit into the available process memory.
|
|
153
|
-
* This option only has an effect if there is screen recording process in progreess
|
|
154
|
-
* and `forceRestart` parameter is not set to `true`.
|
|
155
|
-
* @property {?string} user - The name of the user for the remote authentication. Only works if `remotePath` is provided.
|
|
156
|
-
* @property {?string} pass - The password for the remote authentication. Only works if `remotePath` is provided.
|
|
157
|
-
* @property {?string} method [PUT] - The http multipart upload method name. Only works if `remotePath` is provided.
|
|
158
|
-
* @property {?Object} headers - Additional headers mapping for multipart http(s) uploads
|
|
159
|
-
* @property {?string} fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for
|
|
160
|
-
* http(s) uploads
|
|
161
|
-
* @property {?Object|Array<Pair>} formFields - Additional form fields for multipart http(s) uploads
|
|
162
|
-
* @property {?string} videoSize - The format is widthxheight.
|
|
163
|
-
* The default value is the device's native display resolution (if supported),
|
|
164
|
-
* 1280x720 if not. For best results,
|
|
165
|
-
* use a size supported by your device's Advanced Video Coding (AVC) encoder.
|
|
166
|
-
* For example, "1280x720"
|
|
167
|
-
* @property {?boolean} bugReport - Set it to `true` in order to display additional information on the video overlay,
|
|
168
|
-
* such as a timestamp, that is helpful in videos captured to illustrate bugs.
|
|
169
|
-
* This option is only supported since API level 27 (Android P).
|
|
170
|
-
* @property {?string|number} timeLimit - The maximum recording time, in seconds. The default value is 180 (3 minutes).
|
|
171
|
-
* The maximum value is 1800 (30 minutes). If the passed value is greater than 180 then
|
|
172
|
-
* the algorithm will try to schedule multiple screen recording chunks and merge the
|
|
173
|
-
* resulting videos into a single media file using `ffmpeg` utility.
|
|
174
|
-
* If the utility is not available in PATH then the most recent screen recording chunk is
|
|
175
|
-
* going to be returned.
|
|
176
|
-
* @property {?string|number} bitRate - The video bit rate for the video, in bits per second.
|
|
177
|
-
* The default value is 4000000 (4 Mbit/s). You can increase the bit rate to improve video quality,
|
|
178
|
-
* but doing so results in larger movie files.
|
|
179
|
-
* @property {?boolean} forceRestart - Whether to try to catch and upload/return the currently running screen recording
|
|
180
|
-
* (`false`, the default setting) or ignore the result of it and start a new recording
|
|
181
|
-
* immediately (`true`).
|
|
182
|
-
*/
|
|
183
|
-
/**
|
|
184
|
-
* Record the display of a real devices running Android 4.4 (API level 19) and higher.
|
|
185
|
-
* Emulators are supported since API level 27 (Android P).
|
|
186
|
-
* It records screen activity to an MPEG-4 file. Audio is not recorded with the video file.
|
|
187
|
-
* If screen recording has been already started then the command will stop it forcefully and start a new one.
|
|
188
|
-
* The previously recorded video file will be deleted.
|
|
189
|
-
*
|
|
190
|
-
* @param {?StartRecordingOptions} options - The available options.
|
|
191
|
-
* @returns {string} Base64-encoded content of the recorded media file if
|
|
192
|
-
* any screen recording is currently running or an empty string.
|
|
193
|
-
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
|
|
178
|
+
* @type {import('./mixins').RecordScreenMixin & ThisType<import('../driver').AndroidDriver>}
|
|
179
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
194
180
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
`
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
for (const record of (this._screenRecordingProperties.records || [])) {
|
|
209
|
-
await this.adb.rimraf(record);
|
|
181
|
+
const RecordScreenMixin = {
|
|
182
|
+
async startRecordingScreen(options = {}) {
|
|
183
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
184
|
+
await verifyScreenRecordIsSupported(adb, this.isEmulator());
|
|
185
|
+
let result = '';
|
|
186
|
+
const { videoSize, timeLimit = DEFAULT_RECORDING_TIME_SEC, bugReport, bitRate, forceRestart, } = options;
|
|
187
|
+
if (!forceRestart) {
|
|
188
|
+
result = await this.stopRecordingScreen(options);
|
|
189
|
+
}
|
|
190
|
+
if (await terminateBackgroundScreenRecording(adb, true)) {
|
|
191
|
+
this.log.warn(`There were some ${SCREENRECORD_BINARY} process leftovers running ` +
|
|
192
|
+
`in the background. Make sure you stop screen recording each time after it is started, ` +
|
|
193
|
+
`otherwise the recorded media might quickly exceed all the free space on the device under test.`);
|
|
210
194
|
}
|
|
211
|
-
this._screenRecordingProperties = null;
|
|
212
|
-
}
|
|
213
|
-
const timeout = parseFloat(timeLimit);
|
|
214
|
-
if (isNaN(timeout) || timeout > MAX_TIME_SEC || timeout <= 0) {
|
|
215
|
-
throw new Error(`The timeLimit value must be in range [1, ${MAX_TIME_SEC}] seconds. ` +
|
|
216
|
-
`The value of '${timeLimit}' has been passed instead.`);
|
|
217
|
-
}
|
|
218
|
-
this._screenRecordingProperties = {
|
|
219
|
-
timer: new support_1.timing.Timer().start(),
|
|
220
|
-
videoSize,
|
|
221
|
-
timeLimit,
|
|
222
|
-
currentTimeLimit: timeLimit,
|
|
223
|
-
bitRate,
|
|
224
|
-
bugReport,
|
|
225
|
-
records: [],
|
|
226
|
-
recordingProcess: null,
|
|
227
|
-
stopped: false,
|
|
228
|
-
};
|
|
229
|
-
await scheduleScreenRecord(this.adb, this._screenRecordingProperties, this.log);
|
|
230
|
-
return result;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* @typedef {Object} StopRecordingOptions
|
|
234
|
-
*
|
|
235
|
-
* @property {?string} remotePath - The path to the remote location, where the resulting video should be uploaded.
|
|
236
|
-
* The following protocols are supported: http/https, ftp.
|
|
237
|
-
* Null or empty string value (the default setting) means the content of resulting
|
|
238
|
-
* file should be encoded as Base64 and passed as the endpount response value.
|
|
239
|
-
* An exception will be thrown if the generated media file is too big to
|
|
240
|
-
* fit into the available process memory.
|
|
241
|
-
* @property {?string} user - The name of the user for the remote authentication.
|
|
242
|
-
* @property {?string} pass - The password for the remote authentication.
|
|
243
|
-
* @property {?string} method - The http multipart upload method name. The 'PUT' one is used by default.
|
|
244
|
-
* @property {?Object} headers - Additional headers mapping for multipart http(s) uploads
|
|
245
|
-
* @property {?string} fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for
|
|
246
|
-
* http(s) uploads
|
|
247
|
-
* @property {?Object|Array<Pair>} formFields - Additional form fields for multipart http(s) uploads
|
|
248
|
-
*/
|
|
249
|
-
/**
|
|
250
|
-
* Stop recording the screen.
|
|
251
|
-
* If no screen recording has been started before then the method returns an empty string.
|
|
252
|
-
*
|
|
253
|
-
* @param {?StopRecordingOptions} options - The available options.
|
|
254
|
-
* @returns {string} Base64-encoded content of the recorded media file if 'remotePath'
|
|
255
|
-
* parameter is falsy or an empty string.
|
|
256
|
-
* @throws {Error} If there was an error while getting the name of a media file
|
|
257
|
-
* or the file content cannot be uploaded to the remote location
|
|
258
|
-
* or screen recording is not supported on the device under test.
|
|
259
|
-
*/
|
|
260
|
-
commands.stopRecordingScreen = async function stopRecordingScreen(options = {}) {
|
|
261
|
-
await verifyScreenRecordIsSupported(this.adb, this.isEmulator());
|
|
262
|
-
if (!lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
263
|
-
this._screenRecordingProperties.stopped = true;
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
await terminateBackgroundScreenRecording(this.adb, false);
|
|
267
|
-
}
|
|
268
|
-
catch (err) {
|
|
269
|
-
this.log.warn(err.message);
|
|
270
195
|
if (!lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
271
|
-
this
|
|
196
|
+
// XXX: this doesn't need to be done in serial, does it?
|
|
197
|
+
for (const record of this._screenRecordingProperties.records || []) {
|
|
198
|
+
await /** @type {ADB} */ (this.adb).rimraf(record);
|
|
199
|
+
}
|
|
200
|
+
this._screenRecordingProperties = undefined;
|
|
201
|
+
}
|
|
202
|
+
const timeout = parseFloat(String(timeLimit));
|
|
203
|
+
if (isNaN(timeout) || timeout > MAX_TIME_SEC || timeout <= 0) {
|
|
204
|
+
throw new Error(`The timeLimit value must be in range [1, ${MAX_TIME_SEC}] seconds. ` +
|
|
205
|
+
`The value of '${timeLimit}' has been passed instead.`);
|
|
206
|
+
}
|
|
207
|
+
this._screenRecordingProperties = {
|
|
208
|
+
timer: new support_1.timing.Timer().start(),
|
|
209
|
+
videoSize,
|
|
210
|
+
timeLimit,
|
|
211
|
+
currentTimeLimit: timeLimit,
|
|
212
|
+
bitRate,
|
|
213
|
+
bugReport,
|
|
214
|
+
records: [],
|
|
215
|
+
recordingProcess: null,
|
|
216
|
+
stopped: false,
|
|
217
|
+
};
|
|
218
|
+
await scheduleScreenRecord(adb, this._screenRecordingProperties, this.log);
|
|
219
|
+
return result;
|
|
220
|
+
},
|
|
221
|
+
async stopRecordingScreen(options = {}) {
|
|
222
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
223
|
+
await verifyScreenRecordIsSupported(adb, this.isEmulator());
|
|
224
|
+
if (!lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
225
|
+
this._screenRecordingProperties.stopped = true;
|
|
272
226
|
}
|
|
273
|
-
}
|
|
274
|
-
if (lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
275
|
-
this.log.info(`Screen recording has not been previously started by Appium. There is nothing to stop`);
|
|
276
|
-
return '';
|
|
277
|
-
}
|
|
278
|
-
if (this._screenRecordingProperties.recordingProcess && this._screenRecordingProperties.recordingProcess.isRunning) {
|
|
279
227
|
try {
|
|
280
|
-
await
|
|
228
|
+
await terminateBackgroundScreenRecording(adb, false);
|
|
281
229
|
}
|
|
282
|
-
catch (
|
|
283
|
-
this.log.
|
|
230
|
+
catch (err) {
|
|
231
|
+
this.log.warn(/** @type {Error} */ (err).message);
|
|
232
|
+
if (!lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
233
|
+
this.log.warn('The resulting video might be corrupted');
|
|
234
|
+
}
|
|
284
235
|
}
|
|
285
|
-
this._screenRecordingProperties
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
this.log.errorAndThrow(`No screen recordings have been stored on the device so far. ` +
|
|
289
|
-
`Are you sure the ${SCREENRECORD_BINARY} utility works as expected?`);
|
|
290
|
-
}
|
|
291
|
-
const tmpRoot = await support_1.tempDir.openDir();
|
|
292
|
-
try {
|
|
293
|
-
const localRecords = [];
|
|
294
|
-
for (const pathOnDevice of this._screenRecordingProperties.records) {
|
|
295
|
-
localRecords.push(path_1.default.resolve(tmpRoot, path_1.default.posix.basename(pathOnDevice)));
|
|
296
|
-
await this.adb.pull(pathOnDevice, lodash_1.default.last(localRecords));
|
|
297
|
-
await this.adb.rimraf(pathOnDevice);
|
|
236
|
+
if (lodash_1.default.isEmpty(this._screenRecordingProperties)) {
|
|
237
|
+
this.log.info(`Screen recording has not been previously started by Appium. There is nothing to stop`);
|
|
238
|
+
return '';
|
|
298
239
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
this.log.info(`Got ${localRecords.length} screen recordings. Trying to merge them`);
|
|
240
|
+
if (this._screenRecordingProperties.recordingProcess &&
|
|
241
|
+
this._screenRecordingProperties.recordingProcess.isRunning) {
|
|
302
242
|
try {
|
|
303
|
-
|
|
243
|
+
await this._screenRecordingProperties.recordingProcess.stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT);
|
|
304
244
|
}
|
|
305
245
|
catch (e) {
|
|
306
|
-
this.log.
|
|
307
|
-
`Original error: ${e.message}`);
|
|
246
|
+
this.log.errorAndThrow(`Unable to stop screen recording within ${PROCESS_SHUTDOWN_TIMEOUT}ms`);
|
|
308
247
|
}
|
|
248
|
+
this._screenRecordingProperties.recordingProcess = null;
|
|
309
249
|
}
|
|
310
|
-
if (lodash_1.default.isEmpty(
|
|
311
|
-
|
|
312
|
-
|
|
250
|
+
if (lodash_1.default.isEmpty(this._screenRecordingProperties.records)) {
|
|
251
|
+
this.log.errorAndThrow(`No screen recordings have been stored on the device so far. ` +
|
|
252
|
+
`Are you sure the ${SCREENRECORD_BINARY} utility works as expected?`);
|
|
313
253
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
254
|
+
const tmpRoot = await support_1.tempDir.openDir();
|
|
255
|
+
try {
|
|
256
|
+
const localRecords = [];
|
|
257
|
+
for (const pathOnDevice of this._screenRecordingProperties.records) {
|
|
258
|
+
const relativePath = path_1.default.resolve(tmpRoot, path_1.default.posix.basename(pathOnDevice));
|
|
259
|
+
localRecords.push(relativePath);
|
|
260
|
+
await adb.pull(pathOnDevice, relativePath);
|
|
261
|
+
await adb.rimraf(pathOnDevice);
|
|
262
|
+
}
|
|
263
|
+
let resultFilePath = /** @type {string} */ (lodash_1.default.last(localRecords));
|
|
264
|
+
if (localRecords.length > 1) {
|
|
265
|
+
this.log.info(`Got ${localRecords.length} screen recordings. Trying to merge them`);
|
|
266
|
+
try {
|
|
267
|
+
resultFilePath = await mergeScreenRecords(localRecords, this.log);
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
this.log.warn(`Cannot merge the recorded files. The most recent screen recording is going to be returned as the result. ` +
|
|
271
|
+
`Original error: ${ /** @type {Error} */(e).message}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (lodash_1.default.isEmpty(options.remotePath)) {
|
|
275
|
+
const { size } = await support_1.fs.stat(resultFilePath);
|
|
276
|
+
this.log.debug(`The size of the resulting screen recording is ${support_1.util.toReadableSizeString(size)}`);
|
|
277
|
+
}
|
|
278
|
+
return await uploadRecordedMedia(resultFilePath, options.remotePath, options);
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
await support_1.fs.rimraf(tmpRoot);
|
|
282
|
+
this._screenRecordingProperties = undefined;
|
|
283
|
+
}
|
|
284
|
+
},
|
|
320
285
|
};
|
|
321
|
-
|
|
286
|
+
(0, mixins_1.mixin)(RecordScreenMixin);
|
|
287
|
+
exports.default = RecordScreenMixin;
|
|
288
|
+
/**
|
|
289
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
290
|
+
*/
|
|
322
291
|
//# sourceMappingURL=recordscreen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordscreen.js","sourceRoot":"","sources":["../../../lib/commands/recordscreen.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recordscreen.js","sourceRoot":"","sources":["../../../lib/commands/recordscreen.js"],"names":[],"mappings":";AAAA,YAAY;;;;;AAEZ,6CAAuE;AACvE,uCAA0C;AAC1C,oDAAuB;AACvB,gDAAwB;AACxB,+CAAkC;AAClC,qCAA+B;AAE/B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,sBAAsB,GAAG,EAAE,GAAG,CAAC,CAAC;AACtC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,CAAC;AAC7B,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAC1D,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAC3C,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,aAAa,GAAG,SAAS,gBAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAElE;;;;;;GAMG;AACH,KAAK,UAAU,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE;IAC1E,IAAI,gBAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACzB,OAAO,CAAC,MAAM,cAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC5D;IAED,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAC,GAAG,aAAa,CAAC;IAC/E;;OAEG;IACH,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM,IAAI,KAAK;QACvB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|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export default ShellMixin;
|
|
2
|
+
export type ADB = import('appium-adb').ADB;
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('./mixins').ShellMixin & ThisType<import('../driver').AndroidDriver>}
|
|
5
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
6
|
+
*/
|
|
7
|
+
declare const ShellMixin: import('./mixins').ShellMixin & ThisType<import('../driver').AndroidDriver>;
|
|
8
8
|
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../lib/commands/shell.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../lib/commands/shell.js"],"names":[],"mappings":";kBAwDa,OAAO,YAAY,EAAE,GAAG;AA/CrC;;;GAGG;AACH,0BAHU,OAAO,UAAU,EAAE,UAAU,GAAG,SAAS,OAAO,WAAW,EAAE,aAAa,CAAC,CAuCnF"}
|
|
@@ -1,44 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @ts-check
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.commands = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const teen_process_1 = require("teen_process");
|
|
9
7
|
const support_1 = require("@appium/support");
|
|
10
8
|
const driver_1 = require("appium/driver");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const teen_process_1 = require("teen_process");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
const mixins_1 = require("./mixins");
|
|
13
|
+
/**
|
|
14
|
+
* @type {import('./mixins').ShellMixin & ThisType<import('../driver').AndroidDriver>}
|
|
15
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
16
|
+
*/
|
|
17
|
+
const ShellMixin = {
|
|
18
|
+
async mobileShell(opts) {
|
|
19
|
+
this.ensureFeatureEnabled(utils_1.ADB_SHELL_FEATURE);
|
|
20
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
21
|
+
const { command, args = /** @type {string[]} */ ([]), timeout = 20000, includeStderr, } = opts ?? {};
|
|
22
|
+
if (!lodash_1.default.isString(command)) {
|
|
23
|
+
throw new driver_1.errors.InvalidArgumentError(`The 'command' argument is mandatory`);
|
|
24
|
+
}
|
|
25
|
+
const adbArgs = [...adb.executable.defaultArgs, 'shell', command, ...lodash_1.default.castArray(args)];
|
|
26
|
+
this.log.debug(`Running '${adb.executable.path} ${support_1.util.quote(adbArgs)}'`);
|
|
27
|
+
try {
|
|
28
|
+
const { stdout, stderr } = await (0, teen_process_1.exec)(adb.executable.path, adbArgs, { timeout });
|
|
29
|
+
if (includeStderr) {
|
|
30
|
+
return {
|
|
31
|
+
stdout,
|
|
32
|
+
stderr,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return stdout;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const err = /** @type {import('teen_process').ExecError} */ (e);
|
|
39
|
+
this.log.errorAndThrow(`Cannot execute the '${command}' shell command. ` +
|
|
40
|
+
`Original error: ${err.message}. ` +
|
|
41
|
+
`StdOut: ${err.stdout}. StdErr: ${err.stderr}`);
|
|
42
|
+
throw new Error(); // unreachable; for TS
|
|
34
43
|
}
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
this.log.errorAndThrow(`Cannot execute the '${command}' shell command. ` +
|
|
39
|
-
`Original error: ${err.message}. ` +
|
|
40
|
-
`StdOut: ${err.stdout}. StdErr: ${err.stderr}`);
|
|
41
|
-
}
|
|
44
|
+
},
|
|
42
45
|
};
|
|
43
|
-
|
|
46
|
+
(0, mixins_1.mixin)(ShellMixin);
|
|
47
|
+
exports.default = ShellMixin;
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
50
|
+
*/
|
|
44
51
|
//# sourceMappingURL=shell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../lib/commands/shell.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../lib/commands/shell.js"],"names":[],"mappings":";AAAA,YAAY;;;;;AAEZ,6CAAqC;AACrC,0CAAqC;AACrC,oDAAuB;AACvB,+CAAkC;AAClC,oCAA2C;AAC3C,qCAA+B;AAE/B;;;GAGG;AACH,MAAM,UAAU,GAAG;IACjB,KAAK,CAAC,WAAW,CAAC,IAAI;QACpB,IAAI,CAAC,oBAAoB,CAAC,yBAAiB,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,EACJ,OAAO,EACP,IAAI,GAAG,uBAAuB,CAAC,CAAC,EAAE,CAAC,EACnC,OAAO,GAAG,KAAK,EACf,aAAa,GACd,GAAG,IAAI,IAAI,EAAE,CAAC;QAEf,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACxB,MAAM,IAAI,eAAM,CAAC,oBAAoB,CAAC,qCAAqC,CAAC,CAAC;SAC9E;QAED,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,EAA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