From 54c0a488f48360884f2f69626a8291f6b881988b Mon Sep 17 00:00:00 2001 From: gine Date: Wed, 19 Apr 2017 19:21:24 +0200 Subject: [PATCH] Aggiunto hook per rimuovere dei permessi che non utiliziamo ma che vengono inseriti di default dal plugin media --- hooks/after_prepare/030_remove_permissions.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 hooks/after_prepare/030_remove_permissions.js diff --git a/hooks/after_prepare/030_remove_permissions.js b/hooks/after_prepare/030_remove_permissions.js new file mode 100755 index 0000000..d053b3d --- /dev/null +++ b/hooks/after_prepare/030_remove_permissions.js @@ -0,0 +1,39 @@ +#!/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, "platforms/android/AndroidManifest.xml"); + +fs.readFile( manifestFile, "utf8", function( err, data ) { + if (err) + return console.log( "Error reading AndroidManifest.xml", err ); + + var result = data; + for(var i = 0; i < permsToRm.length; i++) { + var search = ''; + result = result.replace(search, ''); + } + + fs.writeFile( manifestFile, data, "utf8", function( err ){ + if (err) + return console.log( "Error writing AndroidManifest.xml", err ); + }); +} ); \ No newline at end of file