在 android 模拟器中授予应用程序系统权限 [英] grant system permissions to an app in the android emulator

查看:54
本文介绍了在 android 模拟器中授予应用程序系统权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,该应用程序将作为系统应用程序捆绑在 Android 设备上.制造商是将设备交付给我们的一种方式,因此同时我想在模拟器中授予我的应用程序系统级别权限,以便我可以开发自动更新功能,该功能将在没有任何交互的情况下静默安装 APK来自用户.根据我的阅读,我的理解是,能够在 android 上进行静默安装的唯一方法是您的应用程序是否使用与操作系统相同的证书进行签名.那么我如何在模拟器中模拟这个?

I am building an app that will be bundled on an android device as a system app. The manufacturer is a ways out on delivering the device to us, so in the meantime I'd like to grant my app system level permissions in the emulator so I can work on an auto update feature that will do silent installs of APKs without any interactions from the user. From what I've read, its my understanding that the only way to be able to do silent installs on android is if your app is signed with the same cert as the OS. So how can I simulate this in the emulator?

推荐答案

如果你想要一个signatureOrSystem权限,只需要放在系统镜像上即可;您不需要使用任何特殊证书进行签名.您可以一次性执行此操作(直到您退出模拟器),如下所示:

If you want a signatureOrSystem permission, you just need to be placed on the system image; you don't need to be signed with any special cert. You can do this as a one-off (until you exit the emulator) like this:

> adb root
> adb remount
> adb push /path/to/My.apk /system/app/My.apk

完成后,您可以使用正常过程在数据分区上安装更多更新(adb install -r/path/to/My.apk",这是从 Eclipse 运行时开发人员工具所做的工作).以这种方式安装时,应用程序会保留它从系统映像上的原始版本请求的任何签名或系统权限,但无法获得任何新的此类权限.

Once you have done that, you can use the normal process to install further updates on the data partition ("adb install -r /path/to/My.apk" which is what the developer tools do when you run from Eclipse). When installing this way, the app retains any signatureOrSystem permissions it had requested from the original version on the system image, but can not gain any new such permissions.

如果您需要纯签名权限,您需要使用与声明这些权限相同的证书(通常是核心框架,但媒体系统是一个单独的证书等)为您的应用程序签名.如果您请求签名权限,您不需要安装在系统映像上,您可以将其安装为普通应用程序,它仍然可以因为签名而获得权限.

If you need pure signature permissions, you need to sign your app with the same cert as whatever is declaring those permissions (typically the core framework, but the media system is a separate cert etc). If you are requesting signature permissions you don't need to be installed on the system image, you can just install it as a normal app and it can still get the permissions because of the signing.

这篇关于在 android 模拟器中授予应用程序系统权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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