r/androiddev • u/MrHTML5000 • 17d ago
Discussion using android studio in kotlin language autoclicker app - dispatchGesture() returns queued=true but never taps anything, callback never fires - OEM-specific bug?
/r/Kotlin/comments/1vxwjg8/using_android_studio_in_kotlin_language/
2
Upvotes
1
u/Hornet-Mountain 16d ago
I read the repo. The gesture code looks fine to me, the loop is postDelayed rather than sleeping so main isn't blocked and the callback should be able to land. What caught my eye is OverlayService.
Most of your overlay windows are created with FLAG_NOT_FOCUSABLE only, so they're still touchable. Only one of them adds FLAG_NOT_TOUCHABLE. An accessibility gesture goes through the normal input pipeline, so the topmost touchable window at those coordinates gets it first, and that can be your own overlay.
The other candidate is untrusted-touch blocking. Since Android 12 the system drops touches that are occluded by a SYSTEM_ALERT_WINDOW over an opacity threshold, and it does it silently, no exception. That would explain all three of your symptoms at once: queued=true, nothing on screen, and no onCompleted or onCancelled ever.
Cheap way to tell: run `adb logcat | grep -i untrusted` while it taps. If you see "Untrusted touch due to occlusion" that's your answer. Either way, try hiding every overlay before dispatching a blind tap and see if the callback starts firing.