如何使用平台特权将预构建的APK包含到AOSP中 [英] How to include prebuilt APK into AOSP with platform privileges

查看:92
本文介绍了如何使用平台特权将预构建的APK包含到AOSP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为自定义硬件构建AOSP版本,我想使用一些root权限(INJECT_EVENTS,UPDATE_DEVICE_STATS,CONNECTIVITY_INTERNAL).

I'm building a version of the AOSP for custom hardware and I'd like to use some root permissions (INJECT_EVENTS, UPDATE_DEVICE_STATS, CONNECTIVITY_INTERNAL).

对于转速控制,最好使用基于APK的发行版.因此,我想在构建中包含APK,而不是每次都构建源.该程序已成功包含在内,但系统特权被忽略.

For rev control, it would be ideal to use an APK-based distribution. As such, I'd like to include the APK in the build instead of building the source every time. The program gets successfully included, but the system privileges are ignored.

有没有办法包含此程序,使其获得必要的特权?我希望Android.mk中的LOCAL_CERTIFICATE,LOCAL_MODULE_CLASS或BUILD_PREBUILT可以实现某种连接.

Is there a way to include this program such that it receives the necessary privileges? I'm hoping there is some connection that either LOCAL_CERTIFICATE, LOCAL_MODULE_CLASS or BUILD_PREBUILT in Android.mk can achieve.

解决方案是首先确定用于构建Android系统的签名.它们存在于AOSP中的/build/target/product/security/platform中.获得这些签名后,便可以创建一个新的密钥库.然后,我使用此处找到的工具keytool-importkeypair将密钥导入到新的密钥库中.

The solution was to first determine the signatures that were being used to build the Android system. They existed in /build/target/product/security/platform inside the AOSP. Once I had these signatures, I could then create a new keystore. I then imported the keys into the new keystore using the tool keytool-importkeypair found here.

https://github.com/getfatday/keytool-importkeypair

完成后,我可以选择Android Studio中的密钥库,并正确安装和调试具有必要权限的程序.

Once that was done, I could select the keystore inside Android Studio and correctly install and debug the program that had the necessary permissions.

推荐答案

这里是我拥有的:我的应用程序是我使用Android Studio开发的系统应用程序.当我要将其包含在ROM中时,请按以下步骤操作:

Here is what I have: my application is a system application which I develop using Android Studio. When I want to include it in my ROM, here are the steps:

  1. 将应用作为未签名的APK从Android Studio中导出
  2. 将apk放在packages/apps/your_app文件夹中
  3. 像这样使用Android.mk:

.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := your_app
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true // if required
LOCAL_MODULE_CLASS := APPS
LOCAL_SRC_FILES := app-release-unsigned.apk
include $(BUILD_PREBUILT)

除此之外,您还可以从平台证书生成密钥库文件.您可以用谷歌搜索它,它涉及几个shell命令(我使用相同的方法),然后可以使用适当的签名配置从Android Studio在设备上运行您的应用.

In addition to this, you can also generate keystore file from the platform certificates. You can google that, it involves several shell commands (I use the same approach) and then you can run your app on your device from Android Studio with appropriate signing configuration.

这篇关于如何使用平台特权将预构建的APK包含到AOSP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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