tauri-plugin-android-accessibility-api 0.1.0 → 0.2.2
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/README.md +101 -20
- package/dist-js/index.cjs +24 -0
- package/dist-js/index.d.ts +48 -0
- package/dist-js/index.js +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ A mobile plugin based on Tauri v2 for Android accessibility bridging, providing
|
|
|
8
8
|
- Jump to the system accessibility settings page
|
|
9
9
|
- Get a UI tree snapshot of the current foreground window
|
|
10
10
|
- Perform click/long press/focus by node ID (supports falling back to a clickable parent node)
|
|
11
|
+
- Simulate gestures (tap, long press, swipe/drag, multi-touch)
|
|
12
|
+
- Trigger global system actions (back, home, recents, notifications, etc.)
|
|
13
|
+
- Perform generic node actions (scroll, focus navigation, selection)
|
|
11
14
|
|
|
12
15
|
## 1. Functional Description
|
|
13
16
|
|
|
@@ -26,6 +29,14 @@ Implementation entry points:
|
|
|
26
29
|
|
|
27
30
|
## 2. Usage in Tauri App
|
|
28
31
|
|
|
32
|
+
Directly add:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun tauri add android-accessibility
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or add it manually as follows:
|
|
39
|
+
|
|
29
40
|
Register the plugin on the application side:
|
|
30
41
|
|
|
31
42
|
```rust
|
|
@@ -50,6 +61,9 @@ import {
|
|
|
50
61
|
openAccessibilitySettings,
|
|
51
62
|
getFrontmostUiTree,
|
|
52
63
|
clickNode,
|
|
64
|
+
performGesture,
|
|
65
|
+
performGlobalAction,
|
|
66
|
+
performNodeAction,
|
|
53
67
|
} from 'tauri-plugin-android-accessibility-api'
|
|
54
68
|
|
|
55
69
|
const status = await checkAccessibilityEnabled()
|
|
@@ -68,49 +82,116 @@ await clickNode({
|
|
|
68
82
|
action: 'click',
|
|
69
83
|
fallbackToClickableParent: true,
|
|
70
84
|
})
|
|
85
|
+
|
|
86
|
+
await performGesture({
|
|
87
|
+
strokes: [
|
|
88
|
+
{
|
|
89
|
+
points: [
|
|
90
|
+
{ x: 540, y: 1500 },
|
|
91
|
+
{ x: 540, y: 700 },
|
|
92
|
+
],
|
|
93
|
+
durationMs: 320,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
await performGlobalAction({ action: 'back' })
|
|
99
|
+
|
|
100
|
+
await performNodeAction({
|
|
101
|
+
nodeId: '0.1.0',
|
|
102
|
+
action: 'scrollForward',
|
|
103
|
+
fallbackToScrollableParent: true,
|
|
104
|
+
})
|
|
71
105
|
```
|
|
72
106
|
|
|
73
107
|
## 3. API List
|
|
74
108
|
|
|
75
|
-
### checkAccessibilityEnabled
|
|
109
|
+
### `checkAccessibilityEnabled`
|
|
76
110
|
|
|
77
111
|
Returns:
|
|
78
112
|
|
|
79
|
-
- enabled
|
|
80
|
-
- serviceId
|
|
81
|
-
- enabledServices
|
|
113
|
+
- `enabled`: Whether the current app's accessibility service is enabled
|
|
114
|
+
- `serviceId`: Current service component ID
|
|
115
|
+
- `enabledServices`: List of accessibility services currently enabled by the system
|
|
116
|
+
|
|
117
|
+
### `openAccessibilitySettings`
|
|
118
|
+
|
|
119
|
+
Opens the system accessibility settings page, returns `opened`.
|
|
120
|
+
|
|
121
|
+
### `getFrontmostUiTree`
|
|
82
122
|
|
|
83
|
-
|
|
123
|
+
Parameters:
|
|
124
|
+
|
|
125
|
+
- `maxDepth`: Tree depth limit
|
|
126
|
+
- `maxChildrenPerNode`: Maximum number of child nodes per node
|
|
127
|
+
- `includeNonClickable`: Whether to include non-clickable leaf nodes
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
|
|
131
|
+
- `timestampMs`
|
|
132
|
+
- `packageName`
|
|
133
|
+
- `root` (recursive UI node)
|
|
134
|
+
|
|
135
|
+
### `clickNode`
|
|
136
|
+
|
|
137
|
+
Parameters:
|
|
138
|
+
|
|
139
|
+
- `nodeId`: Node path ID in the UI tree (e.g., 0.1.2)
|
|
140
|
+
- `action`: `click` | `longClick` | `focus`
|
|
141
|
+
- `fallbackToClickableParent`: Whether to fall back to a parent node click if the target fails
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
|
|
145
|
+
- `success`
|
|
146
|
+
- `performedOnNodeId`
|
|
147
|
+
- `message`
|
|
148
|
+
|
|
149
|
+
### `performGesture`
|
|
150
|
+
|
|
151
|
+
Parameters:
|
|
152
|
+
|
|
153
|
+
- `strokes`: Array of gesture strokes
|
|
154
|
+
- `strokes[].points`: Path points as `[{ x, y }, ...]`
|
|
155
|
+
- `strokes[].startTimeMs`: Relative start time for this stroke (optional)
|
|
156
|
+
- `strokes[].durationMs`: Duration of the stroke in milliseconds
|
|
157
|
+
- `strokes[].willContinue`: Whether the stroke should continue (optional)
|
|
158
|
+
|
|
159
|
+
Notes:
|
|
160
|
+
|
|
161
|
+
- Tap: 1 point + short duration
|
|
162
|
+
- Long press: 1 point + long duration
|
|
163
|
+
- Swipe/drag: 2 or more points
|
|
164
|
+
- Multi-touch: multiple strokes in one request
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
84
167
|
|
|
85
|
-
|
|
168
|
+
- `success`
|
|
169
|
+
- `message`
|
|
86
170
|
|
|
87
|
-
###
|
|
171
|
+
### `performGlobalAction`
|
|
88
172
|
|
|
89
173
|
Parameters:
|
|
90
174
|
|
|
91
|
-
-
|
|
92
|
-
- maxChildrenPerNode: Maximum number of child nodes per node
|
|
93
|
-
- includeNonClickable: Whether to include non-clickable leaf nodes
|
|
175
|
+
- `action`: `back` | `home` | `recents` | `notifications` | `quickSettings` | `powerDialog` | `lockScreen` | `takeScreenshot`
|
|
94
176
|
|
|
95
177
|
Returns:
|
|
96
178
|
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
- root (recursive UI node)
|
|
179
|
+
- `success`
|
|
180
|
+
- `message`
|
|
100
181
|
|
|
101
|
-
###
|
|
182
|
+
### `performNodeAction`
|
|
102
183
|
|
|
103
184
|
Parameters:
|
|
104
185
|
|
|
105
|
-
- nodeId
|
|
106
|
-
- action
|
|
107
|
-
-
|
|
186
|
+
- `nodeId`: Node path ID in the UI tree
|
|
187
|
+
- `action`: `click` | `longClick` | `focus` | `clearFocus` | `select` | `clearSelection` | `scrollForward` | `scrollBackward`
|
|
188
|
+
- `fallbackToScrollableParent`: Whether to fallback to a scrollable parent for failed scroll actions
|
|
108
189
|
|
|
109
190
|
Returns:
|
|
110
191
|
|
|
111
|
-
- success
|
|
112
|
-
- performedOnNodeId
|
|
113
|
-
- message
|
|
192
|
+
- `success`
|
|
193
|
+
- `performedOnNodeId`
|
|
194
|
+
- `message`
|
|
114
195
|
|
|
115
196
|
## 4. Android Specifications and Limitations
|
|
116
197
|
|
package/dist-js/index.cjs
CHANGED
|
@@ -25,9 +25,33 @@ async function clickNode(payload) {
|
|
|
25
25
|
payload,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
+
async function performGesture(payload) {
|
|
29
|
+
return await core.invoke('plugin:android-accessibility|perform_gesture', {
|
|
30
|
+
payload,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async function performGlobalAction(payload) {
|
|
34
|
+
return await core.invoke('plugin:android-accessibility|perform_global_action', {
|
|
35
|
+
payload,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function performNodeAction(payload) {
|
|
39
|
+
return await core.invoke('plugin:android-accessibility|perform_node_action', {
|
|
40
|
+
payload,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function typeText(payload) {
|
|
44
|
+
return await core.invoke('plugin:android-accessibility|type_text', {
|
|
45
|
+
payload,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
28
48
|
|
|
29
49
|
exports.checkAccessibilityEnabled = checkAccessibilityEnabled;
|
|
30
50
|
exports.clickNode = clickNode;
|
|
31
51
|
exports.getFrontmostUiTree = getFrontmostUiTree;
|
|
32
52
|
exports.openAccessibilitySettings = openAccessibilitySettings;
|
|
53
|
+
exports.performGesture = performGesture;
|
|
54
|
+
exports.performGlobalAction = performGlobalAction;
|
|
55
|
+
exports.performNodeAction = performNodeAction;
|
|
33
56
|
exports.ping = ping;
|
|
57
|
+
exports.typeText = typeText;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -52,7 +52,55 @@ export interface ClickNodeResponse {
|
|
|
52
52
|
export interface OpenSettingsResponse {
|
|
53
53
|
opened: boolean;
|
|
54
54
|
}
|
|
55
|
+
export interface GesturePoint {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
}
|
|
59
|
+
export interface GestureStroke {
|
|
60
|
+
points: GesturePoint[];
|
|
61
|
+
startTimeMs?: number;
|
|
62
|
+
durationMs: number;
|
|
63
|
+
willContinue?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface PerformGestureRequest {
|
|
66
|
+
strokes: GestureStroke[];
|
|
67
|
+
}
|
|
68
|
+
export interface PerformGestureResponse {
|
|
69
|
+
success: boolean;
|
|
70
|
+
message?: string | null;
|
|
71
|
+
}
|
|
72
|
+
export type GlobalActionType = 'back' | 'home' | 'recents' | 'notifications' | 'quickSettings' | 'powerDialog' | 'lockScreen' | 'takeScreenshot';
|
|
73
|
+
export interface GlobalActionRequest {
|
|
74
|
+
action: GlobalActionType;
|
|
75
|
+
}
|
|
76
|
+
export interface GlobalActionResponse {
|
|
77
|
+
success: boolean;
|
|
78
|
+
message?: string | null;
|
|
79
|
+
}
|
|
80
|
+
export type NodeActionType = 'click' | 'longClick' | 'focus' | 'clearFocus' | 'select' | 'clearSelection' | 'scrollForward' | 'scrollBackward';
|
|
81
|
+
export interface NodeActionRequest {
|
|
82
|
+
nodeId: string;
|
|
83
|
+
action: NodeActionType;
|
|
84
|
+
fallbackToScrollableParent?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface NodeActionResponse {
|
|
87
|
+
success: boolean;
|
|
88
|
+
performedOnNodeId?: string | null;
|
|
89
|
+
message?: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface TypeTextRequest {
|
|
92
|
+
nodeId: string;
|
|
93
|
+
text: string;
|
|
94
|
+
}
|
|
95
|
+
export interface TypeTextResponse {
|
|
96
|
+
success: boolean;
|
|
97
|
+
message?: string | null;
|
|
98
|
+
}
|
|
55
99
|
export declare function checkAccessibilityEnabled(): Promise<AccessibilityPermissionStatus>;
|
|
56
100
|
export declare function openAccessibilitySettings(): Promise<OpenSettingsResponse>;
|
|
57
101
|
export declare function getFrontmostUiTree(payload?: UiTreeRequest): Promise<UiTreeResponse>;
|
|
58
102
|
export declare function clickNode(payload: ClickNodeRequest): Promise<ClickNodeResponse>;
|
|
103
|
+
export declare function performGesture(payload: PerformGestureRequest): Promise<PerformGestureResponse>;
|
|
104
|
+
export declare function performGlobalAction(payload: GlobalActionRequest): Promise<GlobalActionResponse>;
|
|
105
|
+
export declare function performNodeAction(payload: NodeActionRequest): Promise<NodeActionResponse>;
|
|
106
|
+
export declare function typeText(payload: TypeTextRequest): Promise<TypeTextResponse>;
|
package/dist-js/index.js
CHANGED
|
@@ -23,5 +23,25 @@ async function clickNode(payload) {
|
|
|
23
23
|
payload,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
async function performGesture(payload) {
|
|
27
|
+
return await invoke('plugin:android-accessibility|perform_gesture', {
|
|
28
|
+
payload,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function performGlobalAction(payload) {
|
|
32
|
+
return await invoke('plugin:android-accessibility|perform_global_action', {
|
|
33
|
+
payload,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function performNodeAction(payload) {
|
|
37
|
+
return await invoke('plugin:android-accessibility|perform_node_action', {
|
|
38
|
+
payload,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function typeText(payload) {
|
|
42
|
+
return await invoke('plugin:android-accessibility|type_text', {
|
|
43
|
+
payload,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
26
46
|
|
|
27
|
-
export { checkAccessibilityEnabled, clickNode, getFrontmostUiTree, openAccessibilitySettings, ping };
|
|
47
|
+
export { checkAccessibilityEnabled, clickNode, getFrontmostUiTree, openAccessibilitySettings, performGesture, performGlobalAction, performNodeAction, ping, typeText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-android-accessibility-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"author": "ShizukuAqua",
|
|
5
5
|
"description": "A Tauri plugin that supports Android accessibility features, allowing Tauri applications to interact with Android's accessibility services for enhanced functionality and user experience.",
|
|
6
6
|
"license": "MIT",
|