From 908938199340fb351f5c647594bf9bc856f90be0 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 10 Jan 2024 22:58:33 +0100 Subject: [PATCH 1/2] feat: Document the helper method to simulate the low-memory event --- README.md | 13 +++++++++++++ lib/execute-method-map.ts | 7 +++++++ package.json | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 879a9217e..c624179b3 100644 --- a/README.md +++ b/README.md @@ -1465,6 +1465,19 @@ The actual mode value. Supported values for different UI modes are: - `night`: yes,no,auto,custom_schedule,custom_bedtime - `car`: yes,no +### mobile: sendTrimMemory + +Simulates the [onTrimMemory()](https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)) event for the given package, which allows to verify the app functinality under different RAM-related circumstances. +Read [Manage your app's memory](https://developer.android.com/topic/performance/memory) for more details. +Available since driver version 2.41 + +#### Arguments + +Name | Type | Required | Description | Example +--- | --- | --- | --- | --- +pkg | string | yes | The package name to send the `trimMemory` event to. | com.my.company +level | 'COMPLETE' or 'MODERATE' or 'BACKGROUND' or 'UI_HIDDEN' or 'RUNNING_CRITICAL' or 'RUNNING_LOW' or 'RUNNING_MODERATE' | yes | The actual memory trim level to simulate | RUNNING_CRITICAL + ## Applications Management diff --git a/lib/execute-method-map.ts b/lib/execute-method-map.ts index 377b37147..bb35b3d1c 100644 --- a/lib/execute-method-map.ts +++ b/lib/execute-method-map.ts @@ -590,6 +590,13 @@ export const executeMethodMap = { optional: ['opts'], }, }, + + 'mobile: sendTrimMemory': { + command: 'mobileSendTrimMemory', + params: { + optional: ['opts'], + } + } } as const; export type Uiautomator2ExecuteMethodMap = typeof executeMethodMap; diff --git a/package.json b/package.json index 2b72d2197..1414623fb 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ }, "dependencies": { "appium-adb": "^11.0.1", - "appium-android-driver": "^7.6.1", + "appium-android-driver": "^7.7.0", "appium-chromedriver": "^5.6.5", "appium-uiautomator2-server": "^6.0.3", "asyncbox": "^3.0.0", From 8d3174e25a4174b0e55ef67f81ac616723dd41ab Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 10 Jan 2024 22:59:49 +0100 Subject: [PATCH 2/2] prettify --- lib/execute-method-map.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/execute-method-map.ts b/lib/execute-method-map.ts index bb35b3d1c..5c8dc9f63 100644 --- a/lib/execute-method-map.ts +++ b/lib/execute-method-map.ts @@ -596,7 +596,8 @@ export const executeMethodMap = { params: { optional: ['opts'], } - } + }, + } as const; export type Uiautomator2ExecuteMethodMap = typeof executeMethodMap;