On XDA I found a post discussing how to PIN an app to not get killed by OOM. As your question indicates your device is rooted, this could be useful for you. The principle described there can be applied to your case as well by simply changing the
oom_adj value specified (the
-17 would permanently PIN it, highest prio -- so use a larger value to "weaken" that).
The script snipped posted there looks like this:
echo "-17" > /proc/$PPID/oom_adj
An anonymous user noted you could also set this file to read-only permissions to prevent Android from updating it, adding
chmod 444 /proc/$PPID/oom_adj to the above script (the proposed 444 means nothing but read permission, but doesn't affect the system's ability to remove the file when the process ends). I have not verified that, but this could in fact save you from looping/repeatedly running the script, making the set value permanent for as long as the process lives.
As said, replace the
-17 by your chosen value. Also replace the app's package name (
com.estrongs.android.safer) by the package name of your target app. You can also lower the
sleep value, or even ommit the sleep at all.
Now you need a way to auto-execute this as soon as your app is running. For this part, you could e.g. use Tasker: Context would be "app running" (and your app selected), and the task "run shell", with above script as parameter. Then, as soon as you start your app (and it comes to foreground), Tasker would execute the script -- and the
oom_adj value should be applied.