Insufficient Android Permissions

Source: Internet
Author: User

Many applications may encounter insufficient permissions when using runtime.exe C or when creating a service. The following solutions can be used:

Androidmanifest. xml:

<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. mokoid. ledtest"
Android: shareduserid = "android. uid. System">

It turns out that servicemanager will check the application's permissions. The Android system will perform permission management based on the user ID. The following code is available in frmeworks/base/cmds/servicemanager/service_manager.c:

Int svc_can_register (unsigned uid, uint16_t * name)

Modify the allowed array.

If a problem occurs at the application layer, two files related to permission management are required: androidmanifest. xml and Android. mk.

Androidmanifest. xml
Declare permissions:
<Uses-Permission Android: Name = "android. Permission. access_surface_flinger"/>
<Uses-Permission Android: Name = "android. Permission. Vibrate"/>

Declare User Group
<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. Android. inputmethod. Pinyin"
Android: shareduserid = "android. uid. System">

The permission is declared through the Certificate in Android. mk.
Local_certificate: = platform must match Android: shareduserid = "android. uid. System" in manifest.
For the platform permission issue, it is best to run it on a self-compiled system to have the privilege. If the permission of the application is modified. Because old applications are associated with data, you need to re-download the application and try to restore the factory settings or delete all data associated with the application through the Application Manager. System uid = 1000 is a special permission process.

Aid_system is defined as 1000, that is, the UID of the system server. From the code above, servicemanager checks the UID of the application. When the UID does not comply with the rules, it cannot execute do_add_service (). That is, when the UID of the application is not 1000, the android service cannot be added. Therefore, the Android: shareduserid attribute is added to androidmanifest. XML to define the UID of the application as Android. uid. system, that is, 1000, so that the program can have permissions for the android service.

Take the example provided by mokoid as an example. Because we start the android service in an Android Application, pay special attention to this part. The typical new Android service method is to modify the frameworks/base/services/Java/COM/Android/Server/systemserver. Java file, but you need to modify the original Android code. So we can adopt this approach.

 

Http://apps.hi.baidu.com/share/detail/33541825

Related Article

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.