问题
I've installed Android Things DP4 on a Raspberry Pi 3. Now I need to execute a ifconfig as root in order to set a static IP. Tried:
-installed an Android app in the /system/app
folder with world executable perms
-installed an Android app in the /system/private-app
folder with world executable perms
-created init.d
with a executable shell script file (folder didn't exist before)
All this failed miserably...
回答1:
Android (and therefore Android Things) does not allow applications to run as the root user for security reasons. If you need this feature for your production apps, feel free to add any comments regarding your use case to the existing feature request in place for this.
Regarding the things you already tried:
-installed an Android app in the /system/app folder with world executable perms
-installed an Android app in the /system/private-app folder with world executable perms
Apps installed in Android's /system
partition are allowed privileged access to various Android-level permissions, but this does not affect their Linux UIDs.
-created init.d with a executable shell script file (folder didn't exist before)
Android does not use the same init structure as other Linux distributions. Init instructions are located in various init.rc
files on the root file system. In general, again for security reasons, even the processes spawned from init are not allowed to run as root and are given isolated SE contexts to run in.
来源:https://stackoverflow.com/questions/45065766/how-can-i-run-a-shell-script-on-android-things-device-at-boot-with-root-permissi