From 268fea58ee96b9561dd690e9b1102f0f7d6fc012 Mon Sep 17 00:00:00 2001 From: sgrebnov Date: Mon, 27 Oct 2014 17:14:35 +0300 Subject: [PATCH 1/6] CB-7881 Android tooling shouldn't lock application directory Close #130 --- bin/templates/cordova/lib/build.js | 3 ++- bin/templates/cordova/lib/device.js | 9 +++++---- bin/templates/cordova/lib/emulator.js | 15 ++++++++------- bin/templates/cordova/lib/log.js | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index fead2067..7bc20f67 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -24,6 +24,7 @@ var shell = require('shelljs'), Q = require('q'), path = require('path'), fs = require('fs'), + os = require('os'), ROOT = path.join(__dirname, '..', '..'); var check_reqs = require('./check_reqs'); var exec = require('./exec'); @@ -400,7 +401,7 @@ module.exports.run = function(options, optResolvedTarget) { */ module.exports.detectArchitecture = function(target) { function helper() { - return exec('adb -s ' + target + ' shell cat /proc/cpuinfo') + return exec('adb -s ' + target + ' shell cat /proc/cpuinfo', os.tmpdir()) .then(function(output) { if (/intel/i.exec(output)) { return 'x86'; diff --git a/bin/templates/cordova/lib/device.js b/bin/templates/cordova/lib/device.js index 6430d732..9516ba4a 100644 --- a/bin/templates/cordova/lib/device.js +++ b/bin/templates/cordova/lib/device.js @@ -22,6 +22,7 @@ var exec = require('./exec'), Q = require('q'), path = require('path'), + os = require('os'), build = require('./build'), appinfo = require('./appinfo'), ROOT = path.join(__dirname, '..', '..'); @@ -32,7 +33,7 @@ var exec = require('./exec'), */ module.exports.list = function(lookHarder) { function helper() { - return exec('adb devices') + return exec('adb devices', os.tmpdir()) .then(function(output) { var response = output.split('\n'); var device_list = []; @@ -100,19 +101,19 @@ module.exports.install = function(target, buildResults) { console.log('Using apk: ' + apk_path); console.log('Installing app on device...'); var cmd = 'adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"'; - return exec(cmd) + return exec(cmd, os.tmpdir()) .then(function(output) { if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output); //unlock screen var cmd = 'adb -s ' + resolvedTarget.target + ' shell input keyevent 82'; - return exec(cmd); + return exec(cmd, os.tmpdir()); }, function(err) { return Q.reject('ERROR: Failed to install apk to device: ' + err); }) .then(function() { // launch the application console.log('Launching application...'); var cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName; - return exec(cmd); + return exec(cmd, os.tmpdir()); }).then(function() { console.log('LAUNCH SUCCESS'); }, function(err) { diff --git a/bin/templates/cordova/lib/emulator.js b/bin/templates/cordova/lib/emulator.js index 8cf58e2d..70e03055 100644 --- a/bin/templates/cordova/lib/emulator.js +++ b/bin/templates/cordova/lib/emulator.js @@ -23,6 +23,7 @@ var shell = require('shelljs'), exec = require('./exec'), Q = require('q'), path = require('path'), + os = require('os'), appinfo = require('./appinfo'), build = require('./build'), ROOT = path.join(__dirname, '..', '..'), @@ -108,7 +109,7 @@ module.exports.best_image = function() { // Returns a promise. module.exports.list_started = function() { - return exec('adb devices') + return exec('adb devices', os.tmpdir()) .then(function(output) { var response = output.split('\n'); var started_emulator_list = []; @@ -123,7 +124,7 @@ module.exports.list_started = function() { // Returns a promise. module.exports.list_targets = function() { - return exec('android list targets') + return exec('android list targets', os.tmpdir()) .then(function(output) { var target_out = output.split('\n'); var targets = []; @@ -201,7 +202,7 @@ module.exports.start = function(emulator_ID) { console.log('BOOT COMPLETE'); //unlock screen - return exec('adb -s ' + emulator_id + ' shell input keyevent 82'); + return exec('adb -s ' + emulator_id + ' shell input keyevent 82', os.tmpdir()); }).then(function() { //return the new emulator id for the started emulators return emulator_id; @@ -231,7 +232,7 @@ module.exports.wait_for_emulator = function(num_running) { */ module.exports.wait_for_boot = function(emulator_id) { var self = this; - return exec('adb -s ' + emulator_id + ' shell getprop init.svc.bootanim') + return exec('adb -s ' + emulator_id + ' shell getprop init.svc.bootanim', os.tmpdir()) .then(function(output) { if (output.match(/stopped/)) { return; @@ -309,7 +310,7 @@ module.exports.install = function(target, buildResults) { var apk_path = build.findBestApkForArchitecture(buildResults, resolvedTarget.arch); console.log('Installing app on emulator...'); console.log('Using apk: ' + apk_path); - return exec('adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"') + return exec('adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"', os.tmpdir()) .then(function(output) { if (output.match(/Failure/)) { return Q.reject('Failed to install apk to emulator: ' + output); @@ -319,13 +320,13 @@ module.exports.install = function(target, buildResults) { return Q.reject('Failed to install apk to emulator: ' + err); }).then(function() { //unlock screen - return exec('adb -s ' + resolvedTarget.target + ' shell input keyevent 82'); + return exec('adb -s ' + resolvedTarget.target + ' shell input keyevent 82', os.tmpdir()); }).then(function() { // launch the application console.log('Launching application...'); var launchName = appinfo.getActivityName(); cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName; - return exec(cmd); + return exec(cmd, os.tmpdir()); }).then(function(output) { console.log('LAUNCH SUCCESS'); }, function(err) { diff --git a/bin/templates/cordova/lib/log.js b/bin/templates/cordova/lib/log.js index 329dfc91..d61023e8 100644 --- a/bin/templates/cordova/lib/log.js +++ b/bin/templates/cordova/lib/log.js @@ -21,6 +21,7 @@ var shell = require('shelljs'), path = require('path'), + os = require('os'), Q = require('q'), child_process = require('child_process'), ROOT = path.join(__dirname, '..', '..'); @@ -32,7 +33,7 @@ var shell = require('shelljs'), module.exports.run = function() { var cmd = 'adb logcat | grep -v nativeGetEnabledTags'; var d = Q.defer(); - var adb = child_process.spawn('adb', ['logcat']); + var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()}); adb.stdout.on('data', function(data) { var lines = data ? data.toString().split('\n') : []; From f7c717e393d913ce4b3297873a9a6b866c799e5d Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 10 Dec 2014 20:06:38 -0500 Subject: [PATCH 2/6] Close #137 (already merged). --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7dbcaba..0ed4e63e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,8 +25,8 @@ Anyone can contribute to Cordova. And we need your contributions. There are multiple ways to contribute: report bugs, improve the docs, and contribute code. - -For instructions on this, start with the + +For instructions on this, start with the [contribution overview](http://cordova.apache.org/#contribute). The details are explained there, but the important items are: @@ -35,3 +35,4 @@ The details are explained there, but the important items are: - Run the tests so your patch doesn't break existing functionality. We look forward to your contributions! + From aa2d3962bfab3a4f3e746ff30a228360e5fc595d Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 10 Dec 2014 20:59:51 -0500 Subject: [PATCH 3/6] Close #126 (not-a-problem) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ed4e63e..f34ecff7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ Anyone can contribute to Cordova. And we need your contributions. There are multiple ways to contribute: report bugs, improve the docs, and contribute code. - + For instructions on this, start with the [contribution overview](http://cordova.apache.org/#contribute). From 3aca14d5306811985354486a434d7819ea2357cc Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 10 Dec 2014 20:30:59 -0500 Subject: [PATCH 4/6] CB-8147 Have corodva/build warn about unrecognized flags rather than fail Close #127 --- bin/templates/cordova/lib/build.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index 7bc20f67..3dc3b3db 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -339,14 +339,19 @@ function parseOpts(options, resolvedTarget) { case 'gradle': ret.buildMethod = option; break; + case 'device': + case 'emulator': + // Don't need to do anything special to when building for device vs emulator. + // iOS uses this flag to switch on architecture. + break; case 'nobuild' : ret.buildMethod = 'none'; break; default : - return Q.reject('Build option \'' + options[i] + '\' not recognized.'); + console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'; } } else { - return Q.reject('Build option \'' + options[i] + '\' not recognized.'); + console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'; } } From d80d532a2a24e67573d9116b06d62c6c5187aa61 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 10 Dec 2014 21:16:18 -0500 Subject: [PATCH 5/6] Fix syntax error in 3aca14d53068 --- bin/templates/cordova/lib/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index 3dc3b3db..461af3b0 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -348,10 +348,10 @@ function parseOpts(options, resolvedTarget) { ret.buildMethod = 'none'; break; default : - console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'; + console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'); } } else { - console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'; + console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).'); } } From 56a3ee5fe66c4eb0ac67b2f258d4f1f9a0536ff8 Mon Sep 17 00:00:00 2001 From: Daniel Toplak Date: Wed, 26 Nov 2014 08:31:45 +0100 Subject: [PATCH 6/6] CB-8079 Use activity class package name, but fallback to application package name when looking for splash screen drawable Close #136 --- framework/src/org/apache/cordova/CordovaPreferences.java | 3 +++ framework/src/org/apache/cordova/SplashScreenInternal.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/framework/src/org/apache/cordova/CordovaPreferences.java b/framework/src/org/apache/cordova/CordovaPreferences.java index 536f25a2..ed0b9b89 100644 --- a/framework/src/org/apache/cordova/CordovaPreferences.java +++ b/framework/src/org/apache/cordova/CordovaPreferences.java @@ -133,6 +133,9 @@ public class CordovaPreferences { } else if (name.equals("splashscreen")) { // Note: We should probably pass in the classname for the variable splash on splashscreen! int resource = action.getResources().getIdentifier(value, "drawable", action.getClass().getPackage().getName()); + if(resource == 0) { + resource = action.getResources().getIdentifier(value, "drawable", action.getPackageName()); + } action.getIntent().putExtra(name, resource); } else if(name.equals("backgroundcolor")) { diff --git a/framework/src/org/apache/cordova/SplashScreenInternal.java b/framework/src/org/apache/cordova/SplashScreenInternal.java index 605fce7d..715e4182 100644 --- a/framework/src/org/apache/cordova/SplashScreenInternal.java +++ b/framework/src/org/apache/cordova/SplashScreenInternal.java @@ -54,6 +54,9 @@ public class SplashScreenInternal extends CordovaPlugin { String splashResource = preferences.getString("SplashScreen", null); if (splashResource != null) { drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName()); + if (drawableId == 0) { + drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName()); + } preferences.set("SplashDrawableId", drawableId); } }