0

I have set permissions in the manifest:

<uses-permission android:name="android.permission.REBOOT" />

I call the following lines to reboot device:

Intent intent = new Intent(Intent.ACTION_REBOOT);
sendBroadcast(intent);

Since I have root permissions in the emulator, I am curious why I encounter the following error:

 Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid=963, uid=10046
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

2 Answers2

2

REBOOT permission is only granted to applications having a platform signature or being a system application.

being root probably allows you to run commands as root, but your app still is not. (you could sudo call the shutdown command, though)

njzk2
  • 38,969
  • 7
  • 69
  • 107
  • Do you have any advice to get a custom mod onto an emulator so that my app has the same signing cert as the OS? – Roy Hinkley Sep 17 '12 at 15:13
0

In case anyone is still looking and we indeed are talking about rooted devices, read this answer.

The following code sample should do it (added per request):

Process rebootProcess = null;
try
{
    rebootProcess = Runtime.getRuntime().exec("su -c reboot now");
}
catch (IOException e)
{
    // Handle I/O exception.
}

// We waitFor only if we've got the process.
if (rebootProcess != null)
{
    try
    {
        rebootProcess.waitFor();
    }
    catch (InterruptedException e)
    {
        // Now handle this exception.
    }
}
Community
  • 1
  • 1
Budimir Grom
  • 756
  • 6
  • 12