Android apk How to get system permissions

Source: Internet
Author: User

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))


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.