我需要通过 su 获得 root 访问权限以午餐 TcpDump 二进制文件(我正在研究一种 android 嗅探器).我使用此代码:
I need to get root access via su to lunch a TcpDump binary (I am working on a sort of android sniffer). I use this code :
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("/data/local/tcpdump-arm -c 10 -s 0 -w /data/local/out.txt
");
os.writeBytes("exit
");
os.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
它在有根手机上完美运行,但我想在模拟器中实现这一点.默认情况下,您无法通过模拟器上的 su 获得 root 权限(尽管可以通过 adb shell 获得).
It works perfectly on a rooted phone, but I want to achieve this in the emulator. By default you can't get root privileges via su on the emulator (although it's possible via adb shell).
我找到了这篇帖子
但这对我不起作用.我在某处读到此技巧不适用于 sdk 的当前版本,但没有说明它适用于哪个版本.我尝试使用 sdk 修订版 10,avd 运行 Android 2.1.
But it doesn't work for me. I read somewhere this tip wont work with the curent revision of the sdk, but it doesn't say with which it will work. I try with sdk revision 10 and the avd run Android 2.1.
好的,我自己解决问题:/
Ok, I solve the problem by myself :/
它适用于 sdk 版本 10 和 avd 2.2.我之前遵循的提示的问题是重新安装步骤.这是对我有用的命令列表(摘自 http://forum.xda-developers.com/showthread.php?t=821742):
It works with sdk revision 10 and in an avd 2.2. The problem with the tip I have followed previously is the remount step. Here is the list of commands working for me (extract from http://forum.xda-developers.com/showthread.php?t=821742) :
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
adb install superuser.apk
您可以在此处获取 su 二进制文件和超级用户应用程序:http://forum.xda-developers.com/showthread.php?t=682828
You can get the su binary and the superuser app here : http://forum.xda-developers.com/showthread.php?t=682828
每次启动模拟器时都必须这样做.
You have to do that each time you start the emulator.
这篇关于在安卓模拟器上通过su获取root权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!