Answers for this question should be ideally non-rooted.
I am looking at re-writing one of the adb tools, sendevent.c I have found this file online and am confident that i could adapt it for my purposes.
I presume i could push my new file to the device, but what i am not sure about is what directories i can place this file so that it can execute, from my research i have found a few directories but get permission errors when trying to push to them.
There is another question that was asked that related allot to what i want to do. but how to add the new tool was not explained for reference it is here.
edit
Or if anyone knows a way of replicating a complex drag without sacrificing accuracy, on a non-rooted device?
My original idea was to remove every other set of co-ordinate events which works, but is not as accurate and timings need allot of fine-tuning.
compiling note
for anyone else interested in how to do this.
I have just compiled and ran a hello world test, the instructions i found were on this question:
here is a copy of the answer if the link becomes invalid (my test modified the test-libstdc++ sample as it is more lightweight):
Last tested with NDK r8e on Linux and Nexus 4 with adb from SDK Platform-Tools Rev 18 on Windows 7 (latest as of 2013-07-25) without root access.
- Go to $NDK_ROOT (The topmost folder of NDK zip when unzipped).
- Copy $NDK_ROOT/samples/hello-jni directory as $NDK_ROOT/sources/hello-world.
- Go to $NDK_ROOT/sources/hello-world.
- Edit AndroidManifest.xml to give the application an appropriate name (This is optional).
- Go to $NDK_ROOT/sources/hello-world/jni. This is where the source code is.
- Edit hello-jni.c, remove all the code, and put in your hello world
code. Mine is:
include
int main( int argc, char* argv[]) { printf("Hello, World!"); return 0; } - Edit Android.mk and change the line include $(BUILD_SHARED_LIBRARY) to include $(BUILD_EXECUTABLE). You can also change the LOCAL_MODULE line to the name you want for your executable(default is hello-jni)
- Go back to $NDK_ROOT/sources/hello-world
- Run ../../ndk-build to create the executable.
- Copy it from $NDK_ROOT/sources/hello-jni/libs/armeabi/hello-jni to /data/local/tmp on the Android device and change it's permissions to 755 (rwxr-xr-x). If you changed the LOCAL_MODULE line in $NDK_ROOT/sources/hello-world/jni/Android.mk, the executable name will be the new value of LOCAL_MODULE instead of hello-jni. (All this is done via adb from the Android SDK.)
- Execute the binary with full path as /data/local/tmp/hello-jni, or whatever you named it to.
And you're done( and free to start on the documentation in $NDK_ROOT/docs to get a better idea of what to do).
The way I solved it in the question you referenced was by using
adb push local_path remote_path
and the remote directory I used is/data/local/tmp/
which requires no root permissions. To push a thing you just need to compile it locally and send push it. You can then run in on the device usingadb shell absolute_path_to_script
To recap. If you want to make a custom script from a android/adb C source, you need to:
my_script
)chmod a+x my_script
adb push my_script /data/local/tmp/my_script
adb shell /data/local/tmp/my_script
Now to answer your other question about dragging, I ended up making my own custom sendevent script that takes a local file (from the android device), reads events line by line and sends them to the driver.
Here's the script http://pastebin.com/LWWiNA6U
It takes 3 arguments,
file_input
,file_output
- this is specific to every device, you need to check and see where do you need to write the raw binary data to emulate touch events. For the devices I used:/dev/input/event5
(for the HTC One M7) and/dev/input/event2
(for the Galaxy Note 8)sleep_time
- delay between every touch event being sent to the driverHope it helps
EDIT: Oh and btw, this is example input. It's standard converted from
getevent
as far as I remember