43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const { withAndroidManifest } = require('@expo/config-plugins');
|
|
|
|
const permissionsToRemove = [
|
|
'android.permission.READ_MEDIA_AUDIO',
|
|
'android.permission.READ_MEDIA_IMAGES',
|
|
'android.permission.READ_MEDIA_VIDEO',
|
|
'android.permission.READ_MEDIA_VISUAL_USER_SELECTED',
|
|
'android.permission.READ_EXTERNAL_STORAGE',
|
|
'android.permission.WRITE_EXTERNAL_STORAGE'
|
|
];
|
|
|
|
module.exports = function withRemoveMediaPermissions(config) {
|
|
return withAndroidManifest(config, async (config) => {
|
|
let androidManifest = config.modResults.manifest;
|
|
|
|
if (!androidManifest['uses-permission']) {
|
|
androidManifest['uses-permission'] = [];
|
|
}
|
|
|
|
// Make sure we have the tools namespace
|
|
if (!androidManifest.$['xmlns:tools']) {
|
|
androidManifest.$['xmlns:tools'] = 'http://schemas.android.com/tools';
|
|
}
|
|
|
|
permissionsToRemove.forEach(permissionName => {
|
|
// Check if it already exists to avoid duplicates
|
|
const exists = androidManifest['uses-permission'].some(
|
|
p => p.$['android:name'] === permissionName && p.$['tools:node'] === 'remove'
|
|
);
|
|
if (!exists) {
|
|
androidManifest['uses-permission'].push({
|
|
$: {
|
|
'android:name': permissionName,
|
|
'tools:node': 'remove'
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
return config;
|
|
});
|
|
};
|