AOSP Marshmallow modify/set default permission

2019-09-14 01:23发布

问题:

I have built my own AOSP Marshmallow on my Nexus 5 device and got trouble with the permissions. If I add a new permission into the AndroidManifest.xml of an existing application, this permission will be by default turned off. I have to manually set it. The other permission for example Contacts is being active (the once I did not modify and seems to be standard even after factory reset). So there has to be a file which gives conclusion about the standard permission of the applications. I just could find some files within /system/etc/default-permissions, but this makes no sense to me and it seems to be ignored.

When I add my custom application all permissions are by default turned off. How can I enable those permissions by default when I flash my custom os in Marshmallow for nexus 5 devices? Where can I set this information within my AOSP project? I could set it via pm grant <app> android.permission... but this is not my use case!

回答1:

Default permissions in AOSP are set in this java class: frameworks/base/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java

Here is an example: https://github.com/ProjectDisco/android_frameworks_base/commit/da1408d4a3df46af11854bf68844be133c5a20d3