#!/usr/bin/env node // // This hook removes specific permissions from the AndroidManifest.xml // The AndroidManifest is re-generated during the prepare stage, // so this must be run on the "after_prepare" hook. // // Configure the permissions to be forcefully removed. // NOTE: These permissions will be removed regardless of how many plugins // require the permission. You can check the permission is only required // by the plugin you *think* needs it, by looking at the "count" shown in // your /plugins/android.json file. // If the count is more than 1, you should search through // the /plugins//plugin.xml files for tags. var permsToRm = [ "RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS", "READ_PHONE_STATE" ]; var fs = require('fs'); var path = require('path'); var rootdir = process.argv[2]; var manifestFile = path.join(rootdir, "plugin/cordova-plugin-media/config.xml"); /* "platforms/android/app/AndroidManifest.xml" */ fs.readFile( manifestFile, "utf8", function( err, data ) { if (err) return console.log( "Error reading plugin/cordova-plugin-media/config.xml", err ); var result = data; for(var i = 0; i < permsToRm.length; i++) { var search = ''; result = result.replace(search, ''); } fs.writeFile( manifestFile, result, "utf8", function( err ){ if (err) return console.log( "Error writing AndroidManifest.xml", err ); }); } );