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\n");
os.writeBytes("exit\n");
os.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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).
I have found this post
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.