In Android, the permission level is divided into
["Normal" | "Dangerous" | "Signature" | "Signatureorsystem"]
Normal, Dangerous is the general apk is declared in the mainifest can be obtained
Signature must have a system-level signature to obtain
Signatureorsystem has a system level signature or has system privileges
Taking Set_preferred_applications as an example
Sign the APK with signapk
Addpreferredactivity requires permission Android.permission.SET_PREFERRED_APPLICATIONS (Permission level is "signature")
Using this permission requires the signapk to be signed, and the required tools
In the source package
1).. \out\host\linux-x86\framework\signapk.jar
2).. \build\target\product\security\platform.pk8
3).. \build\target\product\security\platform.x509.pk8
Put the above 3 files and the apk that needs to be signed in the same directory
CMD-Java-jar signapk.jarplatform.x509.pem platform.pk8 launcherdemo.apk launcher_sign.apk
This permission is required for applications that have system permissions, so you need to compile the app using the source code
When you are done, you can install the app using the normal install method, and you can use Zipalign to optimize the APK
Zipalign Directory Android-sdk\tools\zipalign.exe
L OPTIMIZE the Alignment apk
CMD->zipalign-v 4 old.apk new.apk
L Verify Alignment
CMD->zipalign-c-V 4 new.apk
The above output verification succesful indicates an optimization alignment success
Source code compilation APK shared System UID
This method does not need to declare permissions set_preferred_applications
1) Add in the Mainfest file
Android:shareduserid= "Android.uid.system"
2) added in Android.mk file
Local_certificate: = Platform
After the compilation is complete, install the app using push mode
ANDROID.MK:
#Copyright 2007-2008 the Android Open Source projectlocal_path:=$ (call My-dir) include$ (clear_vars) local_src_files:= $ ( Call All-java-files-under, SRC) local_package_name:= launcherdemolocal_certificate:= platforminclude$ (BUILD_PACKAGE # Use thefolloing include-to-make we test apk.include$ (call all-makefiles-under,$ (Local_path))