Hello,
I compiled Android Automotive OS 10 with userdebug build option for NXP iMX8QM.
I need to give root privileges by running the "su" command from within the APK that I developed with Android Studio.
public static void sudo(String... strings) {
try {
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
for (String s : strings) {
outputStream.writeBytes(s + "\n");
outputStream.flush();
}
outputStream.writeBytes("exit\n");
outputStream.flush();
try {
su.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
I am using the code block below to do this. But I get the error "W/System.err: java.io.IOException: Cannot run program "su": error=13, Permission denied".
What should I do in this situation, could you please help me this issue?
Best regards,
Efecan