ColoradoIcculus
ColoradoIcculus

Reputation: 71

How to include prebuilt APK into AOSP with platform privileges

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.

Upvotes: 1

Views: 6528

Answers (2)

Sava Mikalački
Sava Mikalački

Reputation: 91

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.

Upvotes: 5

Pete Houston
Pete Houston

Reputation: 15069

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.

Upvotes: 1

Related Questions