android linux shell

Need root to execute shell command “input keyevent ” through an app at runtime?

I’m trying to execute the adb shell command input keyevent 5 to answer a call through my app at run time.

If I do this:

Runtime.getRuntime().exec("input keyevent 5");

It doesn’t seem to execute (nothing is happening). But when I do this:

Runtime.getRuntime().exec(new String[] {"su", "-c", "input keyevent 5"});

The expected simulated tap on the answer button on-screen happens. Which is good.

However one problem is that on some devices which are rooted using Superuser, the command takes a while to get the superuser permission. It works fine with devices which have Chainfire’s SuperSU su binary.

My question is:
Is it possible to execute this command without root through Java code at runtime?

Thanks in advance!