Something related to the System Application
You might wonder how to deploy your App as a system application. There are two cases we can talk about. First one, on a rooted device, you can simply put your App into either /system/app or /system/priv-app by using this way:
1 | $adb root |
This is an easier way to make your application access @systemApi without pain. What about the second case? We can download the AOSP source code, put our application into the build process, and make the App a system application when building the AOSP source.
Where to put your App
You can put your App in these two folders:
- your_aosp_project_folder/packages/apps/your_app_folder
- your_aosp_project_folder/vendor/your_project/packages/apps/your_app_folder
For the last folder, you have to create that yourself by using:
1 | mkdir -p vendor/your_project/packages/apps/your_app_folder. |
You can simply put a prebuilt Apk or the entire project source code into the AOSP build. I will simply go over the prebuilt Apk way, but the concepts are the same. Here is the example of preparing the Android.mk or Android.bp for the AOSP build.
1 | LOCAL_PATH := $(call my-dir) |
The key and Keystore
Please note that if you want to make your application a system App, you will need to add android.uid.system
to your AndroidManifest.xml. This setting will make your application share the same system uid with other system applications. And by using this way, you will need to provide the platform key to sign your application:
Manually sign
1 | java -Djava.library.path=out/host/linux-x86/lib64 -jar out/host/linux-x86/framework/signapk.jar build/target/product/security/platform.x509.pem build/target/product/security/platform.pk8 your_debug_app.apk your_debug_app_signed.apk |
Sign your app by using Android Studio
1 | keytool-importkeypair -k ~/.android/platform.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform |
After creating the Keystore file, you can use this Keystore file in your Android Studio and set up the SignConfig to sign your application.
signingConfigs {
release {
storeFile file("your.keystore")
storePassword 'your_store_pwd'
keyAlias 'your_key_alias'
keyPassword 'your_key_pwd'
}
}