Neither user 10071 nor current process has android.permission.DEVICE_POWER.
在自己的activity里写了如下代码
try {
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
if (power != null) {
System.out.println("brightness = " + brightness); --------------- brightness 数值也是对的
power.setBacklightBrightness(brightness); ------------ 这里报错
}
} catch (RemoteException doe) {
}
报错提示
09-08 03:06:30.630: ERROR/AndroidRuntime(13726): java.lang.SecurityException: Neither user 10071 nor current process has android.permission.DEVICE_POWER.
但是我已经再androidminifest 里 定义了
<uses-permission android:name="android.permission.DEVICE_POWER" />
等高人解答~~
不过已经找到问题了。。原来是没有签名的问题
手动签名之后 就可以了,
终于知道了,搞死人了啊,哈哈
在
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mokoid.LedTest"
android:sharedUserId="android.uid.system">
其中后面一句是一定要加的
第二:
在Android.mk
中通过证书来声明权限。
LOCAL_CERTIFICATE := platform
需要和manifest中的android:sharedUserId="android.uid.system" 对应起来。
platform 权限问题,最好运行在自己编译的系统上,才可以有次特权。
<!-- Allows low-level access to power management -->
<permission android:name="android.permission.DEVICE_POWER"
android:label="@string/permlab_devicePower"
android:description="@string/permdesc_devicePower"
android:protectionLevel="signature" />
如果某个权限(permission)的protectionLevel是signature,则这个权限就只能授予那些跟该权限所在的包拥有同一个数字证书的程序。
A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission.