我想使用 android.permission.DEVICE_POWER 权限,它需要系统或签名,我搜索了很多,似乎/system/priv-app 中的 apk 可能有权限,但我在 Nexus 4 5.0 上失败了.2.
我把 apk 放到/system/priv-app,但是 logcat 显示
未授予包 xxxx 的 android.permission.DEVICE_POWER 权限
我做错了什么吗?还是有其他方式获取权限?
最佳答案
请参阅 documentation 中有关 android:protectionLevel
的文档.
如果应用程序包含在 /system/priv-app
文件夹中,则安装时只会分配保护级别为 signatureOrSystem 的权限。 android.permission.DEVICE_POWER
不是其中之一。引用 list 定义 in the source :
摘录如下:
<!-- Allows low-level access to power management.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.DEVICE_POWER"
android:label="@string/permlab_devicePower"
android:description="@string/permdesc_devicePower"
android:protectionLevel="signature" />
因此应用程序需要为 signed with the platform key ROM/system/AOSP-build 以获得此权限。
关于android - 应用程序如何在 Lollipop 上使用系统权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28846637/