0

I develop an Android app for a pcDuino board (based on Android 4.2).

In my app, there is a Watchdog thread; this thread checks its messages received from other threads; if there is any problem (no message received during a specific time by another thread) then this Watchdog thread must restart the board.

My app is a service and this service starts on the board boot (it's done for that).

So, is it possible to reboot this board by software?

anthony
  • 7,653
  • 8
  • 49
  • 101
  • This would be fairly device specific, but you can see if there is a /system/bin/reboot or similar, and if that works when run unprivileged. It's likely on that board you can somehow get root access and create a setuid executable to reboot the board if one doesn't already exist, but do it carefully so as not to introduce a greater security hole. – Chris Stratton Apr 23 '14 at 16:56

1 Answers1

0

I am using the following code from this link. It works as long as you are rooted. As an aside, reboot -p will perform a shutdown if you need this option in your code.

How to shutdown an android mobile programatically?

    Process chperm;
    try {
        chperm = Runtime.getRuntime().exec("su");
        DataOutputStream os =
                new DataOutputStream(chperm.getOutputStream());

        os.writeBytes("reboot\n");
        os.flush();

        chperm.waitFor();

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Community
  • 1
  • 1