From a32276a331e0a4dfaf4980185739225a276a7246 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Thu, 17 Jul 2014 14:47:19 -0700 Subject: [PATCH] [TIMOB-17344] Fixed a bug with the buffer not being reset after an adb command fails. Also fixed a bug where Genymotion emulators with stale ip addresses were detected as running even if they weren't. --- node_modules/titanium-sdk/lib/adb.js | 6 +++++- node_modules/titanium-sdk/lib/emulators/genymotion.js | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/node_modules/titanium-sdk/lib/adb.js b/node_modules/titanium-sdk/lib/adb.js index 77a2438dfb8..a6416085e7a 100644 --- a/node_modules/titanium-sdk/lib/adb.js +++ b/node_modules/titanium-sdk/lib/adb.js @@ -151,7 +151,11 @@ Connection.prototype.exec = function exec(cmd, callback, opts) { len && (buffer = buffer.slice(0, len)); DEBUG && console.log('[' + this.connNum + '] ERROR! ' + buffer.toString()); this.state = DO_NOTHING; - callback(new Error(buffer.toString())); + + // copy the buffer into an error so we can free up the buffer + var err = new Error(buffer.toString()); + buffer = null; + callback(err); conn.end(); return; } diff --git a/node_modules/titanium-sdk/lib/emulators/genymotion.js b/node_modules/titanium-sdk/lib/emulators/genymotion.js index a1bf5ca74c2..2cc22e9e025 100644 --- a/node_modules/titanium-sdk/lib/emulators/genymotion.js +++ b/node_modules/titanium-sdk/lib/emulators/genymotion.js @@ -360,7 +360,13 @@ function getVMInfo(config, vboxmanage, callback) { if (emu && emu.ipaddress) { var adb = new ADB(config); adb.shell(emu.ipaddress + ':5555', '[ -f /system/etc/g.prop ] && cat /system/etc/g.prop || echo ""', function (err, out) { - emu.googleApis = out ? out.toString().indexOf('gapps') != -1 : null; + if (err) { + // if we errored, then that means the 'androvm_ip_management' + // was stale and we should just assume it's not running + emu.ipaddress = null; + } else { + emu.googleApis = out ? out.toString().indexOf('gapps') != -1 : null; + } next(null, emu); }); } else {