-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathmemory.js
27 lines (24 loc) · 894 Bytes
/
memory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {errors} from 'appium/driver';
/**
* Simulates the onTrimMemory() event for the given package.
* Read https://developer.android.com/topic/performance/memory
* for more details.
*
* @this {import('../driver').AndroidDriver}
* @param {string} pkg The package name to send the `trimMemory` event to
* @param {'COMPLETE' | 'MODERATE' | 'BACKGROUND' | 'UI_HIDDEN' | 'RUNNING_CRITICAL' | 'RUNNING_LOW' | 'RUNNING_MODERATE'} level The
* actual memory trim level to be sent
* @returns {Promise<void>}
*/
export async function mobileSendTrimMemory(pkg, level) {
if (!pkg) {
throw new errors.InvalidArgumentError(`The 'pkg' argument must be provided`);
}
if (!level) {
throw new errors.InvalidArgumentError(`The 'level' argument must be provided`);
}
await this.adb.shell(['am', 'send-trim-memory', pkg, level]);
}
/**
* @typedef {import('appium-adb').ADB} ADB
*/