Reboot programmatically Android Things

前端 未结 4 1458
忘掉有多难
忘掉有多难 2020-12-19 20:38

I want to use this code in order to reboot my RPI3 running Android Things:

public static void Reboot()
{
    try {
        Process proc = R         


        
4条回答
  •  轮回少年
    2020-12-19 21:09

    /system/bin/reboot binary in DP 4, so as in all the previous dev previews, has world-executable permission, i.e. the following yields

    adb shell ls -l /system/bin | grep reboot
    -rwxr-xr-x 1 root shell   ... reboot
    

    That said, it is yet possible to execute the binary for any user (a.k.a app process in Android) without a need to grab su. Just execute in Java for

    rebooting

    Runtime.getRuntime().exec("reboot");
    

    or for powering off

    Runtime.getRuntime().exec("reboot -p");
    

    No permission's needed in AndroidManifest.xml to run the binary successfully.

    Caution: in case of security model changes in newer OS versions this approach may not work.

提交回复
热议问题