1

I am trying to reboot (through code) the phone at some point. In order to do that I do this:


    Intent i = new Intent(android.content.Intent.ACTION_REBOOT);
    i.putExtra("nowait", 1);
    i.putExtra("interval", 1);
    i.putExtra("window", 0);
    this.sendBroadcast(i);

The problem is that, even if I have in the manifest this line:

uses-permission android:name="android.permission.REBOOT" (with the delimiters).

When trying to execute it, it gives me the next error:


Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid= uid= gids= 

I read that you should create an .apk and sign it with SignApk, but I created the key/certificate with openssl and signed with those and this didn't run either, I continue getting exactly the same error.

Do you have any clue about how to solve this and being able to reboot the phone? I do really need to do it.

Nicolas Kaiser
  • 1,628
  • 2
  • 14
  • 26
Dhay
  • 11
  • 1
  • 1
  • 2

5 Answers5

3
public static final String ACTION_REBOOT

Since: API Level 1
Broadcast Action: Have the device reboot. **This is only for use by system code.**
**This is a protected intent that can only be sent by the system.**

Constant Value: "android.intent.action.REBOOT"

http://developer.android.com/reference/android/content/Intent.html#ACTION_REBOOT

So, unless you go off band and rely on having SuperUser you wont be able to force a reboot.

Dr.J
  • 1,220
  • 8
  • 9
2

Why does my app throw an `android.permission.REBOOT SecurityException`?

From what I understand, the permission REBOOT is only available to apps signed by the key that signed the hardware, ie system apps

Community
  • 1
  • 1
Michael Allen
  • 5,712
  • 3
  • 38
  • 63
1

For rebooting Android device through code u need "android.intent.action.REBOOT" permission which is granted only to the system applications or to the application which are signed with the same key as that of system applications. Apart from this one also has to add a tag in Android Manifest android:sharedUserId="android.uid.system". So as to insure application shares the same uid as that of system application.

The key used for signing system app. is unique to device manufacturer and it cant be duplicated.

Rohit
  • 593
  • 2
  • 8
0

Android applications are not allowed to send android.content.Intent.ACTION_REBOOT

See the note here http://www.google.com/codesearch/p?hl=en#5oTG8Wvrixk/trunk/android-x86/frameworks/base/core/java/android/content/Intent.java&l=1510

/**
 * Broadcast Action: Have the device reboot.  This is only for use by
 * system code.
 */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_REBOOT =
        "android.intent.action.REBOOT";
Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
0

http://www.krvarma.com/posts/android/security-permissions-in-android/

Permissions are granted to the application by package installer while installing. But not all the permissions will be granted to the system. There are some system permission which will not be granted to the user applications, but only to the system applications. Following are some of the permissions that may NOT be granted to the user application.

To get these permissions, the application must be signed with the key which used to sign the platform. This may be different for manufacturers. So it practically not possible to get these permissions granted to a user application.

Community
  • 1
  • 1
Vincent Mimoun-Prat
  • 28,208
  • 16
  • 81
  • 124