I'm building a custom OS with my app as system app. I need to get storage, camera, etc., permissions by default when the OS is installed.
How can I get these permission by default without any user interaction?
create a xml file and Add the following lines (name the file as def_permission.xml)
<?xml version="1.0" encoding="utf-8"?>
<exceptions>
<exception package="com.<package_name>.<package>">
<!-- <yourpackage> -->
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" fixed="false"/>
<permission name="android.permission.READ_EXTERNAL_STORAGE" fixed="false"/>
<permission name="android.permission.ACCESS_FINE_LOCATION" fixed="false" />
<permission name="android.permission.ACCESS_COARSE_LOCATION" fixed="false" />
<permission name="android.permission.CAMERA" fixed="false"/>
<permission name="android.permission.WRITE_CONTACTS" fixed="false" />
<permission name="android.permission.READ_CONTACTS" fixed="false"/>
<permission name="android.permission.READ_PHONE_STATE" fixed="false"/>
</exception>
</exceptions>
for Android 9 and above --
copy def_permission.xml to device/make/model/def_permission.xml
add these following lines in device-model.mk , aosp_model.mk
PRODUCT_COPY_FILES += device/make/model/def_permission.xml:product/etc/default-permissions/def_permission.xml
and build your custom rom , this will enable permissions for your apk by default