Question

I would like to present my situation first, I am making a kernel tweaker which passes various shell commands using Runtime.getRuntime().exec(...), it does the work well, but the problem is that su permission is asked every time I run a shell command with su in it.

I want the app to ask permission only once and then execute all the commands without asking for su again. Currently my application has about 30 lines with su commands, so my app user has to allow su access 30 times in order to get everything working.

Était-ce utile?

La solution 2

I solved this by, using the same interface for my root calls in the Async Task, initally I was using methods individually as and when required in the Fragment, which caused permissions to be asked again and again. Bu then on changing it to one standard exec method, and using this to make system calls everytime. It fixed the error.

Autres conseils

One approach that may work would be to run a shell with su and pipe your various commands into the stdin of the hopefully resulting root shell process. This would mean su is only used once.

The code for doing so has been covered many times here in the context of people wanting to run commands with arguments that cannot be passed on the su commandline, and so instead have to be piped into the resulting process.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top