Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1027232 - Restart b2g #2

Merged
merged 1 commit into from Jul 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion index.js
Expand Up @@ -62,7 +62,18 @@ Host.prototype = {
'tcp:' + DEFAULT_PORT]);
adb.on('close', function() {
debug('Set adb forward to ' + port);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug code. because it is useful when you need to diagnose. not sure what your question is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't see that this was called after the adb port forward command finished

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merely an FYI here: you could leave off the 0 here, or since it's Node, you can use the much more efficient process.nextTick(callback).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid Node specific stuff if I can :-)

I have seen setTimeout(callback, 0) elsewhere. MDN doesn't tell us that the delay is an optional parameter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just call the callback, we should be good since spawn is async.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope it doesn't work if I just call the callback. I actually tried that. I didn't dig the problem but the setTimeout did the trick.

});
});
});
adb.stdout.on('data', function (data) {
console.error('(start) stdout: ' + data);
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down