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

查看:27
本文介绍了如何将预构建的 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. 从 Android Studio 将应用导出为未签名的 apk
  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天全站免登陆