为什么我的应用会抛出“android.permission.REBOOT SecurityException"? [英] Why does my app throw an `android.permission.REBOOT SecurityException`?

查看:36
本文介绍了为什么我的应用会抛出“android.permission.REBOOT SecurityException"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个使用 android.os.PowerManager.reboot() 的 Android 应用,并添加了 <uses-permission android:name="android.permission.REBOOT"/> 在我的 AndroidManifest.xml 中.但是,当我运行该应用程序时,它总是抛出以下异常:

I wrote an Android app that uses android.os.PowerManager.reboot(), and I added <uses-permission android:name="android.permission.REBOOT" /> in my AndroidManifest.xml. However, when I run the app, it always throws the following exception:

java.lang.SecurityException: Neither user 10039 nor current process has android.permission.REBOOT. at android.os.Parcel.readException(Parcel.java:1247)
at android.os.Parcel.readException(Parcel.java:1247)
at android.os.Parcel.readException(Parcel.java:1235)
at android.os.IPowerManager$Stub$Proxy.reboot(IPowerManager.java:427)
at android.os.PowerManager.reboot(PowerManager.java:481)
at Test.testPower(Test.java:374)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
at android.os.Parcel.readException(Parcel.java:1247)
at android.os.Parcel.readException(Parcel.java:1235)
at android.os.IPowerManager$Stub$Proxy.reboot(IPowerManager.java:427)
at android.os.PowerManager.reboot(PowerManager.java:481)
at com.fsl.cts.FSLPlaybackTest.testPower(FSLPlaybackTest.java:374)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

是我做错了什么,还是 froyo 重启有问题?

Is the anything I'm doing wrong, or does froyo have some problem with rebooting?

推荐答案

您无法获得此权限.只有系统应用程序和使用用于签名固件的相同密钥签名的应用程序才能获得该权限.

You cannot get this permission. Only system applications and applications signed with the same key that was used to sign the firmware will be able to get that permission.

为什么需要重启?如果你告诉你重启的必要性,那么可能有人可以建议你一个更好的方法来完成同样的事情而无需重启.

Why do you need to reboot? If you tell the necessity of rebooting, then may be someone can suggest you a better way to accomplish the same thing without rebooting.

这篇关于为什么我的应用会抛出“android.permission.REBOOT SecurityException"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆