The most common answer is that you need to add android:canPerformGestures="true", but I already added it. Please help me understand this. I'm writing a program in flutter, and I'm trying to make gestures through the created plugin. Permissions are granted and the onServiceConnected function is called. Gesture code:
fun clickAt(x: Int, y: Int): Boolean {
val gestureBuilder = GestureDescription.Builder()
val path = Path()
path.moveTo(x.toFloat(), y.toFloat())
gestureBuilder.addStroke(GestureDescription.StrokeDescription(path, 0, 1L))
val gesture: GestureDescription = gestureBuilder.build()
return dispatchGesture(gesture, object : GestureResultCallback() {
override fun onCompleted(gestureDescription: GestureDescription) {
Log.d("start", "+++++");
super.onCompleted(gestureDescription)
}
override fun onCancelled(gestureDescription: GestureDescription) {
Log.d("start", "-----");
super.onCancelled(gestureDescription)
}
}, null)
}
Code added to manifest:
<service
android:name="com.example.macroexternal.macrodroid.accessibility_plugin.TextReaderAccessibilityService"
android:exported="false"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibilityservice" />
</service>
Code added to a separate xml file accessibilityservice:
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:canPerformGestures="true"
android:accessibilityEventTypes="typeWindowsChanged|typeAllMask|typeWindowStateChanged|typeWindowContentChanged"
android:notificationTimeout="300"
android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagRequestEnhancedWebAccessibility|flagReportViewIds"
android:canRetrieveWindowContent="true"
android:settingsActivity="com.example.macroexternal.SettingsActivity"
android:canRequestTouchExplorationMode="true"
>
</accessibility-service>
I can't figure out what I'm missing. dispatchGesture always returns false and the onCompleted and onCancelled functions are not called
I tried reading the documentation and asking about GPT, but couldn't find anything additional.
I was creating my own instance of the AccessibilityService class however the application creates this class itself as a service.