I have an Android TV box (4.4.2, armv7), and I can login the device as root by ADB (local network). What I want to do is to give certain apps root permission. How can I do it?
You don't give certain apps root permission, but certain apps ask for root permission by executing
su binary. It's the developer of the app who decides if the app would perform some tasks with root privileges or not. In order to let apps request root privileges, you need to root your device using e.g. Magisk, SuperSU etc. (whatever works on your device).
When you get root privileges on
adb (e.g. by executing
adb root or
adb shell su) it runs
adbd process on device as root (UID
0) user. So all commands which you run through
adb have root privileges. To grant root access to apps you need a special
su binary which is not shipped with Android.
su binary (like on any UNIX-like OS) makes a transition to UID
0 by making
setuid syscall to kernel. This is not possible on Android due to certain restrictions. The special
su binary (the one provided by rooting solutions like Magisk) connects to a background daemon to get a root shell for the requesting app, where the app can execute commands with root privileges. However the app itself is still running with its own UID (assigned at the time of installation).
For more details see: