First download the keytool tool address
Take the windows system as an example.
1. First download the keytool-importkeypair tool. After downloading I put it on the desktop.
2. Since this tool needs to run in Linux but I don't have that environment so use MinGW instead.
Open msys.bat in the D:\MinGW\msys\1.0 directory and enter the environment (similar to cmd in win).
Then enter the command to enter the key tool importkeypair directory.
Note: The file directory in this command uses a backslash instead of a slash. If you use a slash you will not be able to enter the directory in the MinGW environment. There will be no such files or directories.
As shown in the figure below you entered keytool - importkeypair-host.
Then copy platform.x509.pem and platform.pk8 to keytool-importkeypair-master (platform.x509.pem and platform.pk8 are the files in the security folder when compiling the system need to be provided by the manufacturer)
At this point the preparation is complete and the keystore file can be generated.
Execute commands in MinGW.
-k indicates the name of the keystore file to be generated here named platform.keystore
-p indicates the password of the keystore to be generated here is android
-pk8 indicates the platform.pk8 file to be imported
-cert indicates the platform.x509.pem to be imported
-alias means to give the generated platform.keystore an alias which is named platform
Then the platform.keystore file is generated.
This file is the signature file required by android studio and will be configured later in build.gradle.
I put the platform.keystore file in the C:\ test directory. So the storeFile file is C:\ test \ platform.keystore.
Then you need to configure buildTypes in the project structure so that the app is installed with the signature after running the app.
Set the signature of debug in buildTypes to debug and the signature of release to release.
This way you don't have to compile the APK every time you use it and then use signapk.jar to generate the APK with system signature.
Finally remember to add android:sharedUserId = "android.uid.system" to the corresponding location in the AndroidManifest.xml file.
This is an APK with system level permissions.