android - 应用程序如何在 Lollipop 上使用系统权限

标签 android permissions android-5.0-lollipop

我想使用 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/

相关文章:

java - fragment 转换 : shared elements

android - 如何在Android Studio上引用库?

linux - 在 Linux 中 - 如何为文件夹设置权限,保存文件以供客户端应用程序调用和下载文件

Android 从通话记录中获取联系人图片

google-apps-script - 强制要求授权 onOpen()(强制弹出)

c# - .NET 中基于角色的授权,使用 PrincipalPermission 和 SecurityAction.Assert

Android XML : android:elevation vs. 应用程序:海拔

android - 原色(有时)变得透明

java - 印地语 kavita 正确对齐/对齐

android - 如何绕过 Java 在 Android Things 上执行 GPIO