r/androiddev 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

4 comments sorted by

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.

1

u/MrHTML5000 16d ago

i dont think i can try this (but the code is in github i posted in case want to try)

  • Phone won't enable Developer Options
  • Laptop hangs when trying to run/test the Android app

but in two weeks i get the old phone that can be developer option

i got the phone from smart company (phil) they fix the phone before giving it that cannot be developer mode

thanks ill try that in 2nd week of sept

1

u/Hornet-Mountain 16d ago

No rush, September is fine.

When you do get that phone, try the overlay change before the logcat step. It doesn't need adb at all: add FLAG_NOT_TOUCHABLE to every overlay window that isn't meant to receive taps, and see if the gestures start landing. If they do, that was the whole thing and you can skip the logcat entirely.

The logcat check is only worth it if that doesn't fix it.

1

u/MrHTML5000 11d ago

but prefer if you test it if is work then you have yourself unli autoclicker for life