mercredi 10 février 2021

simulating touch events as system app via injectInputEvent reflection

I am trying to simulate touch events from an android service via injectInputEvent reflection

I am using simulateTouch in TouchSimulator from TouchMapper

public void simulateTouch(int mapId,int originalAction,int x,int y) 
    throws InvocationTargetException, IllegalAccessException {

    ....

    eventInput.injectTouch(
        unmaskedAction,
        pointerPropertieses.toArray(
            new MotionEvent.PointerProperties[pointerPropertieses.size()]
        ),
        pointerCoordses.toArray(new MotionEvent.PointerCoords[pointerCoordses.size()])
    );
}

Not like TouchMapper , i am trying do so as system app but keep getting:

java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission

I added to the manifest:

<manifest 
    android:sharedUserId = "android.uid.system"
    ...>

<uses-permission android:name="android.permission.INJECT_EVENTS"
        tools:ignore="ProtectedPermissions"/>

And i followed this tutorial to make it as system app

When i type

adb shell pm list packages -s

I can indeed see my package as a system application

What am i missing?





Aucun commentaire:

Enregistrer un commentaire