First: note that you can only execute shell commands using su (= you can only use shell commands as root, not java code).
Second: Not sure if this applies to all su apps out there, but this is the help message of su
on my phone:
Usage: su [options] [--] [-] [LOGIN] [--] [args...]
Options:
--daemon start the su daemon agent
-c, --command COMMAND pass COMMAND to the invoked shell
-h, --help display this help message and exit
-, -l, --login pretend the shell to be a login shell
-m, -p,
--preserve-environment do not change environment variables
-s, --shell SHELL use SHELL instead of the default /system/bin/sh
-u display the multiuser mode and exit
-v, --version display version number and exit
-V display version code and exit,
this is used almost exclusively by Superuser.apk
This means: you have to run su -c something
(or su -c something - root
, but root
is the default anyway). essentially this is equal to su on most Linux systems, except the daemon-thing, as there is no daemon ahndling su calls on regular linux systems.
If other su commands behave differently (which is possible), it's more secure to open a stream to a shell, execute su
, evaluate it's return code, then proceed to execute other commands, finally execute exit
.
su
is ther right way to get there. You just have to figure out what commands to call - and what commands are avialable. First thing to do: learn how to use the linux shell. Android features a bourne-shell, so you can use bourne-shell specific syntax. – Psychopathsu
has to HAVEsu
ofr course, so yes. I don't know about the emulator, I guess it doesn't feature a su binary unless you inject one. Haven't done anything that required su myself though, so I really don't know. – Psychopath