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