I am developing a Java and C app for Android which requires root uid to enable a major part of its functionality. Thus, I rooted an Android emulator using SuperSu and called Process p = Runtime.getRuntime().exec("su") in my app's Java code on a separate thread to open a new process running as root.
However, it seems that I can only run terminal commands within this process as per https://su.chainfire.eu/#how-call, which is not what I want it to do. Instead, I want the process to run a portion of my app's Java and C code.
Are there any ways to run a portion of my app as root?
NB: The code I want to run on that Process involves opening a raw socket, crafting and sending packets.