diff --git a/index.js b/index.js index 38131e8..6ec4db4 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,18 @@ Host.prototype = { 'tcp:' + DEFAULT_PORT]); adb.on('close', function() { debug('Set adb forward to ' + port); - callback(); + var adbStart = spawn('adb', ['shell', 'stop', 'b2g']); + adbStart.on('close', function() { + + var adbStop = spawn('adb', ['shell', 'start', 'b2g']); + adbStop.on('close', function() { + // Note: you need to wait for marionette to be ready. + // The marionette client should do that for you. + // https://bugzilla.mozilla.org/show_bug.cgi?id=1033402 + // Callback still needs to be called Asynchronously + setTimeout(callback, 0); + }); + }); }); adb.stdout.on('data', function (data) { console.error('(start) stdout: ' + data); diff --git a/package.json b/package.json index 5a4c924..cb0c0ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marionette-device-host", - "version": "0.0.2", + "version": "0.1.0", "author": "Hubert Figuiere [:hub]", "description": "marionette-js-runner host for device (and emulator)", "main": "index.js",