From 5607fee1926864a28b625b8eb9cee780b671bb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 8 Aug 2016 12:20:01 -0300 Subject: [PATCH] disable android auto backup --- cordova/build.sh | 6 ++++++ cordova/config.xml | 6 ++++-- cordova/scripts/afterRun.js | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 cordova/scripts/afterRun.js diff --git a/cordova/build.sh b/cordova/build.sh index a39271a78..765992233 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -209,6 +209,12 @@ if [ $CURRENT_OS == "ANDROID" ]; then cp android/project.properties $PROJECT/platforms/android/project.properties checkOK + mkdir -p $PROJECT/scripts + checkOK + + cp scripts/* $PROJECT/scripts + checkOK + cp -R android/res/* $PROJECT/platforms/android/res checkOK fi diff --git a/cordova/config.xml b/cordova/config.xml index 18b3d4c4c..ca2c4b14f 100644 --- a/cordova/config.xml +++ b/cordova/config.xml @@ -19,7 +19,7 @@ - + @@ -29,7 +29,9 @@ - + + + diff --git a/cordova/scripts/afterRun.js b/cordova/scripts/afterRun.js new file mode 100644 index 000000000..1f5f4d53a --- /dev/null +++ b/cordova/scripts/afterRun.js @@ -0,0 +1,18 @@ +module.exports = function(ctx) { + var fs = ctx.requireCordovaModule('fs'), + path = ctx.requireCordovaModule('path'), + xml = ctx.requireCordovaModule('cordova-common').xmlHelpers; + + var manifestPath = path.join(ctx.opts.projectRoot, '/platforms/android/AndroidManifest.xml'); + var doc = xml.parseElementtreeSync(manifestPath); + if (doc.getroot().tag !== 'manifest') { + throw new Error(manifestPath + ' has incorrect root node name (expected "manifest")'); + } + + doc.getroot().find('./application').attrib['android:allowBackup'] = "false"; + + //write the manifest file + fs.writeFileSync(manifestPath, doc.write({ + indent: 4 + }), 'utf-8'); +};