0

Since API level 8 PowerManager has contained a reboot() method.

I've added the required permission to my manifest, acquired the PowerManager object and call

pm.reboot();

This results in a force close with this stack trace

01-04 16:58:35.847: ERROR/AndroidRuntime(2945): java.lang.SecurityException: Neither user 10060 nor current process has android.permission.REBOOT.

Does anyone know if this PowerManager.reboot() method is supposed to be available to applications? Since it is in the documentation I kind of guessed that it was ok to use.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156

1 Answers1

3

Does anyone know if this PowerManager.reboot() method is supposed to be available to applications?

SDK applications that are installed to the system partition as part of firmware can hold the REBOOT permission. Ordinary SDK applications cannot.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Is there any handy place to find specifically which parts of which APIs are available for standard applications? The developer docs do not mention that it is system only on either the method, or the permission. Such a list would really help avoid some of the trial and error involved in exploring some APIs – FoamyGuy Jan 05 '12 at 01:15
  • 3
    @Tim: The documentation is usually pretty good about denoting what permissions are needed to perform certain operations. The documentation does not describe anywhere what is required to hold the permission. To do that, you need to examine `frameworks/base/core/res/AndroidManifest.xml` in the source code. Each permission is listed there with a `android:protectionLevel` attribute. `signature` means the app must be signed with the firmware's signing key. `signatureOrSystem` also allows the app to be normally signed but reside in `/mnt/system`. Any app can hold `normal` and `dangerous` ones. – CommonsWare Jan 05 '12 at 12:33
  • 1
    @Tim: You have a very generous definition of "perfect". :-) – CommonsWare Jan 05 '12 at 14:18
  • 1
    lol Ok, perhaps not perfect. But better than guess and check. – FoamyGuy Jan 05 '12 at 14:26