Reputation: 61
In a custom android Oreo AOSP, is possible grant camera permission for my app in priv-app folder?
I know that is a dangerous permission and should be granted in runtime, but there is any other option that not require the user interaction if the app is in system/priv-app?
I saw that there is a whitelist in /etc/permissions, https://source.android.com/devices/tech/config/perms-whitelist, but I think that is no for dangerous permissions, like camera.
Upvotes: 1
Views: 841
Reputation: 703
You can grant dangerous permission for private application in /system/priv-app
:
Create the default permission file default-permission-sample.xml
. You need to replace package name by your app's package name
<?xml version="1.0" encoding="utf-8"?>
<exceptions>
<exception package="com.your.camera">
<permission name="android.permission.CAMERA"/>
</exception>
</exceptions>
Then config makefile to copy default-permission-sample.xml
into /system/etc/default-permissions/
directory.
DONE.
Upvotes: 1
Reputation: 4756
You can grant default runtime permissions to a package by modifying frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
The relevant method here would be:
private void grantDefaultSystemHandlerPermissions(PackageManagerWrapper pm, int userId)
For example, this is how STORAGE permissions are granted to "com.android.sharedstoragebackup" :
// There is no real "marker" interface to identify the shared storage backup, it is
// hardcoded in BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE.
grantSystemFixedPermissionsToSystemPackage(pm, "com.android.sharedstoragebackup", userId,
STORAGE_PERMISSIONS);
Upvotes: 0