How to include prebuilt APK into AOSP with platform privileges

浪尽此生 提交于 2019-12-08 06:36:14

问题


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).

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.

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.

EDIT: 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

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


回答1:


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. Export the app as an unsigned apk from Android Studio
  2. Place the apk in packages/apps/your_app folder
  3. Use the Android.mk like this:

.

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)

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.




回答2:


So you are making a custom Android build, just need to put your app source in the same directory level with other system apps, such as Phone, Messages, Calendar ... then it will eventually be built and generated as a system app, which will stay in /system/app after burning the image to the hardware.



来源:https://stackoverflow.com/questions/34189833/how-to-include-prebuilt-apk-into-aosp-with-platform-privileges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!