添加自定义工具到Android ADB壳 [英] Adding a custom tool to the android adb shell

查看:137
本文介绍了添加自定义工具到Android ADB壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解答这个问题应该是理想的无根。

Answers for this question should be ideally non-rooted.

我在看重写的亚行工具之一,sendevent.c 我发现这个文件在线和有信心,我能够适应它为我的目的。

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.

我presume我可以把我的新文件到设备上,但什么我不知道的是什么目录,我可以把这个文件,以便它可以执行,从我的研究,我已经找到了几个目录,但得到当试图权限错误推给他们。

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.

或者,如果有谁知道复制一个复杂的阻力不牺牲精度,一个无根的设备上的一种方式?

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.

对于任何人感兴趣的是如何做到这一点。

for anyone else interested in how to do this.

我刚刚编译并运行一个Hello World的测试,我发现指示是在这个<一href="http://stackoverflow.com/questions/9868309/how-can-i-run-c-binary-executable-file-in-android-from-android-shell">question:

I have just compiled and ran a hello world test, the instructions i found were on this question:

下面是答案的一个副本,如果链路失效(我的测试修改了测试的libstdc ++示例,因为它是更轻巧):

here is a copy of the answer if the link becomes invalid (my test modified the test-libstdc++ sample as it is more lightweight):

去年(最新为2013年7月25日)没有root访问权限的Windows 7测试与NDK R8E在Linux和Nexus 4与SDK平台的工具亚行启18。

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.

  1. 转到$ NDK_ROOT(NDK ZIP解压缩时的最顶层文件夹)。
  2. 复制$ NDK_ROOT /样本/ HELLO-JNI目录 $ NDK_ROOT /来源/你好世界。
  3. 转到$ NDK_ROOT /来源/你好世界。
  4. 编辑AndroidManifest.xml中给应用程序一个合适的名称 (这是可选)。
  5. 转到$ NDK_ROOT /来源/你好世界/ JNI。这是其中源 code为。
  6. 编辑HELLO-jni.c,删除所有code,并把你的Hello World code。我的是: #包括 INT主(INT ARGC,字符* argv的[]) {     的printf(你好,世界!);     返回0; }
  7. 编辑Android.mk和更改线路包括$(BUILD_SHARED_LIBRARY) 包括$(BUILD_EXECUTABLE)。您还可以更改LOCAL_MODULE 行,你想为你的可执行文件名(默认是HELLO-JNI)
  8. 返回$ NDK_ROOT /来源/你好世界
  9. 运行../../ndk-build创建可执行文件。
  10. 从$ NDK_ROOT /源将其复制/ HELLO-JNI /库/ armeabi / HELLO-JNI来  /数据/本地/在Android设备上TMP和改变它的权限  为755(rwxr-XR-X)。如果您在更改了LOCAL_MODULE线  $ NDK_ROOT /来源/你好世界/ JNI / Android.mk,可执行文件的名称  将LOCAL_MODULE而不是HELLO-JNI的新的价值。 (所有  这是通过从Android SDK亚行完成的。)
  11. 全路径执行二进制文件为/数据/本地的/ tmp / HELLO-JNI,或  无论你把它命名为。
  1. Go to $NDK_ROOT (The topmost folder of NDK zip when unzipped).
  2. Copy $NDK_ROOT/samples/hello-jni directory as $NDK_ROOT/sources/hello-world.
  3. Go to $NDK_ROOT/sources/hello-world.
  4. Edit AndroidManifest.xml to give the application an appropriate name (This is optional).
  5. Go to $NDK_ROOT/sources/hello-world/jni. This is where the source code is.
  6. 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; }
  7. 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)
  8. Go back to $NDK_ROOT/sources/hello-world
  9. Run ../../ndk-build to create the executable.
  10. 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.)
  11. Execute the binary with full path as /data/local/tmp/hello-jni, or whatever you named it to.

和你做(免费开始在$ NDK_ROOT /文档的文档,以获得更好的主意要做什么)。

And you're done( and free to start on the documentation in $NDK_ROOT/docs to get a better idea of what to do).

推荐答案

我在你提到的问题,解决它的方法是使用亚行推LOCAL_PATH远程路径键,遥控器目录我用的是 /数据/本地的/ tmp / 这不需要root权限。 要推你只需要在本地编译它,并发送推的事情。使用的设备然后,您可以运行在亚行外壳absolute_path_to_script

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 using adb shell absolute_path_to_script

要回顾一下。如果你想从一个机器人/亚行C源代码创建自定义脚本,您需要:

To recap. If you want to make a custom script from a android/adb C source, you need to:

  • 在编译它(比方说,你得到 my_script
  • 请不要忘记,使其与搭配chmod一个可执行+ X my_script
  • 将其推送到设备亚行推my_script /数据/本地的/ tmp / my_script
  • 运行它形成设备亚行外壳/数据/本地的/ tmp / my_script
  • compile it (lets say you get my_script)
  • don't forget to make it an executable with chmod a+x my_script
  • push it to the device adb push my_script /data/local/tmp/my_script
  • run it form the device adb shell /data/local/tmp/my_script

现在来回答您的其他问题有关拖着,我最终作出自己的自定义的SendEvent脚本,需要一个本地文件(在Android设备),读取事件一行行,并将它们发送到驱动程序。

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.

下面的脚本 http://pastebin.com/LWWiNA6U

这需要3个参数,

  • file_input
  • file_output - 这是具体到每一个设备,你需要检查,看看你需要编写原始二进制数据来模拟触摸事件。对于设备我用:的/ dev /输入/ event5 (为HTC一M7)和的/ dev /输入/ EVENT2 (银河注8)
  • SLEEP_TIME - 每一个触摸事件之间的延迟发送到驱动程序
  • the file_input,
  • the 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)
  • and the sleep_time - delay between every touch event being sent to the driver

希望它可以帮助

编辑:哦和顺便说一句,这就是例子输入。这是标准的转换,从 getevent 据我记得

Oh and btw, this is example input. It's standard converted from getevent as far as I remember

0003 0039 4a
0003 0035 1cc
0003 0036 3a2
0000 0000 00000000

0003 0035 250
0003 0036 426
0000 0000 00000000

0003 0035 250
0003 0036 4aa
0000 0000 00000000

0003 0035 149
0003 0036 3a2
0000 0000 00000000

0003 0035 c5
0003 0036 3a2
0000 0000 00000000

0003 0039 ffffffff
0000 0000 00000000

这篇关于添加自定义工具到Android ADB壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆