dhan-accessibility-plugin 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # DHAN Accessibility Plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A user-controlled Android Accessibility bridge for DHAN AI QUEEN, built as a Capacitor 7 plugin.
4
+
5
+ ## Implemented source capabilities
6
+
7
+ - Open Android Accessibility settings.
8
+ - Check whether the accessibility service is enabled.
9
+ - Read visible, non-password screen text when explicitly requested.
10
+ - Click a matching visible text label when explicitly requested.
11
+ - Perform requested tap and swipe gestures.
12
+
13
+ ## Current development status
14
+
15
+ The TypeScript and Android Java source files are present.
16
+ TypeScript checks and builds have passed locally.
17
+
18
+ Android compilation, device installation, accessibility enablement,
19
+ and real-device testing have not yet been verified.
20
+
21
+ ## Safety
22
+
23
+ - The user must enable the Android Accessibility service manually.
24
+ - The service must remain visible, user-controlled, and interruptible.
25
+ - No automatic background tapping or screen collection.
26
+ - Never bypass CAPTCHA, identity verification, anti-bot systems,
27
+ offer tracking, or human-only task requirements.
28
+ - Screen content is not intentionally uploaded or stored by this plugin.
@@ -0,0 +1,15 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ android {
4
+ namespace "com.dhan.accessibility"
5
+ compileSdkVersion 35
6
+
7
+ defaultConfig {
8
+ minSdkVersion 23
9
+ targetSdkVersion 35
10
+ }
11
+ }
12
+
13
+ dependencies {
14
+ implementation project(':capacitor-android')
15
+ }
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <application>
4
+ <service
5
+ android:name="com.dhan.accessibility.DhanAccessibilityService"
6
+ android:label="DHAN AI QUEEN Accessibility"
7
+ android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
8
+ android:exported="true">
9
+ <intent-filter>
10
+ <action android:name="android.accessibilityservice.AccessibilityService" />
11
+ </intent-filter>
12
+ <meta-data
13
+ android:name="android.accessibilityservice"
14
+ android:resource="@xml/dhan_accessibility_config" />
15
+ </service>
16
+ </application>
17
+ </manifest>
@@ -0,0 +1,159 @@
1
+ package com.dhan.accessibility;
2
+
3
+ import android.content.ComponentName;
4
+ import android.content.Intent;
5
+ import android.provider.Settings;
6
+ import android.text.TextUtils;
7
+
8
+ import com.getcapacitor.Plugin;
9
+ import com.getcapacitor.PluginCall;
10
+ import com.getcapacitor.PluginMethod;
11
+ import com.getcapacitor.annotation.CapacitorPlugin;
12
+ import com.getcapacitor.JSObject;
13
+
14
+ @CapacitorPlugin(name = "DhanAccessibility")
15
+ public class DhanAccessibilityPlugin extends Plugin {
16
+
17
+ @PluginMethod
18
+ public void openAccessibilitySettings(PluginCall call) {
19
+ Intent intent = new Intent(
20
+ Settings.ACTION_ACCESSIBILITY_SETTINGS
21
+ );
22
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
23
+ getContext().startActivity(intent);
24
+ call.resolve();
25
+ }
26
+
27
+ @PluginMethod
28
+ public void getStatus(PluginCall call) {
29
+ String enabledServices = Settings.Secure.getString(
30
+ getContext().getContentResolver(),
31
+ Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES
32
+ );
33
+
34
+ ComponentName component = new ComponentName(
35
+ getContext(),
36
+ DhanAccessibilityService.class
37
+ );
38
+
39
+ String expected = component.flattenToString();
40
+
41
+ boolean enabled = false;
42
+
43
+ if (!TextUtils.isEmpty(enabledServices)) {
44
+ TextUtils.SimpleStringSplitter splitter =
45
+ new TextUtils.SimpleStringSplitter(':');
46
+
47
+ splitter.setString(enabledServices);
48
+
49
+ while (splitter.hasNext()) {
50
+ if (expected.equalsIgnoreCase(splitter.next())) {
51
+ enabled = true;
52
+ break;
53
+ }
54
+ }
55
+ }
56
+
57
+ JSObject result = new JSObject();
58
+ result.put("enabled", enabled);
59
+ call.resolve(result);
60
+ }
61
+
62
+ @PluginMethod
63
+ public void readScreen(PluginCall call) {
64
+ DhanAccessibilityService service =
65
+ DhanAccessibilityService.getInstance();
66
+
67
+ if (service == null) {
68
+ call.reject("Enable DHAN Accessibility in Android Settings first.");
69
+ return;
70
+ }
71
+
72
+ JSObject result = new JSObject();
73
+ result.put("text", new org.json.JSONArray(
74
+ service.readVisibleText()
75
+ ));
76
+ call.resolve(result);
77
+ }
78
+
79
+ @PluginMethod
80
+ public void clickText(PluginCall call) {
81
+ String text = call.getString("text");
82
+
83
+ if (text == null || text.trim().isEmpty()) {
84
+ call.reject("A visible text label is required.");
85
+ return;
86
+ }
87
+
88
+ DhanAccessibilityService service =
89
+ DhanAccessibilityService.getInstance();
90
+
91
+ if (service == null) {
92
+ call.reject("Accessibility service is not enabled.");
93
+ return;
94
+ }
95
+
96
+ JSObject result = new JSObject();
97
+ result.put("clicked", service.clickText(text));
98
+ call.resolve(result);
99
+ }
100
+
101
+ @PluginMethod
102
+ public void tap(PluginCall call) {
103
+ Double x = call.getDouble("x");
104
+ Double y = call.getDouble("y");
105
+
106
+ if (x == null || y == null) {
107
+ call.reject("Both x and y coordinates are required.");
108
+ return;
109
+ }
110
+
111
+ DhanAccessibilityService service =
112
+ DhanAccessibilityService.getInstance();
113
+
114
+ if (service == null) {
115
+ call.reject("Accessibility service is not enabled.");
116
+ return;
117
+ }
118
+
119
+ service.tap(x.floatValue(), y.floatValue(), success -> {
120
+ JSObject result = new JSObject();
121
+ result.put("performed", success);
122
+ call.resolve(result);
123
+ });
124
+ }
125
+
126
+ @PluginMethod
127
+ public void swipe(PluginCall call) {
128
+ Double sx = call.getDouble("startX");
129
+ Double sy = call.getDouble("startY");
130
+ Double ex = call.getDouble("endX");
131
+ Double ey = call.getDouble("endY");
132
+
133
+ if (sx == null || sy == null || ex == null || ey == null) {
134
+ call.reject("All four swipe coordinates are required.");
135
+ return;
136
+ }
137
+
138
+ Long duration = call.getLong("duration", 500L);
139
+
140
+ DhanAccessibilityService service =
141
+ DhanAccessibilityService.getInstance();
142
+
143
+ if (service == null) {
144
+ call.reject("Accessibility service is not enabled.");
145
+ return;
146
+ }
147
+
148
+ service.swipe(
149
+ sx.floatValue(), sy.floatValue(),
150
+ ex.floatValue(), ey.floatValue(),
151
+ duration == null ? 500L : duration,
152
+ success -> {
153
+ JSObject result = new JSObject();
154
+ result.put("performed", success);
155
+ call.resolve(result);
156
+ }
157
+ );
158
+ }
159
+ }
@@ -0,0 +1,236 @@
1
+ package com.dhan.accessibility;
2
+
3
+ import android.accessibilityservice.AccessibilityService;
4
+ import android.accessibilityservice.GestureDescription;
5
+ import android.graphics.Path;
6
+ import android.view.accessibility.AccessibilityEvent;
7
+ import android.view.accessibility.AccessibilityNodeInfo;
8
+ import android.util.DisplayMetrics;
9
+
10
+ import java.util.ArrayList;
11
+ import java.util.List;
12
+
13
+ public class DhanAccessibilityService extends AccessibilityService {
14
+
15
+ private static volatile DhanAccessibilityService instance;
16
+
17
+ public interface GestureResult {
18
+ void complete(boolean success);
19
+ }
20
+
21
+ @Override
22
+ protected void onServiceConnected() {
23
+ super.onServiceConnected();
24
+ instance = this;
25
+ }
26
+
27
+ @Override
28
+ public void onAccessibilityEvent(AccessibilityEvent event) {
29
+ // No automatic actions or background screen collection.
30
+ }
31
+
32
+ @Override
33
+ public void onInterrupt() {
34
+ // Accessibility service interrupted by Android.
35
+ }
36
+
37
+ @Override
38
+ public void onDestroy() {
39
+ if (instance == this) instance = null;
40
+ super.onDestroy();
41
+ }
42
+
43
+ public static DhanAccessibilityService getInstance() {
44
+ return instance;
45
+ }
46
+
47
+ public List<String> readVisibleText() {
48
+ List<String> result = new ArrayList<>();
49
+ AccessibilityNodeInfo root = getRootInActiveWindow();
50
+
51
+ if (root != null) {
52
+ try {
53
+ collectText(root, result);
54
+ } finally {
55
+ root.recycle();
56
+ }
57
+ }
58
+
59
+ return result;
60
+ }
61
+
62
+ private void collectText(
63
+ AccessibilityNodeInfo node,
64
+ List<String> result
65
+ ) {
66
+ if (node == null || result.size() >= 150) return;
67
+
68
+ if (node.isVisibleToUser() && !node.isPassword()) {
69
+ CharSequence text = node.getText();
70
+ CharSequence description = node.getContentDescription();
71
+
72
+ addText(text, result);
73
+ addText(description, result);
74
+ }
75
+
76
+ for (int i = 0; i < node.getChildCount(); i++) {
77
+ if (result.size() >= 150) break;
78
+ AccessibilityNodeInfo child = node.getChild(i);
79
+ if (child != null) {
80
+ try {
81
+ collectText(child, result);
82
+ } finally {
83
+ child.recycle();
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ private void addText(CharSequence value, List<String> result) {
90
+ if (value == null || result.size() >= 150) return;
91
+
92
+ String text = value.toString().trim();
93
+
94
+ if (!text.isEmpty() && !result.contains(text)) {
95
+ result.add(text);
96
+ }
97
+ }
98
+
99
+ public boolean clickText(String query) {
100
+ if (query == null || query.trim().isEmpty()) return false;
101
+
102
+ AccessibilityNodeInfo root = getRootInActiveWindow();
103
+ if (root == null) return false;
104
+
105
+ try {
106
+ List<AccessibilityNodeInfo> matches =
107
+ root.findAccessibilityNodeInfosByText(query);
108
+
109
+ if (matches == null) return false;
110
+
111
+ try {
112
+ for (AccessibilityNodeInfo node : matches) {
113
+ if (node == null || node.isPassword()) continue;
114
+
115
+ AccessibilityNodeInfo current =
116
+ AccessibilityNodeInfo.obtain(node);
117
+
118
+ try {
119
+ for (int depth = 0;
120
+ current != null && depth < 8;
121
+ depth++) {
122
+
123
+ if (current.isClickable() && current.isEnabled()) {
124
+ return current.performAction(
125
+ AccessibilityNodeInfo.ACTION_CLICK
126
+ );
127
+ }
128
+
129
+ AccessibilityNodeInfo parent = current.getParent();
130
+ current.recycle();
131
+ current = parent;
132
+ }
133
+ } finally {
134
+ if (current != null) current.recycle();
135
+ }
136
+ }
137
+ } finally {
138
+ for (AccessibilityNodeInfo node : matches) {
139
+ if (node != null) node.recycle();
140
+ }
141
+ }
142
+
143
+ return false;
144
+ } finally {
145
+ root.recycle();
146
+ }
147
+ }
148
+
149
+ private boolean validPoint(float x, float y) {
150
+ DisplayMetrics metrics =
151
+ getResources().getDisplayMetrics();
152
+
153
+ return x >= 0 && y >= 0
154
+ && x < metrics.widthPixels
155
+ && y < metrics.heightPixels;
156
+ }
157
+
158
+ public void tap(float x, float y, GestureResult callback) {
159
+ if (!validPoint(x, y)) {
160
+ callback.complete(false);
161
+ return;
162
+ }
163
+
164
+ Path path = new Path();
165
+ path.moveTo(x, y);
166
+
167
+ GestureDescription gesture =
168
+ new GestureDescription.Builder()
169
+ .addStroke(
170
+ new GestureDescription.StrokeDescription(
171
+ path, 0, 100
172
+ )
173
+ )
174
+ .build();
175
+
176
+ dispatchGesture(
177
+ gesture,
178
+ new GestureResultCallback() {
179
+ @Override
180
+ public void onCompleted(GestureDescription g) {
181
+ callback.complete(true);
182
+ }
183
+
184
+ @Override
185
+ public void onCancelled(GestureDescription g) {
186
+ callback.complete(false);
187
+ }
188
+ },
189
+ null
190
+ );
191
+ }
192
+
193
+ public void swipe(
194
+ float startX, float startY,
195
+ float endX, float endY,
196
+ long duration,
197
+ GestureResult callback
198
+ ) {
199
+ if (!validPoint(startX, startY)
200
+ || !validPoint(endX, endY)) {
201
+ callback.complete(false);
202
+ return;
203
+ }
204
+
205
+ long safeDuration = Math.max(100, Math.min(duration, 2000));
206
+
207
+ Path path = new Path();
208
+ path.moveTo(startX, startY);
209
+ path.lineTo(endX, endY);
210
+
211
+ GestureDescription gesture =
212
+ new GestureDescription.Builder()
213
+ .addStroke(
214
+ new GestureDescription.StrokeDescription(
215
+ path, 0, safeDuration
216
+ )
217
+ )
218
+ .build();
219
+
220
+ dispatchGesture(
221
+ gesture,
222
+ new GestureResultCallback() {
223
+ @Override
224
+ public void onCompleted(GestureDescription g) {
225
+ callback.complete(true);
226
+ }
227
+
228
+ @Override
229
+ public void onCancelled(GestureDescription g) {
230
+ callback.complete(false);
231
+ }
232
+ },
233
+ null
234
+ );
235
+ }
236
+ }
@@ -0,0 +1,3 @@
1
+ <resources>
2
+ <string name="dhan_accessibility_description">Allows DHAN AI QUEEN to read visible screen text and perform actions explicitly requested by the user. The user controls this service in Android Accessibility Settings.</string>
3
+ </resources>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <accessibility-service
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:description="@string/dhan_accessibility_description"
5
+ android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged"
6
+ android:accessibilityFeedbackType="feedbackGeneric"
7
+ android:notificationTimeout="100"
8
+ android:canRetrieveWindowContent="true"
9
+ android:canPerformGestures="true"
10
+ android:accessibilityFlags="flagReportViewIds|flagRetrieveInteractiveWindows" />
@@ -0,0 +1,29 @@
1
+ export interface DhanAccessibilityPlugin {
2
+ openAccessibilitySettings(): Promise<void>;
3
+ getStatus(): Promise<{
4
+ enabled: boolean;
5
+ }>;
6
+ readScreen(): Promise<{
7
+ text: string[];
8
+ }>;
9
+ clickText(options: {
10
+ text: string;
11
+ }): Promise<{
12
+ clicked: boolean;
13
+ }>;
14
+ tap(options: {
15
+ x: number;
16
+ y: number;
17
+ }): Promise<{
18
+ performed: boolean;
19
+ }>;
20
+ swipe(options: {
21
+ startX: number;
22
+ startY: number;
23
+ endX: number;
24
+ endY: number;
25
+ duration?: number;
26
+ }): Promise<{
27
+ performed: boolean;
28
+ }>;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { DhanAccessibilityPlugin } from './definitions';
2
+ declare const DhanAccessibility: DhanAccessibilityPlugin;
3
+ export * from './definitions';
4
+ export { DhanAccessibility };
@@ -0,0 +1,4 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const DhanAccessibility = registerPlugin('DhanAccessibility');
3
+ export * from './definitions';
4
+ export { DhanAccessibility };
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "dhan-accessibility-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "User-controlled Android accessibility bridge for DHAN AI QUEEN",
5
+ "type": "module",
6
+ "main": "dist/esm/index.js",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "files": [
10
+ "dist/",
11
+ "android/"
12
+ ],
13
+ "keywords": [
14
+ "capacitor",
15
+ "android",
16
+ "accessibility",
17
+ "dhan-ai"
18
+ ],
19
+ "license": "MIT",
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "check": "tsc --noEmit"
23
+ },
24
+ "peerDependencies": {
25
+ "@capacitor/core": ">=7.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@capacitor/android": "^7.6.11",
29
+ "@capacitor/core": "^7.0.0",
30
+ "typescript": "^5.7.0"
31
+ },
32
+ "capacitor": {
33
+ "android": {
34
+ "src": "android"
35
+ }
36
+ }
37
+ }