If you sign your app with platform key, you can get system permissions. such as like below.
<!-- Allows applications to call into AccountAuthenticators.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.ACCOUNT_MANAGER"
android:protectionLevel="signature" />
Or, you can set your UserId to "android.uid.system" meaning the "android" package. because your app is signed with platform key.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.app"
android:sharedUserId="android.uid.system"
The ways introduced here are only available in the android emulator, not for devices sold in the market.
You need to get 2 files in "/build/target/product/security"
in AOSP sources.
- platform.x509.pem
- platform.pk8
You can sign your app with these files or you can generate "jsk" file and use it in Android Studio when you sign it.
Sign your app with 2 files
If you get platform.pk8
, app-debug.apk
, then you need to download the tool called Apk Sign.
You can download signapk.jar
file in this page.
You can sign it with platform key like below.
you have to provide the unsigned apk file "app-unsigned.apk"
. and Signed apk file "app-signed.apk"
will be created.
$ java -jar signapk.jar platform.x509.pem platform.pk8 app-unsigned.apk app-signed.apk
Generate jks file
Type below commands to created a jks file called platform.jks
.
$ openssl pkcs8 -inform DER -nocrypt -in platform.pk8 -out platform.pem
$ openssl pkcs12 -export -in platform.x509.pem -inkey platform.pem -out platform.p12 -password pass:android -name platform
$ keytool -importkeystore -deststorepass android -destkeystore platform.jks -srcstoretype PKCS12 -srcstorepass android -srckeystore
You can register this jks file in Android Studio and use it to sign an app.
In the above commands, key alias, key store password and key password are defined as follows. Of course, you can change these.
key store password: android
key alias: platform
key password: android
Note that this platform key applies to Android Image compiled with AOSP sources. It will not work with Android emulator images provided by Android studio.
References
Related Posts
- How to download and build Android 13, AOSP
- Notification permission request, pop up notification in Android 13
- Resolve `Access blocked: ComponentInfo` error on Android 13
- Fix error "android gradle plugin requires java 11 to run. you are currently using java 1.8."
- Android - Vibration, Vibrator, VibrationEffect example
- How to get phone number in Android
- How to create Bugreports and Logcat with ADB in Android
- Clear application user data with ADB in Android
- How to disable/enable apps with ADB in Android
- How to find PID of a package with adb in Android
- How to grant/revoke permissions with adb in Android
- How to install an apk(app) with adb in Android
- How to kill a process/package from ADB in Android
- How to transfer files using adb push/pull command in Android
- How to capture the screen from adb in Android
- How to uninstall/install system apps from adb in Android
- How to change Settings values from adb in Android
- How to Factory reset with ADB in Android
- How to get logcat from ADB command in Android
- How to capture Heap Dump from app with ADB in Android
- How to force stop an app with adb in Android
- How to start/stop a service from adb in Android
- How to send/broadcast an intent from adb command in Android
- How to start an activity from adb in Android
- How to generate input from adb in Android
- How to check SQLite DB table in Android Studio
- How to get memory info and thread list from adb in Android
- Android - Uri, Scheme and SSP(Scheme Specific Part)
- How to parse a xml file with XmlResourceParser in Android
- Android - Signing an apk with Platfom key
- How to fix "Cleartext HTTP ... not permitted" for Android development
- How to fix "kvm permission denied" for Android Emulator
- Using ADB over Wifi for Android development