appium-android-driver 7.8.3 → 8.0.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.
- package/CHANGELOG.md +25 -0
- package/build/lib/commands/app-management.d.ts +129 -5
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +433 -128
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +17 -4
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +32 -33
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/context/cache.d.ts +19 -0
- package/build/lib/commands/context/cache.d.ts.map +1 -0
- package/build/lib/commands/context/cache.js +32 -0
- package/build/lib/commands/context/cache.js.map +1 -0
- package/build/lib/commands/context/exports.d.ts +141 -0
- package/build/lib/commands/context/exports.d.ts.map +1 -0
- package/build/lib/commands/context/exports.js +351 -0
- package/build/lib/commands/context/exports.js.map +1 -0
- package/build/lib/commands/context/helpers.d.ts +98 -0
- package/build/lib/commands/context/helpers.d.ts.map +1 -0
- package/build/lib/commands/context/helpers.js +715 -0
- package/build/lib/commands/context/helpers.js.map +1 -0
- package/build/lib/commands/device/common.d.ts +23 -0
- package/build/lib/commands/device/common.d.ts.map +1 -0
- package/build/lib/commands/device/common.js +230 -0
- package/build/lib/commands/device/common.js.map +1 -0
- package/build/lib/commands/device/emulator-actions.d.ts +114 -0
- package/build/lib/commands/device/emulator-actions.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-actions.js +197 -0
- package/build/lib/commands/device/emulator-actions.js.map +1 -0
- package/build/lib/commands/device/emulator-console.d.ts +7 -0
- package/build/lib/commands/device/emulator-console.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-console.js +24 -0
- package/build/lib/commands/device/emulator-console.js.map +1 -0
- package/build/lib/commands/device/utils.d.ts +50 -0
- package/build/lib/commands/device/utils.d.ts.map +1 -0
- package/build/lib/commands/device/utils.js +238 -0
- package/build/lib/commands/device/utils.js.map +1 -0
- package/build/lib/commands/deviceidle.d.ts +8 -5
- package/build/lib/commands/deviceidle.d.ts.map +1 -1
- package/build/lib/commands/deviceidle.js +31 -37
- package/build/lib/commands/deviceidle.js.map +1 -1
- package/build/lib/commands/element.d.ts +99 -5
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +152 -116
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +12 -4
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +83 -78
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +42 -5
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +230 -194
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +5 -4
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +7 -10
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +45 -0
- package/build/lib/commands/geolocation.d.ts.map +1 -0
- package/build/lib/commands/geolocation.js +182 -0
- package/build/lib/commands/geolocation.js.map +1 -0
- package/build/lib/commands/ime.d.ts +25 -5
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +59 -42
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/intent.d.ts +56 -5
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +135 -83
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +58 -4
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +119 -17
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/lock/exports.d.ts +301 -0
- package/build/lib/commands/lock/exports.d.ts.map +1 -0
- package/build/lib/commands/lock/exports.js +121 -0
- package/build/lib/commands/lock/exports.js.map +1 -0
- package/build/lib/commands/lock/helpers.d.ts +349 -0
- package/build/lib/commands/lock/helpers.d.ts.map +1 -0
- package/build/lib/commands/lock/helpers.js +375 -0
- package/build/lib/commands/lock/helpers.js.map +1 -0
- package/build/lib/commands/log.d.ts +59 -5
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +150 -140
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +16 -5
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +69 -58
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/memory.d.ts +9 -5
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +19 -24
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/misc.d.ts +42 -0
- package/build/lib/commands/misc.d.ts.map +1 -0
- package/build/lib/commands/misc.js +100 -0
- package/build/lib/commands/misc.js.map +1 -0
- package/build/lib/commands/network.d.ts +61 -5
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +196 -189
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +67 -27
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +105 -80
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +12 -6
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +65 -62
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +44 -5
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +131 -126
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/resources.d.ts +16 -0
- package/build/lib/commands/resources.d.ts.map +1 -0
- package/build/lib/commands/resources.js +91 -0
- package/build/lib/commands/resources.js.map +1 -0
- package/build/lib/commands/shell.d.ts +8 -5
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +29 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +34 -6
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +166 -162
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +18 -13
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +68 -64
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/time.d.ts +14 -0
- package/build/lib/commands/time.d.ts.map +1 -0
- package/build/lib/commands/time.js +39 -0
- package/build/lib/commands/time.js.map +1 -0
- package/build/lib/commands/touch.d.ts +99 -6
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +399 -280
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +110 -2
- package/build/lib/commands/types.d.ts.map +1 -1
- package/build/lib/doctor/checks.d.ts.map +1 -1
- package/build/lib/doctor/checks.js +4 -4
- package/build/lib/doctor/checks.js.map +1 -1
- package/build/lib/driver.d.ts +224 -27
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +232 -7
- package/build/lib/driver.js.map +1 -1
- package/build/lib/index.d.ts +1 -4
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -13
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/method-map.d.ts +0 -23
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +0 -11
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/utils.d.ts +12 -0
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +38 -2
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/app-management.js +470 -145
- package/lib/commands/appearance.js +29 -36
- package/lib/commands/context/cache.js +29 -0
- package/lib/commands/context/exports.js +379 -0
- package/lib/commands/context/helpers.js +802 -0
- package/lib/commands/device/common.js +264 -0
- package/lib/commands/device/emulator-actions.js +194 -0
- package/lib/commands/device/emulator-console.js +24 -0
- package/lib/commands/device/utils.js +285 -0
- package/lib/commands/deviceidle.js +31 -44
- package/lib/commands/element.js +149 -142
- package/lib/commands/execute.js +86 -87
- package/lib/commands/file-actions.js +249 -222
- package/lib/commands/find.ts +13 -19
- package/lib/commands/geolocation.js +179 -0
- package/lib/commands/ime.js +53 -45
- package/lib/commands/intent.js +149 -91
- package/lib/commands/keyboard.js +114 -17
- package/lib/commands/lock/exports.js +139 -0
- package/lib/commands/lock/helpers.js +379 -0
- package/lib/commands/log.js +170 -166
- package/lib/commands/media-projection.js +75 -70
- package/lib/commands/memory.js +17 -29
- package/lib/commands/misc.js +94 -0
- package/lib/commands/network.js +209 -223
- package/lib/commands/performance.js +88 -73
- package/lib/commands/permissions.js +83 -84
- package/lib/commands/recordscreen.js +171 -170
- package/lib/commands/resources.js +96 -0
- package/lib/commands/shell.js +28 -42
- package/lib/commands/streamscreen.js +207 -206
- package/lib/commands/system-bars.js +76 -77
- package/lib/commands/time.js +36 -0
- package/lib/commands/touch.js +442 -346
- package/lib/commands/types.ts +123 -2
- package/lib/doctor/checks.js +24 -16
- package/lib/driver.ts +454 -12
- package/lib/index.ts +1 -13
- package/lib/logger.js +1 -1
- package/lib/method-map.js +0 -11
- package/lib/utils.js +40 -3
- package/package.json +1 -1
- package/build/lib/commands/actions.d.ts +0 -8
- package/build/lib/commands/actions.d.ts.map +0 -1
- package/build/lib/commands/actions.js +0 -207
- package/build/lib/commands/actions.js.map +0 -1
- package/build/lib/commands/alert.d.ts +0 -8
- package/build/lib/commands/alert.d.ts.map +0 -1
- package/build/lib/commands/alert.js +0 -29
- package/build/lib/commands/alert.js.map +0 -1
- package/build/lib/commands/context.d.ts +0 -10
- package/build/lib/commands/context.d.ts.map +0 -1
- package/build/lib/commands/context.js +0 -431
- package/build/lib/commands/context.js.map +0 -1
- package/build/lib/commands/emu-console.d.ts +0 -7
- package/build/lib/commands/emu-console.d.ts.map +0 -1
- package/build/lib/commands/emu-console.js +0 -27
- package/build/lib/commands/emu-console.js.map +0 -1
- package/build/lib/commands/general.d.ts +0 -9
- package/build/lib/commands/general.d.ts.map +0 -1
- package/build/lib/commands/general.js +0 -293
- package/build/lib/commands/general.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -28
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -57
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/commands/mixins.d.ts +0 -747
- package/build/lib/commands/mixins.d.ts.map +0 -1
- package/build/lib/commands/mixins.js +0 -19
- package/build/lib/commands/mixins.js.map +0 -1
- package/build/lib/helpers/android.d.ts +0 -163
- package/build/lib/helpers/android.d.ts.map +0 -1
- package/build/lib/helpers/android.js +0 -818
- package/build/lib/helpers/android.js.map +0 -1
- package/build/lib/helpers/index.d.ts +0 -7
- package/build/lib/helpers/index.d.ts.map +0 -1
- package/build/lib/helpers/index.js +0 -29
- package/build/lib/helpers/index.js.map +0 -1
- package/build/lib/helpers/types.d.ts +0 -122
- package/build/lib/helpers/types.d.ts.map +0 -1
- package/build/lib/helpers/types.js +0 -3
- package/build/lib/helpers/types.js.map +0 -1
- package/build/lib/helpers/unlock.d.ts +0 -32
- package/build/lib/helpers/unlock.d.ts.map +0 -1
- package/build/lib/helpers/unlock.js +0 -273
- package/build/lib/helpers/unlock.js.map +0 -1
- package/build/lib/helpers/webview.d.ts +0 -74
- package/build/lib/helpers/webview.d.ts.map +0 -1
- package/build/lib/helpers/webview.js +0 -448
- package/build/lib/helpers/webview.js.map +0 -1
- package/lib/commands/actions.js +0 -244
- package/lib/commands/alert.js +0 -34
- package/lib/commands/context.js +0 -507
- package/lib/commands/emu-console.js +0 -31
- package/lib/commands/general.js +0 -343
- package/lib/commands/index.ts +0 -54
- package/lib/commands/mixins.ts +0 -976
- package/lib/helpers/android.ts +0 -1153
- package/lib/helpers/index.ts +0 -6
- package/lib/helpers/types.ts +0 -136
- package/lib/helpers/unlock.ts +0 -329
- package/lib/helpers/webview.ts +0 -610
|
@@ -1,16 +1,162 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @ts-check
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLog = exports.getLogTypes = exports.mobileStopLogsBroadcast = exports.mobileStartLogsBroadcast = exports.supportedLogTypes = void 0;
|
|
7
7
|
const driver_1 = require("appium/driver");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const node_os_1 = __importDefault(require("node:os"));
|
|
10
10
|
const ws_1 = __importDefault(require("ws"));
|
|
11
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
12
|
-
const mixins_1 = require("./mixins");
|
|
13
11
|
const GET_SERVER_LOGS_FEATURE = 'get_server_logs';
|
|
12
|
+
exports.supportedLogTypes = {
|
|
13
|
+
logcat: {
|
|
14
|
+
description: 'Logs for Android applications on real device and emulators via ADB',
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {import('../driver').AndroidDriver} self
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
getter: (self) => /** @type {ADB} */ (self.adb).getLogcatLogs(),
|
|
21
|
+
},
|
|
22
|
+
bugreport: {
|
|
23
|
+
description: `'adb bugreport' output for advanced issues diagnostic`,
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {import('../driver').AndroidDriver} self
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
getter: async (self) => {
|
|
30
|
+
const output = await /** @type {ADB} */ (self.adb).bugreport();
|
|
31
|
+
const timestamp = Date.now();
|
|
32
|
+
return output.split(node_os_1.default.EOL).map((x) => toLogRecord(timestamp, 'ALL', x));
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
server: {
|
|
36
|
+
description: 'Appium server logs',
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {import('../driver').AndroidDriver} self
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
getter: (self) => {
|
|
43
|
+
self.ensureFeatureEnabled(GET_SERVER_LOGS_FEATURE);
|
|
44
|
+
const timestamp = Date.now();
|
|
45
|
+
return self.log
|
|
46
|
+
.unwrap()
|
|
47
|
+
.record.map((x) => toLogRecord(timestamp, 'ALL', lodash_1.default.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`));
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Starts Android logcat broadcast websocket on the same host and port
|
|
53
|
+
* where Appium server is running at `/ws/session/:sessionId:/appium/logcat` endpoint. The method
|
|
54
|
+
* will return immediately if the web socket is already listening.
|
|
55
|
+
*
|
|
56
|
+
* Each connected websocket listener will receive logcat log lines
|
|
57
|
+
* as soon as they are visible to Appium.
|
|
58
|
+
*
|
|
59
|
+
* @this {import('../driver').AndroidDriver}
|
|
60
|
+
* @returns {Promise<void>}
|
|
61
|
+
*/
|
|
62
|
+
async function mobileStartLogsBroadcast() {
|
|
63
|
+
const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
|
|
64
|
+
const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
|
|
65
|
+
if (!lodash_1.default.isEmpty(await server.getWebSocketHandlers(pathname))) {
|
|
66
|
+
this.log.debug(`The logcat broadcasting web socket server is already listening at ${pathname}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.log.info(`Starting logcat broadcasting on web socket server ` +
|
|
70
|
+
`${JSON.stringify(server.address())} to ${pathname}`);
|
|
71
|
+
// https://github.com/websockets/ws/blob/master/doc/ws.md
|
|
72
|
+
const wss = new ws_1.default.Server({
|
|
73
|
+
noServer: true,
|
|
74
|
+
});
|
|
75
|
+
wss.on('connection', (ws, req) => {
|
|
76
|
+
if (req) {
|
|
77
|
+
const remoteIp = lodash_1.default.isEmpty(req.headers['x-forwarded-for'])
|
|
78
|
+
? req.connection?.remoteAddress
|
|
79
|
+
: req.headers['x-forwarded-for'];
|
|
80
|
+
this.log.debug(`Established a new logcat listener web socket connection from ${remoteIp}`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.log.debug('Established a new logcat listener web socket connection');
|
|
84
|
+
}
|
|
85
|
+
if (lodash_1.default.isEmpty(this._logcatWebsocketListener)) {
|
|
86
|
+
this._logcatWebsocketListener = (logRecord) => {
|
|
87
|
+
if (ws?.readyState === ws_1.default.OPEN) {
|
|
88
|
+
ws.send(logRecord.message);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
this.adb.setLogcatListener(this._logcatWebsocketListener);
|
|
93
|
+
ws.on('close', (code, reason) => {
|
|
94
|
+
if (!lodash_1.default.isEmpty(this._logcatWebsocketListener)) {
|
|
95
|
+
try {
|
|
96
|
+
this.adb.removeLogcatListener(this._logcatWebsocketListener);
|
|
97
|
+
}
|
|
98
|
+
catch (ign) { }
|
|
99
|
+
this._logcatWebsocketListener = undefined;
|
|
100
|
+
}
|
|
101
|
+
let closeMsg = 'Logcat listener web socket is closed.';
|
|
102
|
+
if (!lodash_1.default.isEmpty(code)) {
|
|
103
|
+
closeMsg += ` Code: ${code}.`;
|
|
104
|
+
}
|
|
105
|
+
if (!lodash_1.default.isEmpty(reason)) {
|
|
106
|
+
closeMsg += ` Reason: ${reason.toString()}.`;
|
|
107
|
+
}
|
|
108
|
+
this.log.debug(closeMsg);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
await server.addWebSocketHandler(pathname, /** @type {import('@appium/types').WSServer} */ (wss));
|
|
112
|
+
}
|
|
113
|
+
exports.mobileStartLogsBroadcast = mobileStartLogsBroadcast;
|
|
114
|
+
/**
|
|
115
|
+
* Stops the previously started logcat broadcasting wesocket server.
|
|
116
|
+
* This method will return immediately if no server is running.
|
|
117
|
+
*
|
|
118
|
+
* @this {import('../driver').AndroidDriver}
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
*/
|
|
121
|
+
async function mobileStopLogsBroadcast() {
|
|
122
|
+
const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
|
|
123
|
+
const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
|
|
124
|
+
if (lodash_1.default.isEmpty(await server.getWebSocketHandlers(pathname))) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.log.debug(`Stopping logcat broadcasting on web socket server ` +
|
|
128
|
+
`${JSON.stringify(server.address())} to ${pathname}`);
|
|
129
|
+
await server.removeWebSocketHandler(pathname);
|
|
130
|
+
}
|
|
131
|
+
exports.mobileStopLogsBroadcast = mobileStopLogsBroadcast;
|
|
132
|
+
/**
|
|
133
|
+
* @this {import('../driver').AndroidDriver}
|
|
134
|
+
* @returns {Promise<string[]>}
|
|
135
|
+
*/
|
|
136
|
+
async function getLogTypes() {
|
|
137
|
+
// XXX why doesn't `super` work here?
|
|
138
|
+
const nativeLogTypes = await driver_1.BaseDriver.prototype.getLogTypes.call(this);
|
|
139
|
+
if (this.isWebContext()) {
|
|
140
|
+
const webLogTypes = /** @type {string[]} */ (await /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy.command('/log/types', 'GET'));
|
|
141
|
+
return [...nativeLogTypes, ...webLogTypes];
|
|
142
|
+
}
|
|
143
|
+
return nativeLogTypes;
|
|
144
|
+
}
|
|
145
|
+
exports.getLogTypes = getLogTypes;
|
|
146
|
+
/**
|
|
147
|
+
* @this {import('../driver').AndroidDriver}
|
|
148
|
+
* @param {string} logType
|
|
149
|
+
* @returns {Promise<any>}
|
|
150
|
+
*/
|
|
151
|
+
async function getLog(logType) {
|
|
152
|
+
if (this.isWebContext() && !lodash_1.default.keys(this.supportedLogTypes).includes(logType)) {
|
|
153
|
+
return await /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy.command('/log', 'POST', { type: logType });
|
|
154
|
+
}
|
|
155
|
+
// XXX why doesn't `super` work here?
|
|
156
|
+
return await driver_1.BaseDriver.prototype.getLog.call(this, logType);
|
|
157
|
+
}
|
|
158
|
+
exports.getLog = getLog;
|
|
159
|
+
// #region Internal helpers
|
|
14
160
|
/**
|
|
15
161
|
* @param {string} sessionId
|
|
16
162
|
* @returns {string}
|
|
@@ -30,143 +176,7 @@ function toLogRecord(timestamp, level, message) {
|
|
|
30
176
|
message,
|
|
31
177
|
};
|
|
32
178
|
}
|
|
33
|
-
|
|
34
|
-
* @type {import('./mixins').LogMixin & ThisType<import('../driver').AndroidDriver>}
|
|
35
|
-
* @satisfies {import('@appium/types').ExternalDriver}
|
|
36
|
-
*/
|
|
37
|
-
const LogMixin = {
|
|
38
|
-
supportedLogTypes: {
|
|
39
|
-
logcat: {
|
|
40
|
-
description: 'Logs for Android applications on real device and emulators via ADB',
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {import('../driver').AndroidDriver} self
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
getter: (self) => /** @type {ADB} */ (self.adb).getLogcatLogs(),
|
|
47
|
-
},
|
|
48
|
-
bugreport: {
|
|
49
|
-
description: `'adb bugreport' output for advanced issues diagnostic`,
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param {import('../driver').AndroidDriver} self
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
getter: async (self) => {
|
|
56
|
-
const output = await /** @type {ADB} */ (self.adb).bugreport();
|
|
57
|
-
const timestamp = Date.now();
|
|
58
|
-
return output.split(node_os_1.default.EOL).map((x) => toLogRecord(timestamp, 'ALL', x));
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
server: {
|
|
62
|
-
description: 'Appium server logs',
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {import('../driver').AndroidDriver} self
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
getter: (self) => {
|
|
69
|
-
self.ensureFeatureEnabled(GET_SERVER_LOGS_FEATURE);
|
|
70
|
-
const timestamp = Date.now();
|
|
71
|
-
return logger_1.default
|
|
72
|
-
.unwrap()
|
|
73
|
-
.record.map((x) => toLogRecord(timestamp, 'ALL', lodash_1.default.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`));
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* Starts Android logcat broadcast websocket on the same host and port
|
|
79
|
-
* where Appium server is running at `/ws/session/:sessionId:/appium/logcat` endpoint. The method
|
|
80
|
-
* will return immediately if the web socket is already listening.
|
|
81
|
-
*
|
|
82
|
-
* Each connected websocket listener will receive logcat log lines
|
|
83
|
-
* as soon as they are visible to Appium.
|
|
84
|
-
*/
|
|
85
|
-
async mobileStartLogsBroadcast() {
|
|
86
|
-
const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
|
|
87
|
-
const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
|
|
88
|
-
if (!lodash_1.default.isEmpty(await server.getWebSocketHandlers(pathname))) {
|
|
89
|
-
logger_1.default.debug(`The logcat broadcasting web socket server is already listening at ${pathname}`);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
logger_1.default.info(`Starting logcat broadcasting on web socket server ` +
|
|
93
|
-
`${JSON.stringify(server.address())} to ${pathname}`);
|
|
94
|
-
// https://github.com/websockets/ws/blob/master/doc/ws.md
|
|
95
|
-
const wss = new ws_1.default.Server({
|
|
96
|
-
noServer: true,
|
|
97
|
-
});
|
|
98
|
-
wss.on('connection', (ws, req) => {
|
|
99
|
-
if (req) {
|
|
100
|
-
const remoteIp = lodash_1.default.isEmpty(req.headers['x-forwarded-for'])
|
|
101
|
-
? req.connection?.remoteAddress
|
|
102
|
-
: req.headers['x-forwarded-for'];
|
|
103
|
-
logger_1.default.debug(`Established a new logcat listener web socket connection from ${remoteIp}`);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
logger_1.default.debug('Established a new logcat listener web socket connection');
|
|
107
|
-
}
|
|
108
|
-
if (lodash_1.default.isEmpty(this._logcatWebsocketListener)) {
|
|
109
|
-
this._logcatWebsocketListener = (logRecord) => {
|
|
110
|
-
if (ws?.readyState === ws_1.default.OPEN) {
|
|
111
|
-
ws.send(logRecord.message);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
this.adb.setLogcatListener(this._logcatWebsocketListener);
|
|
116
|
-
ws.on('close', (code, reason) => {
|
|
117
|
-
if (!lodash_1.default.isEmpty(this._logcatWebsocketListener)) {
|
|
118
|
-
try {
|
|
119
|
-
this.adb.removeLogcatListener(this._logcatWebsocketListener);
|
|
120
|
-
}
|
|
121
|
-
catch (ign) { }
|
|
122
|
-
this._logcatWebsocketListener = undefined;
|
|
123
|
-
}
|
|
124
|
-
let closeMsg = 'Logcat listener web socket is closed.';
|
|
125
|
-
if (!lodash_1.default.isEmpty(code)) {
|
|
126
|
-
closeMsg += ` Code: ${code}.`;
|
|
127
|
-
}
|
|
128
|
-
if (!lodash_1.default.isEmpty(reason)) {
|
|
129
|
-
closeMsg += ` Reason: ${reason.toString()}.`;
|
|
130
|
-
}
|
|
131
|
-
logger_1.default.debug(closeMsg);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
await server.addWebSocketHandler(pathname,
|
|
135
|
-
/** @type {import('@appium/types').WSServer} */ (wss));
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Stops the previously started logcat broadcasting wesocket server.
|
|
139
|
-
* This method will return immediately if no server is running.
|
|
140
|
-
*/
|
|
141
|
-
async mobileStopLogsBroadcast() {
|
|
142
|
-
const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
|
|
143
|
-
const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
|
|
144
|
-
if (lodash_1.default.isEmpty(await server.getWebSocketHandlers(pathname))) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
logger_1.default.debug(`Stopping logcat broadcasting on web socket server ` +
|
|
148
|
-
`${JSON.stringify(server.address())} to ${pathname}`);
|
|
149
|
-
await server.removeWebSocketHandler(pathname);
|
|
150
|
-
},
|
|
151
|
-
async getLogTypes() {
|
|
152
|
-
// XXX why doesn't `super` work here?
|
|
153
|
-
const nativeLogTypes = await driver_1.BaseDriver.prototype.getLogTypes.call(this);
|
|
154
|
-
if (this.isWebContext()) {
|
|
155
|
-
const webLogTypes = /** @type {string[]} */ (await /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy.command('/log/types', 'GET'));
|
|
156
|
-
return [...nativeLogTypes, ...webLogTypes];
|
|
157
|
-
}
|
|
158
|
-
return nativeLogTypes;
|
|
159
|
-
},
|
|
160
|
-
async getLog(logType) {
|
|
161
|
-
if (this.isWebContext() && !lodash_1.default.keys(this.supportedLogTypes).includes(logType)) {
|
|
162
|
-
return await /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy.command('/log', 'POST', { type: logType });
|
|
163
|
-
}
|
|
164
|
-
// XXX why doesn't `super` work here?
|
|
165
|
-
return await driver_1.BaseDriver.prototype.getLog.call(this, logType);
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
(0, mixins_1.mixin)(LogMixin);
|
|
169
|
-
exports.default = LogMixin;
|
|
179
|
+
// #endregion
|
|
170
180
|
/**
|
|
171
181
|
* @typedef {import('appium-adb').ADB} ADB
|
|
172
182
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../lib/commands/log.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../lib/commands/log.js"],"names":[],"mappings":";;;;;;AAAA,0CAAqE;AACrE,oDAAuB;AACvB,sDAAyB;AACzB,4CAA2B;AAE3B,MAA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E,OAAO,EAAC,CAAC,CAAC;KACpD;IACD,qCAAqC;IACrC,OAAO,MAAM,mBAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC;AARD,wBAQC;AAED,2BAA2B;AAE3B;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,EAAE,CACvC,GAAG,mCAA0B,YAAY,SAAS,uBAAuB,CAAC;AAE5E;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO;IAC5C,OAAO;QACL,SAAS;QACT,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC;AAED,aAAa;AAEb;;GAEG"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
export default MediaProjectionMixin;
|
|
2
|
-
export type ADB = import('appium-adb').ADB;
|
|
3
1
|
/**
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
2
|
+
* @this {import('../driver').AndroidDriver}
|
|
3
|
+
* @param {import('./types').StartMediaProjectionRecordingOpts} [options={}]
|
|
4
|
+
* @returns {Promise<boolean>}
|
|
5
|
+
*/
|
|
6
|
+
export function mobileStartMediaProjectionRecording(this: import("../driver").AndroidDriver, options?: import("./types").StartMediaProjectionRecordingOpts | undefined): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* @this {import('../driver').AndroidDriver}
|
|
9
|
+
* @returns {Promise<boolean>}
|
|
6
10
|
*/
|
|
7
|
-
|
|
11
|
+
export function mobileIsMediaProjectionRecordingRunning(this: import("../driver").AndroidDriver): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* @this {import('../driver').AndroidDriver}
|
|
14
|
+
* @param {import('./types').StopMediaProjectionRecordingOpts} [options={}]
|
|
15
|
+
* @returns {Promise<string>}
|
|
16
|
+
*/
|
|
17
|
+
export function mobileStopMediaProjectionRecording(this: import("../driver").AndroidDriver, options?: import("./types").StopMediaProjectionRecordingOpts | undefined): Promise<string>;
|
|
18
|
+
export type ADB = import('appium-adb').ADB;
|
|
8
19
|
//# sourceMappingURL=media-projection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-projection.d.ts","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"media-projection.d.ts","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,yKAFa,QAAQ,OAAO,CAAC,CAsB5B;AAED;;;GAGG;AACH,kGAFa,QAAQ,OAAO,CAAC,CAO5B;AAED;;;;GAIG;AACH,uKAFa,QAAQ,MAAM,CAAC,CA4B3B;kBAoEY,OAAO,YAAY,EAAE,GAAG"}
|
|
@@ -3,15 +3,82 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mobileStopMediaProjectionRecording = exports.mobileIsMediaProjectionRecordingRunning = exports.mobileStartMediaProjectionRecording = void 0;
|
|
6
7
|
const support_1 = require("@appium/support");
|
|
7
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
9
|
const moment_1 = __importDefault(require("moment"));
|
|
9
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const mixins_1 = require("./mixins");
|
|
11
11
|
// https://github.com/appium/io.appium.settings#internal-audio--video-recording
|
|
12
12
|
const DEFAULT_EXT = '.mp4';
|
|
13
13
|
const MIN_API_LEVEL = 29;
|
|
14
14
|
const DEFAULT_FILENAME_FORMAT = 'YYYY-MM-DDTHH-mm-ss';
|
|
15
|
+
/**
|
|
16
|
+
* @this {import('../driver').AndroidDriver}
|
|
17
|
+
* @param {import('./types').StartMediaProjectionRecordingOpts} [options={}]
|
|
18
|
+
* @returns {Promise<boolean>}
|
|
19
|
+
*/
|
|
20
|
+
async function mobileStartMediaProjectionRecording(options = {}) {
|
|
21
|
+
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
22
|
+
const { resolution, priority, maxDurationSec, filename } = options;
|
|
23
|
+
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
24
|
+
const fname = adjustMediaExtension(filename || (0, moment_1.default)().format(DEFAULT_FILENAME_FORMAT));
|
|
25
|
+
const didStart = await recorder.start({
|
|
26
|
+
resolution,
|
|
27
|
+
priority,
|
|
28
|
+
maxDurationSec,
|
|
29
|
+
filename: fname,
|
|
30
|
+
});
|
|
31
|
+
if (didStart) {
|
|
32
|
+
this.log.info(`A new media projection recording '${fname}' has been successfully started`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.log.info('Another media projection recording is already in progress. There is nothing to start');
|
|
36
|
+
}
|
|
37
|
+
return didStart;
|
|
38
|
+
}
|
|
39
|
+
exports.mobileStartMediaProjectionRecording = mobileStartMediaProjectionRecording;
|
|
40
|
+
/**
|
|
41
|
+
* @this {import('../driver').AndroidDriver}
|
|
42
|
+
* @returns {Promise<boolean>}
|
|
43
|
+
*/
|
|
44
|
+
async function mobileIsMediaProjectionRecordingRunning() {
|
|
45
|
+
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
46
|
+
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
47
|
+
return await recorder.isRunning();
|
|
48
|
+
}
|
|
49
|
+
exports.mobileIsMediaProjectionRecordingRunning = mobileIsMediaProjectionRecordingRunning;
|
|
50
|
+
/**
|
|
51
|
+
* @this {import('../driver').AndroidDriver}
|
|
52
|
+
* @param {import('./types').StopMediaProjectionRecordingOpts} [options={}]
|
|
53
|
+
* @returns {Promise<string>}
|
|
54
|
+
*/
|
|
55
|
+
async function mobileStopMediaProjectionRecording(options = {}) {
|
|
56
|
+
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
57
|
+
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
58
|
+
if (await recorder.stop()) {
|
|
59
|
+
this.log.info('Successfully stopped a media projection recording. Pulling the recorded media');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.log.info('Media projection recording is not running. There is nothing to stop');
|
|
63
|
+
}
|
|
64
|
+
const recentRecordingPath = await recorder.pullRecent();
|
|
65
|
+
if (!recentRecordingPath) {
|
|
66
|
+
throw new Error(`No recent media projection recording have been found. Did you start any?`);
|
|
67
|
+
}
|
|
68
|
+
const { remotePath } = options;
|
|
69
|
+
if (lodash_1.default.isEmpty(remotePath)) {
|
|
70
|
+
const { size } = await support_1.fs.stat(recentRecordingPath);
|
|
71
|
+
this.log.debug(`The size of the resulting media projection recording is ${support_1.util.toReadableSizeString(size)}`);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return await uploadRecordedMedia(recentRecordingPath, remotePath, options);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
await support_1.fs.rimraf(node_path_1.default.dirname(recentRecordingPath));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.mobileStopMediaProjectionRecording = mobileStopMediaProjectionRecording;
|
|
81
|
+
// #region Internal helpers
|
|
15
82
|
/**
|
|
16
83
|
*
|
|
17
84
|
* @param {string} localFile
|
|
@@ -59,63 +126,7 @@ async function verifyMediaProjectionRecordingIsSupported(adb) {
|
|
|
59
126
|
`Minimum required API Level is ${MIN_API_LEVEL}.`);
|
|
60
127
|
}
|
|
61
128
|
}
|
|
62
|
-
|
|
63
|
-
* @type {import('./mixins').MediaProjectionMixin & ThisType<import('../driver').AndroidDriver>}
|
|
64
|
-
* @satisfies {import('@appium/types').ExternalDriver}
|
|
65
|
-
*/
|
|
66
|
-
const MediaProjectionMixin = {
|
|
67
|
-
async mobileStartMediaProjectionRecording(options = {}) {
|
|
68
|
-
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
69
|
-
const { resolution, priority, maxDurationSec, filename } = options;
|
|
70
|
-
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
71
|
-
const fname = adjustMediaExtension(filename || (0, moment_1.default)().format(DEFAULT_FILENAME_FORMAT));
|
|
72
|
-
const didStart = await recorder.start({
|
|
73
|
-
resolution,
|
|
74
|
-
priority,
|
|
75
|
-
maxDurationSec,
|
|
76
|
-
filename: fname,
|
|
77
|
-
});
|
|
78
|
-
if (didStart) {
|
|
79
|
-
this.log.info(`A new media projection recording '${fname}' has been successfully started`);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.log.info('Another media projection recording is already in progress. There is nothing to start');
|
|
83
|
-
}
|
|
84
|
-
return didStart;
|
|
85
|
-
},
|
|
86
|
-
async mobileIsMediaProjectionRecordingRunning() {
|
|
87
|
-
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
88
|
-
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
89
|
-
return await recorder.isRunning();
|
|
90
|
-
},
|
|
91
|
-
async mobileStopMediaProjectionRecording(options = {}) {
|
|
92
|
-
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
93
|
-
const recorder = this.settingsApp.makeMediaProjectionRecorder();
|
|
94
|
-
if (await recorder.stop()) {
|
|
95
|
-
this.log.info('Successfully stopped a media projection recording. Pulling the recorded media');
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.log.info('Media projection recording is not running. There is nothing to stop');
|
|
99
|
-
}
|
|
100
|
-
const recentRecordingPath = await recorder.pullRecent();
|
|
101
|
-
if (!recentRecordingPath) {
|
|
102
|
-
throw new Error(`No recent media projection recording have been found. Did you start any?`);
|
|
103
|
-
}
|
|
104
|
-
const { remotePath } = options;
|
|
105
|
-
if (lodash_1.default.isEmpty(remotePath)) {
|
|
106
|
-
const { size } = await support_1.fs.stat(recentRecordingPath);
|
|
107
|
-
this.log.debug(`The size of the resulting media projection recording is ${support_1.util.toReadableSizeString(size)}`);
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
return await uploadRecordedMedia(recentRecordingPath, remotePath, options);
|
|
111
|
-
}
|
|
112
|
-
finally {
|
|
113
|
-
await support_1.fs.rimraf(node_path_1.default.dirname(recentRecordingPath));
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
(0, mixins_1.mixin)(MediaProjectionMixin);
|
|
118
|
-
exports.default = MediaProjectionMixin;
|
|
129
|
+
// #endregion
|
|
119
130
|
/**
|
|
120
131
|
* @typedef {import('appium-adb').ADB} ADB
|
|
121
132
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-projection.js","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media-projection.js","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":";;;;;;AAAA,6CAA8C;AAC9C,oDAAuB;AACvB,oDAA4B;AAC5B,0DAA6B;AAE7B,+EAA+E;AAC/E,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAEtD;;;;GAIG;AACI,KAAK,UAAU,mCAAmC,CAAC,OAAO,GAAG,EAAE;IACpE,MAAM,yCAAyC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE1D,MAAM,EAAC,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC;IACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,2BAA2B,EAAE,CAAC;IAChE,MAAM,KAAK,GAAG,oBAAoB,CAAC,QAAQ,IAAI,IAAA,gBAAM,GAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC;QACpC,UAAU;QACV,QAAQ;QACR,cAAc;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,IAAI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GAAG,WAAW,EAAE,CAAC;AAChF,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,yCAAyC,CAAC,GAAG;IAC1D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IACzC,IAAI,QAAQ,GAAG,aAAa,EAAE;QAC5B,MAAM,IAAI,KAAK,CACb,kEAAkE,QAAQ,IAAI;YAC5E,iCAAiC,aAAa,GAAG,CACpD,CAAC;KACH;AACH,CAAC;AAED,aAAa;AAEb;;GAEG"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export default MemoryMixin;
|
|
2
|
-
export type ADB = import('appium-adb').ADB;
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Simulates the onTrimMemory() event for the given package.
|
|
3
|
+
* Read https://developer.android.com/topic/performance/memory
|
|
4
|
+
* for more details.
|
|
5
|
+
*
|
|
6
|
+
* @this {import('../driver').AndroidDriver}
|
|
7
|
+
* @param {import('./types').SendTrimMemoryOpts} opts
|
|
8
|
+
* @returns {Promise<void>}
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
export function mobileSendTrimMemory(this: import("../driver").AndroidDriver, opts: import('./types').SendTrimMemoryOpts): Promise<void>;
|
|
11
|
+
export type ADB = import('appium-adb').ADB;
|
|
8
12
|
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../lib/commands/memory.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../lib/commands/memory.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,oFAHW,OAAO,SAAS,EAAE,kBAAkB,GAClC,QAAQ,IAAI,CAAC,CAazB;kBAGY,OAAO,YAAY,EAAE,GAAG"}
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mobileSendTrimMemory = void 0;
|
|
3
4
|
const driver_1 = require("appium/driver");
|
|
4
|
-
const mixins_1 = require("./mixins");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Simulates the onTrimMemory() event for the given package.
|
|
7
|
+
* Read https://developer.android.com/topic/performance/memory
|
|
8
|
+
* for more details.
|
|
9
|
+
*
|
|
10
|
+
* @this {import('../driver').AndroidDriver}
|
|
11
|
+
* @param {import('./types').SendTrimMemoryOpts} opts
|
|
12
|
+
* @returns {Promise<void>}
|
|
8
13
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
throw new driver_1.errors.InvalidArgumentError(`The 'pkg' argument must be provided`);
|
|
21
|
-
}
|
|
22
|
-
if (!level) {
|
|
23
|
-
throw new driver_1.errors.InvalidArgumentError(`The 'level' argument must be provided`);
|
|
24
|
-
}
|
|
25
|
-
await this.adb.shell(['am', 'send-trim-memory', pkg, level]);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
(0, mixins_1.mixin)(MemoryMixin);
|
|
29
|
-
exports.default = MemoryMixin;
|
|
14
|
+
async function mobileSendTrimMemory(opts) {
|
|
15
|
+
const { pkg, level } = opts;
|
|
16
|
+
if (!pkg) {
|
|
17
|
+
throw new driver_1.errors.InvalidArgumentError(`The 'pkg' argument must be provided`);
|
|
18
|
+
}
|
|
19
|
+
if (!level) {
|
|
20
|
+
throw new driver_1.errors.InvalidArgumentError(`The 'level' argument must be provided`);
|
|
21
|
+
}
|
|
22
|
+
await this.adb.shell(['am', 'send-trim-memory', pkg, level]);
|
|
23
|
+
}
|
|
24
|
+
exports.mobileSendTrimMemory = mobileSendTrimMemory;
|
|
30
25
|
/**
|
|
31
26
|
* @typedef {import('appium-adb').ADB} ADB
|
|
32
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../lib/commands/memory.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../lib/commands/memory.js"],"names":[],"mappings":";;;AAAA,0CAAqC;AAErC;;;;;;;;GAQG;AACI,KAAK,UAAU,oBAAoB,CAAC,IAAI;IAC7C,MAAM,EAAC,GAAG,EAAE,KAAK,EAAC,GAAG,IAAI,CAAC;IAE1B,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,eAAM,CAAC,oBAAoB,CAAC,qCAAqC,CAAC,CAAC;KAC9E;IACD,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,eAAM,CAAC,oBAAoB,CAAC,uCAAuC,CAAC,CAAC;KAChF;IAED,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/D,CAAC;AAXD,oDAWC;AAED;;GAEG"}
|