Search code examples
androidandroid-source

Android: Catch and intercept all gestures


I'm building custom launcher for a custom rom (Android 9), so I have root, system uid for the launcher or even an access to change android sources. I want to build custom gesture that will be available at any time at any application. So I have to have an ability to listen to all gestures and perhaps an ability to intercept them.

As I know there is an ability to show all touch events inside the developer settings, but how is it done? where this code is located? Or is there any other place where I can listen for touch event?

Some notes: I've tried to build custom accessibility service and it works only for click events, but I need touch events.


Solution

  • how is it done? where this code is located?

    For android 9, the pointer location is enabled in PhoneWindowManager#enablePointerLocation. WindowManagerService provide an internal API registerPointerEventListener for PhoneWindowManager. So It can get all the input events. mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView)

    is there any other place where I can listen for touch event?

    If you can modify the framework and build your custom rom, then you can add the same API to WindowManager, then you app can call this new API to listen for touch event.