【发布时间】:2017-05-22 07:40:33
【问题描述】:
我的应用程序的一项功能旨在在单击重启按钮时发送重启广播。
getActivity().sendBroadcast(new Intent(Intent.ACTION_REBOOT));
根据Android参考文档,APK在/system/priv-app目录下的应用可以使用signatureOrSystem权限没有共享平台证书。参考AOSP Privileged vs System app
REBOOT 权限就是其中之一(frameworks/base/core/res/AndroidManifest.xml)。
<!-- @SystemApi Required to be able to reboot the device.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.REBOOT"
android:label="@string/permlab_reboot"
android:description="@string/permdesc_reboot"
android:protectionLevel="signature|system" />
所以我用自己的证书签署了我的 APK,然后将我的 APK 推送到 /system/priv-app 并确保 APK 文件与目录中的其他 APK 具有相同的读写访问权限。
但是,它无法发送重启广播,并出现以下错误,
ActivityManager: Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid=2801, uid=10016
我用dumpsys检查了系统状态,发现10016的user-id被授予了REBOOT权限em>。
SharedUser [com.example] (10b8d16d):
userId=10016 gids=[1028, 1015, 1007, 3003]
授予权限:
android.permission.重启
顺便说一句,我正在使用Android5.1.1的pad进行测试。
【问题讨论】:
标签: android permissions