Skip to content

Commit

Permalink
feat: Add support of UiModeManager service commands (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Nov 3, 2023
1 parent 9703a3d commit 89303f0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,36 @@ A dictionary where each key is the diplay identifier and the value has the follo
- `isDefault`: Whether this display is the default one
- `payload`: The actual PNG screenshot data encoded to base64 string

### mobile: setUiMode

Set the device UI appearance. A thin wrapper over `adb shell cmd uimode` CLI.
Works on Android 10 and newer. Available since driver version 2.34

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
mode | string | yes | One of the supported UI mode names: `night` or `car`. | night
value | string | yes | The actual mode value to set. Supported values for different UI modes are: `night`: yes,no,auto,custom_schedule,custom_bedtime, `car`: yes,no. For example, to switch the device UI to the dark mode you should set `mode` to `night` and `value` to `yes`, or to `no` in order to switch back to the light mode. | yes

### mobile: getUiMode

Gets the device UI appearance for the given mode. A thin wrapper over `adb shell cmd uimode` CLI. Works on Android 10 and newer. Available since driver version 2.34

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
mode | string | yes | One of the supported UI mode names: `night` or `car`. | night

#### Returned Result

The actual mode value. Supported values for different UI modes are:

- `night`: yes,no,auto,custom_schedule,custom_bedtime
- `car`: yes,no


## Applications Management

UiAutomator2 driver supports Appium endpoints for applications management:
Expand Down
15 changes: 13 additions & 2 deletions lib/execute-method-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,20 +562,31 @@ export const executeMethodMap = {
optional: ['opts'],
},
},

'mobile: getActionHistory': {
command: 'mobileGetActionHistory',
params: {
optional: ['opts'],
},
},

'mobile: unscheduleAction': {
command: 'mobileUnscheduleAction',
params: {
optional: ['opts'],
},
},

'mobile: getUiMode': {
command: 'mobileGetUiMode',
params: {
optional: ['opts'],
},
},
'mobile: setUiMode': {
command: 'mobileSetUiMode',
params: {
optional: ['opts'],
},
},
} as const;

export type Uiautomator2ExecuteMethodMap = typeof executeMethodMap;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"appium-adb": "^11.0.1",
"appium-android-driver": "^7.2.1",
"appium-android-driver": "^7.3.0",
"appium-chromedriver": "^5.6.5",
"appium-uiautomator2-server": "^5.12.2",
"asyncbox": "^3.0.0",
Expand Down

0 comments on commit 89303f0

Please sign in to comment.