Socket
Socket
Sign inDemoInstall

adbkit

Package Overview
Dependencies
8
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.4 to 1.1.5

153

lib/adb/client.js

@@ -185,6 +185,7 @@ (function() {

this.connection().on('connect', function() {
var _this = this;
return new HostTransportCommand(this).execute(serial, function(err) {
return callback(err, _this);
});
return new HostTransportCommand(this).execute(serial, (function(_this) {
return function(err) {
return callback(err, _this);
};
})(this));
}).on('error', callback);

@@ -226,20 +227,21 @@ return this;

Client.prototype.screencap = function(serial, callback) {
var _this = this;
return this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return new ScreencapCommand(transport).execute(function(err, out) {
if (!err) {
return callback(null, out);
return this.transport(serial, (function(_this) {
return function(err, transport) {
if (err) {
return callback(err);
}
debug("Emulating screencap command due to '" + err + "'");
return _this.framebuffer(serial, 'png', function(err, info, framebuffer) {
if (err) {
return callback(err);
return new ScreencapCommand(transport).execute(function(err, out) {
if (!err) {
return callback(null, out);
}
return callback(null, framebuffer);
debug("Emulating screencap command due to '" + err + "'");
return _this.framebuffer(serial, 'png', function(err, info, framebuffer) {
if (err) {
return callback(err);
}
return callback(null, framebuffer);
});
});
});
});
};
})(this));
};

@@ -270,4 +272,3 @@

Client.prototype.openMonkey = function(serial, port, callback) {
var tryConnect,
_this = this;
var tryConnect;
if (arguments.length === 2) {

@@ -277,49 +278,54 @@ callback = port;

}
tryConnect = function(times, callback) {
return _this.openTcp(serial, port, function(err, stream) {
if (err && (times -= 1)) {
debug("Monkey can't be reached, trying " + times + " more times");
return setTimeout(function() {
return tryConnect(times, callback);
}, 100);
} else if (err) {
return callback(err);
} else {
return callback(null, Monkey.connectStream(stream));
tryConnect = (function(_this) {
return function(times, callback) {
return _this.openTcp(serial, port, function(err, stream) {
if (err && (times -= 1)) {
debug("Monkey can't be reached, trying " + times + " more times");
return setTimeout(function() {
return tryConnect(times, callback);
}, 100);
} else if (err) {
return callback(err);
} else {
return callback(null, Monkey.connectStream(stream));
}
});
};
})(this);
return tryConnect(1, (function(_this) {
return function(err, monkey) {
if (!err) {
return callback(null, monkey);
}
});
};
return tryConnect(1, function(err, monkey) {
if (!err) {
return callback(null, monkey);
}
return _this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return new MonkeyCommand(transport).execute(port, function(err) {
return _this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return tryConnect(20, callback);
return new MonkeyCommand(transport).execute(port, function(err) {
if (err) {
return callback(err);
}
return tryConnect(20, callback);
});
});
});
});
};
})(this));
};
Client.prototype.openLogcat = function(serial, callback) {
var _this = this;
return this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return new LogcatCommand(transport).execute(function(err, stream) {
return this.transport(serial, (function(_this) {
return function(err, transport) {
if (err) {
return callback(err);
}
return callback(null, Logcat.readStream(stream, {
fixLineFeeds: false
}));
});
});
return new LogcatCommand(transport).execute(function(err, stream) {
if (err) {
return callback(err);
}
return callback(null, Logcat.readStream(stream, {
fixLineFeeds: false
}));
});
};
})(this));
};

@@ -346,25 +352,26 @@

Client.prototype.install = function(serial, apk, callback) {
var temp,
_this = this;
var temp;
temp = Sync.temp(typeof apk === 'string' ? apk : '_stream.apk');
return this.push(serial, apk, temp, function(err, transfer) {
if (err) {
return callback(err);
}
return transfer.on('end', function() {
return _this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return new InstallCommand(transport).execute(temp, function(err) {
return this.push(serial, apk, temp, (function(_this) {
return function(err, transfer) {
if (err) {
return callback(err);
}
return transfer.on('end', function() {
return _this.transport(serial, function(err, transport) {
if (err) {
return callback(err);
}
return _this.shell(serial, ['rm', '-f', temp], function(err, out) {
return callback(err);
return new InstallCommand(transport).execute(temp, function(err) {
if (err) {
return callback(err);
}
return _this.shell(serial, ['rm', '-f', temp], function(err, out) {
return callback(err);
});
});
});
});
});
});
};
})(this));
};

@@ -371,0 +378,0 @@

(function() {
var Command, ForwardCommand, Protocol, _ref,
var Command, ForwardCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,27 +14,27 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function ForwardCommand() {
_ref = ForwardCommand.__super__.constructor.apply(this, arguments);
return _ref;
return ForwardCommand.__super__.constructor.apply(this, arguments);
}
ForwardCommand.prototype.execute = function(serial, local, remote, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host-serial:" + serial + ":forward:" + local + ";" + remote);

@@ -41,0 +41,0 @@ };

(function() {
var Command, GetDevicePathCommand, Protocol, _ref,
var Command, GetDevicePathCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetDevicePathCommand() {
_ref = GetDevicePathCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetDevicePathCommand.__super__.constructor.apply(this, arguments);
}
GetDevicePathCommand.prototype.execute = function(serial, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host-serial:" + serial + ":get-devpath");

@@ -34,0 +34,0 @@ };

(function() {
var Command, GetSerialNoCommand, Protocol, _ref,
var Command, GetSerialNoCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetSerialNoCommand() {
_ref = GetSerialNoCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetSerialNoCommand.__super__.constructor.apply(this, arguments);
}
GetSerialNoCommand.prototype.execute = function(serial, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host-serial:" + serial + ":get-serialno");

@@ -34,0 +34,0 @@ };

(function() {
var Command, GetStateCommand, Protocol, _ref,
var Command, GetStateCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetStateCommand() {
_ref = GetStateCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetStateCommand.__super__.constructor.apply(this, arguments);
}
GetStateCommand.prototype.execute = function(serial, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, value.toString('ascii'));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host-serial:" + serial + ":get-state");

@@ -34,0 +34,0 @@ };

(function() {
var Command, ListForwardsCommand, Protocol, _ref,
var Command, ListForwardsCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function ListForwardsCommand() {
_ref = ListForwardsCommand.__super__.constructor.apply(this, arguments);
return _ref;
return ListForwardsCommand.__super__.constructor.apply(this, arguments);
}
ListForwardsCommand.prototype.execute = function(serial, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseForwards(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseForwards(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host-serial:" + serial + ":list-forward");

@@ -37,9 +37,9 @@ };

ListForwardsCommand.prototype._parseForwards = function(value) {
var forward, forwards, local, remote, serial, _i, _len, _ref1, _ref2;
var forward, forwards, local, remote, serial, _i, _len, _ref, _ref1;
forwards = [];
_ref1 = value.toString().split('\n');
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
forward = _ref1[_i];
_ref = value.toString().split('\n');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
forward = _ref[_i];
if (forward) {
_ref2 = forward.split(/\s+/), serial = _ref2[0], local = _ref2[1], remote = _ref2[2];
_ref1 = forward.split(/\s+/), serial = _ref1[0], local = _ref1[1], remote = _ref1[2];
forwards.push({

@@ -46,0 +46,0 @@ serial: serial,

(function() {
var ClearCommand, Command, Protocol, _ref,
var ClearCommand, Command, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,28 +14,28 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function ClearCommand() {
_ref = ClearCommand.__super__.constructor.apply(this, arguments);
return _ref;
return ClearCommand.__super__.constructor.apply(this, arguments);
}
ClearCommand.prototype.execute = function(pkg, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(6, function(reply) {
switch (reply) {
case 'Succes':
return callback(null);
case 'Failed':
_this.connection.end();
return callback(new Error("Data of " + pkg + " could not be cleared"));
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(6, function(reply) {
switch (reply) {
case 'Succes':
return callback(null);
case 'Failed':
_this.connection.end();
return callback(new Error("Data of " + pkg + " could not be cleared"));
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:pm clear " + pkg + " 2>/dev/null");

@@ -42,0 +42,0 @@ };

(function() {
var Assert, Command, FrameBufferCommand, Protocol, RgbTransform, debug, spawn, _ref,
var Assert, Command, FrameBufferCommand, Protocol, RgbTransform, debug, spawn,
__hasProp = {}.hasOwnProperty,

@@ -22,30 +22,30 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function FrameBufferCommand() {
_ref = FrameBufferCommand.__super__.constructor.apply(this, arguments);
return _ref;
return FrameBufferCommand.__super__.constructor.apply(this, arguments);
}
FrameBufferCommand.prototype.execute = function(format, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readBytes(52, function(header) {
return _this._parseHeader(header, function(err, info) {
if (err) {
return callback(err);
}
switch (format) {
case 'raw':
return callback(null, info, _this.parser.raw());
default:
return callback(null, info, _this._convert(info, format, _this.parser.raw()));
}
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readBytes(52, function(header) {
return _this._parseHeader(header, function(err, info) {
if (err) {
return callback(err);
}
switch (format) {
case 'raw':
return callback(null, info, _this.parser.raw());
default:
return callback(null, info, _this._convert(info, format, _this.parser.raw()));
}
});
});
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('framebuffer:');

@@ -52,0 +52,0 @@ };

(function() {
var Command, GetFeaturesCommand, LineTransform, Protocol, _ref,
var Command, GetFeaturesCommand, LineTransform, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -18,4 +18,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetFeaturesCommand() {
_ref = GetFeaturesCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetFeaturesCommand.__super__.constructor.apply(this, arguments);
}

@@ -26,21 +25,22 @@

GetFeaturesCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parseFeatures(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parseFeatures(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('shell:pm list features 2>/dev/null');

@@ -47,0 +47,0 @@ };

(function() {
var Command, GetPackagesCommand, LineTransform, Protocol, _ref,
var Command, GetPackagesCommand, LineTransform, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -18,4 +18,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetPackagesCommand() {
_ref = GetPackagesCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetPackagesCommand.__super__.constructor.apply(this, arguments);
}

@@ -26,21 +25,22 @@

GetPackagesCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parsePackages(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parsePackages(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('shell:pm list packages 2>/dev/null');

@@ -47,0 +47,0 @@ };

(function() {
var Command, GetPropertiesCommand, LineTransform, Protocol, _ref,
var Command, GetPropertiesCommand, LineTransform, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -18,4 +18,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function GetPropertiesCommand() {
_ref = GetPropertiesCommand.__super__.constructor.apply(this, arguments);
return _ref;
return GetPropertiesCommand.__super__.constructor.apply(this, arguments);
}

@@ -26,21 +25,22 @@

GetPropertiesCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parseProperties(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var data, transform;
switch (reply) {
case Protocol.OKAY:
data = new Buffer('');
transform = _this.parser.raw().pipe(new LineTransform);
transform.on('data', function(chunk) {
return data = Buffer.concat([data, chunk]);
});
return transform.on('end', function() {
return callback(null, _this._parseProperties(data.toString()));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('shell:getprop');

@@ -47,0 +47,0 @@ };

(function() {
var Command, InstallCommand, Protocol, _ref,
var Command, InstallCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,29 +14,29 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function InstallCommand() {
_ref = InstallCommand.__super__.constructor.apply(this, arguments);
return _ref;
return InstallCommand.__super__.constructor.apply(this, arguments);
}
InstallCommand.prototype.execute = function(apk, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(7, function(reply) {
switch (reply) {
case 'Success':
return _this.parser.skipLine(function() {
return callback(null);
});
case 'Failure':
return callback(new Error("" + apk + " could not be installed"));
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(7, function(reply) {
switch (reply) {
case 'Success':
return _this.parser.skipLine(function() {
return callback(null);
});
case 'Failure':
return callback(new Error("" + apk + " could not be installed"));
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:pm install -r '" + apk + "' 2>/dev/null");

@@ -43,0 +43,0 @@ };

(function() {
var Command, IsInstalledCommand, Protocol, _ref,
var Command, IsInstalledCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,30 +14,30 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function IsInstalledCommand() {
_ref = IsInstalledCommand.__super__.constructor.apply(this, arguments);
return _ref;
return IsInstalledCommand.__super__.constructor.apply(this, arguments);
}
IsInstalledCommand.prototype.execute = function(pkg, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var endListener;
switch (reply) {
case Protocol.OKAY:
_this.connection.once('end', endListener = function() {
return callback(null, false);
});
return _this.parser.readAscii(8, function(reply) {
_this.connection.removeListener('end', endListener);
switch (reply) {
case 'package:':
return callback(null, true);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var endListener;
switch (reply) {
case Protocol.OKAY:
_this.connection.once('end', endListener = function() {
return callback(null, false);
});
return _this.parser.readAscii(8, function(reply) {
_this.connection.removeListener('end', endListener);
switch (reply) {
case 'package:':
return callback(null, true);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:pm path " + pkg + " 2>/dev/null");

@@ -44,0 +44,0 @@ };

(function() {
var Command, LogCommand, Protocol, _ref,
var Command, LogCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,18 +14,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function LogCommand() {
_ref = LogCommand.__super__.constructor.apply(this, arguments);
return _ref;
return LogCommand.__super__.constructor.apply(this, arguments);
}
LogCommand.prototype.execute = function(name, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("log:" + name);

@@ -32,0 +32,0 @@ };

(function() {
var Command, LineTransform, LogcatCommand, Protocol, _ref,
var Command, LineTransform, LogcatCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -16,19 +16,19 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function LogcatCommand() {
_ref = LogcatCommand.__super__.constructor.apply(this, arguments);
return _ref;
return LogcatCommand.__super__.constructor.apply(this, arguments);
}
LogcatCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw().pipe(new LineTransform));
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
return this._send('shell:logcat -B');
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw().pipe(new LineTransform));
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('shell:logcat -B 2>/dev/null');
};

@@ -35,0 +35,0 @@

(function() {
var Command, MonkeyCommand, Protocol, once, _ref,
var Command, MonkeyCommand, Protocol, once,
__hasProp = {}.hasOwnProperty,

@@ -18,4 +18,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function MonkeyCommand() {
_ref = MonkeyCommand.__super__.constructor.apply(this, arguments);
return _ref;
return MonkeyCommand.__super__.constructor.apply(this, arguments);
}

@@ -26,30 +25,31 @@

MonkeyCommand.prototype.execute = function(port, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var done, endListener, raw, timer;
switch (reply) {
case Protocol.OKAY:
done = once(function(err) {
raw.removeListener('end', endListener);
clearTimeout(timer);
return callback(err);
});
raw = _this.parser.raw();
raw.once('end', endListener = function() {
return done(new Error('Unexpected end of stream'));
});
raw.once('data', function(chunk) {
if (RE_OK.test(chunk)) {
return done(null);
} else {
return done(_this._unexpected(chunk));
}
});
return timer = setTimeout(done, 500);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var done, endListener, raw, timer;
switch (reply) {
case Protocol.OKAY:
done = once(function(err) {
raw.removeListener('end', endListener);
clearTimeout(timer);
return callback(err);
});
raw = _this.parser.raw();
raw.once('end', endListener = function() {
return done(new Error('Unexpected end of stream'));
});
raw.once('data', function(chunk) {
if (RE_OK.test(chunk)) {
return done(null);
} else {
return done(_this._unexpected(chunk));
}
});
return timer = setTimeout(done, 500);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:EXTERNAL_STORAGE=/data/local/tmp monkey --port " + port + " -v");

@@ -56,0 +56,0 @@ };

(function() {
var Command, Protocol, RemountCommand, _ref,
var Command, Protocol, RemountCommand,
__hasProp = {}.hasOwnProperty,

@@ -14,18 +14,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function RemountCommand() {
_ref = RemountCommand.__super__.constructor.apply(this, arguments);
return _ref;
return RemountCommand.__super__.constructor.apply(this, arguments);
}
RemountCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('remount:');

@@ -32,0 +32,0 @@ };

(function() {
var Command, LineTransform, Protocol, ScreencapCommand, _ref,
var Command, LineTransform, Protocol, ScreencapCommand,
__hasProp = {}.hasOwnProperty,

@@ -16,27 +16,27 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function ScreencapCommand() {
_ref = ScreencapCommand.__super__.constructor.apply(this, arguments);
return _ref;
return ScreencapCommand.__super__.constructor.apply(this, arguments);
}
ScreencapCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var closeListener, out, readableListener;
switch (reply) {
case Protocol.OKAY:
out = _this.parser.raw().pipe(new LineTransform);
out.once('end', closeListener = function() {
out.removeListener('readable', readableListener);
return callback(new Error('Unable to run screencap command'));
});
return out.once('readable', readableListener = function() {
out.removeListener('end', closeListener);
return callback(null, out);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var closeListener, out, readableListener;
switch (reply) {
case Protocol.OKAY:
out = _this.parser.raw().pipe(new LineTransform);
out.once('end', closeListener = function() {
out.removeListener('readable', readableListener);
return callback(new Error('Unable to run screencap command'));
});
return out.once('readable', readableListener = function() {
out.removeListener('end', closeListener);
return callback(null, out);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('shell:screencap -p 2>/dev/null');

@@ -43,0 +43,0 @@ };

(function() {
var Command, Protocol, ShellCommand, _ref,
var Command, Protocol, ShellCommand,
__hasProp = {}.hasOwnProperty,

@@ -16,4 +16,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function ShellCommand() {
_ref = ShellCommand.__super__.constructor.apply(this, arguments);
return _ref;
return ShellCommand.__super__.constructor.apply(this, arguments);
}

@@ -24,16 +23,17 @@

ShellCommand.prototype.execute = function(command, callback) {
var _this = this;
if (Array.isArray(command)) {
command = command.map(this._escapeArg).join(' ');
}
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:" + command);

@@ -40,0 +40,0 @@ };

(function() {
var Command, Protocol, StartActivityCommand, split, _ref,
var Command, Protocol, StartActivityCommand, split,
__hasProp = {}.hasOwnProperty,

@@ -18,4 +18,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function StartActivityCommand() {
_ref = StartActivityCommand.__super__.constructor.apply(this, arguments);
return _ref;
return StartActivityCommand.__super__.constructor.apply(this, arguments);
}

@@ -26,25 +25,26 @@

StartActivityCommand.prototype.execute = function(options, callback) {
var args,
_this = this;
this.parser.readAscii(4, function(reply) {
var err, lines;
switch (reply) {
case Protocol.OKAY:
err = null;
lines = _this.parser.raw().pipe(split());
lines.on('data', function(line) {
var match;
if (match = RE_ERROR.exec(line)) {
return err = new Error(match[1]);
}
});
return lines.on('end', function() {
return callback(err);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
var args;
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var err, lines;
switch (reply) {
case Protocol.OKAY:
err = null;
lines = _this.parser.raw().pipe(split());
lines.on('data', function(line) {
var match;
if (match = RE_ERROR.exec(line)) {
return err = new Error(match[1]);
}
});
return lines.on('end', function() {
return callback(err);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
args = [];

@@ -51,0 +51,0 @@ if (options.action) {

(function() {
var Command, Protocol, Sync, SyncCommand, _ref,
var Command, Protocol, Sync, SyncCommand,
__hasProp = {}.hasOwnProperty,

@@ -16,18 +16,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function SyncCommand() {
_ref = SyncCommand.__super__.constructor.apply(this, arguments);
return _ref;
return SyncCommand.__super__.constructor.apply(this, arguments);
}
SyncCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, new Sync(_this.connection, _this.parser));
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, new Sync(_this.connection, _this.parser));
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('sync:');

@@ -34,0 +34,0 @@ };

(function() {
var Command, Protocol, TcpCommand, _ref,
var Command, Protocol, TcpCommand,
__hasProp = {}.hasOwnProperty,

@@ -14,18 +14,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function TcpCommand() {
_ref = TcpCommand.__super__.constructor.apply(this, arguments);
return _ref;
return TcpCommand.__super__.constructor.apply(this, arguments);
}
TcpCommand.prototype.execute = function(port, host, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null, _this.parser.raw());
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send(("tcp:" + port) + (host ? ":" + host : ''));

@@ -32,0 +32,0 @@ };

(function() {
var Command, Protocol, UninstallCommand, _ref,
var Command, Protocol, UninstallCommand,
__hasProp = {}.hasOwnProperty,

@@ -14,26 +14,26 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function UninstallCommand() {
_ref = UninstallCommand.__super__.constructor.apply(this, arguments);
return _ref;
return UninstallCommand.__super__.constructor.apply(this, arguments);
}
UninstallCommand.prototype.execute = function(pkg, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(7, function(reply) {
switch (reply) {
case 'Success':
case 'Failure':
return callback(null);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(7, function(reply) {
switch (reply) {
case 'Success':
case 'Failure':
return callback(null);
default:
return callback(_this._unexpected(reply));
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:pm uninstall " + pkg + " 2>/dev/null");

@@ -40,0 +40,0 @@ };

(function() {
var Command, Protocol, WaitBootCompleteCommand, debug, split, _ref,
var Command, Protocol, WaitBootCompleteCommand, debug, split,
__hasProp = {}.hasOwnProperty,

@@ -18,37 +18,37 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function WaitBootCompleteCommand() {
_ref = WaitBootCompleteCommand.__super__.constructor.apply(this, arguments);
return _ref;
return WaitBootCompleteCommand.__super__.constructor.apply(this, arguments);
}
WaitBootCompleteCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var cleanup, endListener, lineListener, lines;
switch (reply) {
case Protocol.OKAY:
cleanup = function() {
lines.removeListener('end', endListener);
return lines.removeListener('data', lineListener);
};
lines = _this.parser.raw().pipe(split());
lines.on('end', endListener = function() {
cleanup();
return callback(new Error('Premature end of connection'));
});
return lines.on('data', lineListener = function(line) {
switch (line.toString()) {
case '1':
cleanup();
_this.connection.end();
return callback(null);
default:
return debug('Boot is not complete yet');
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var cleanup, endListener, lineListener, lines;
switch (reply) {
case Protocol.OKAY:
cleanup = function() {
lines.removeListener('end', endListener);
return lines.removeListener('data', lineListener);
};
lines = _this.parser.raw().pipe(split());
lines.on('end', endListener = function() {
cleanup();
return callback(new Error('Premature end of connection'));
});
return lines.on('data', lineListener = function(line) {
switch (line.toString()) {
case '1':
cleanup();
_this.connection.end();
return callback(null);
default:
return debug('Boot is not complete yet');
}
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("shell:while getprop sys.boot_completed 2>/dev/null; do sleep 1; done");

@@ -55,0 +55,0 @@ };

(function() {
var Command, HostDevicesCommand, Protocol, _ref,
var Command, HostDevicesCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostDevicesCommand() {
_ref = HostDevicesCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostDevicesCommand.__super__.constructor.apply(this, arguments);
}
HostDevicesCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseDevices(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseDevices(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('host:devices');

@@ -37,3 +37,3 @@ };

HostDevicesCommand.prototype._parseDevices = function(value) {
var devices, id, line, type, _i, _len, _ref1, _ref2;
var devices, id, line, type, _i, _len, _ref, _ref1;
devices = [];

@@ -43,7 +43,7 @@ if (!value.length) {

}
_ref1 = value.toString('ascii').split('\n');
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
line = _ref1[_i];
_ref = value.toString('ascii').split('\n');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
if (line) {
_ref2 = line.split('\t'), id = _ref2[0], type = _ref2[1];
_ref1 = line.split('\t'), id = _ref1[0], type = _ref1[1];
devices.push({

@@ -50,0 +50,0 @@ id: id,

(function() {
var Command, HostDevicesWithPathsCommand, Protocol, _ref,
var Command, HostDevicesWithPathsCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostDevicesWithPathsCommand() {
_ref = HostDevicesWithPathsCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostDevicesWithPathsCommand.__super__.constructor.apply(this, arguments);
}
HostDevicesWithPathsCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseDevices(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseDevices(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('host:devices-l');

@@ -37,3 +37,3 @@ };

HostDevicesWithPathsCommand.prototype._parseDevices = function(value) {
var devices, id, line, path, type, _i, _len, _ref1, _ref2;
var devices, id, line, path, type, _i, _len, _ref, _ref1;
devices = [];

@@ -43,7 +43,7 @@ if (!value.length) {

}
_ref1 = value.toString('ascii').split('\n');
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
line = _ref1[_i];
_ref = value.toString('ascii').split('\n');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
if (line) {
_ref2 = line.split(/\s+/), id = _ref2[0], type = _ref2[1], path = _ref2[2];
_ref1 = line.split(/\s+/), id = _ref1[0], type = _ref1[1], path = _ref1[2];
devices.push({

@@ -50,0 +50,0 @@ id: id,

(function() {
var Command, HostKillCommand, Protocol, _ref,
var Command, HostKillCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,18 +14,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostKillCommand() {
_ref = HostKillCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostKillCommand.__super__.constructor.apply(this, arguments);
}
HostKillCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('host:kill');

@@ -32,0 +32,0 @@ };

(function() {
var Command, HostDevicesCommand, HostTrackDevicesCommand, Protocol, Tracker, _ref,
var Command, HostDevicesCommand, HostTrackDevicesCommand, Protocol, Tracker,
__hasProp = {}.hasOwnProperty,

@@ -18,23 +18,23 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostTrackDevicesCommand() {
_ref = HostTrackDevicesCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostTrackDevicesCommand.__super__.constructor.apply(this, arguments);
}
HostTrackDevicesCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
var tracker;
switch (reply) {
case Protocol.OKAY:
tracker = new Tracker(_this.connection);
callback(null, tracker);
return setImmediate(function() {
return _this._readDevices(tracker);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
var tracker;
switch (reply) {
case Protocol.OKAY:
tracker = new Tracker(_this.connection);
callback(null, tracker);
return setImmediate(function() {
return _this._readDevices(tracker);
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send('host:track-devices');

@@ -44,9 +44,10 @@ };

HostTrackDevicesCommand.prototype._readDevices = function(tracker) {
var _this = this;
this.parser.readValue(function(value) {
tracker.update(_this._parseDevices(value));
return setImmediate(function() {
return _this._readDevices(tracker);
});
});
this.parser.readValue((function(_this) {
return function(value) {
tracker.update(_this._parseDevices(value));
return setImmediate(function() {
return _this._readDevices(tracker);
});
};
})(this));
return this;

@@ -53,0 +54,0 @@ };

(function() {
var Command, HostTransportCommand, Protocol, _ref,
var Command, HostTransportCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,18 +14,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostTransportCommand() {
_ref = HostTransportCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostTransportCommand.__super__.constructor.apply(this, arguments);
}
HostTransportCommand.prototype.execute = function(serial, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return callback(null);
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(_this._unexpected(reply));
}
};
})(this));
return this._send("host:transport:" + serial);

@@ -32,0 +32,0 @@ };

(function() {
var Command, HostVersionCommand, Protocol, _ref,
var Command, HostVersionCommand, Protocol,
__hasProp = {}.hasOwnProperty,

@@ -14,20 +14,20 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

function HostVersionCommand() {
_ref = HostVersionCommand.__super__.constructor.apply(this, arguments);
return _ref;
return HostVersionCommand.__super__.constructor.apply(this, arguments);
}
HostVersionCommand.prototype.execute = function(callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseVersion(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(null, _this._parseVersion(reply));
}
});
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue(function(value) {
return callback(null, _this._parseVersion(value));
});
case Protocol.FAIL:
return _this.parser.readError(callback);
default:
return callback(null, _this._parseVersion(reply));
}
};
})(this));
return this._send('host:version');

@@ -34,0 +34,0 @@ };

@@ -27,20 +27,29 @@ (function() {

Connection.prototype.connect = function() {
var _this = this;
this.socket = Net.connect(this.options);
this.parser = new Parser(this.socket);
this.socket.on('connect', function() {
return _this.emit('connect');
});
this.socket.on('end', function() {
return _this.emit('end');
});
this.socket.on('timeout', function() {
return _this.emit('timeout');
});
this.socket.on('error', function(err) {
return _this._handleError(err);
});
this.socket.on('close', function(hadError) {
return _this.emit('close', hadError);
});
this.socket.on('connect', (function(_this) {
return function() {
return _this.emit('connect');
};
})(this));
this.socket.on('end', (function(_this) {
return function() {
return _this.emit('end');
};
})(this));
this.socket.on('timeout', (function(_this) {
return function() {
return _this.emit('timeout');
};
})(this));
this.socket.on('error', (function(_this) {
return function(err) {
return _this._handleError(err);
};
})(this));
this.socket.on('close', (function(_this) {
return function(hadError) {
return _this.emit('close', hadError);
};
})(this));
return this;

@@ -71,12 +80,13 @@ };

Connection.prototype._handleError = function(err) {
var _this = this;
if (err.code === 'ECONNREFUSED' && !this.triedStarting) {
debug("Connection was refused, let's try starting the server once");
this.triedStarting = true;
this.startServer(function(err) {
if (err) {
return _this._handleError(err);
}
return _this.connect();
});
this.startServer((function(_this) {
return function(err) {
if (err) {
return _this._handleError(err);
}
return _this.connect();
};
})(this));
} else {

@@ -83,0 +93,0 @@ debug("Connection had an error: " + err.message);

@@ -39,8 +39,9 @@ (function() {

Parser.prototype.readValue = function(callback) {
var _this = this;
return this.readAscii(4, function(value) {
var length;
length = Protocol.decodeLength(value);
return _this.readBytes(length, callback);
});
return this.readAscii(4, (function(_this) {
return function(value) {
var length;
length = Protocol.decodeLength(value);
return _this.readBytes(length, callback);
};
})(this));
};

@@ -55,13 +56,14 @@

Parser.prototype.skipLine = function(callback) {
var consume,
_this = this;
consume = function() {
return _this.readBytes(1, function(buf) {
if (buf[0] === 0x0a) {
return callback();
} else {
return consume();
}
});
};
var consume;
consume = (function(_this) {
return function() {
return _this.readBytes(1, function(buf) {
if (buf[0] === 0x0a) {
return callback();
} else {
return consume();
}
});
};
})(this);
consume();

@@ -81,4 +83,3 @@ return this;

Parser.prototype._read = function(howMany, callback) {
var chunk,
_this = this;
var chunk;
if (howMany) {

@@ -88,5 +89,7 @@ if (chunk = this.stream.read(howMany)) {

} else {
this.stream.once('readable', function() {
return _this._read(howMany, callback);
});
this.stream.once('readable', (function(_this) {
return function() {
return _this._read(howMany, callback);
};
})(this));
}

@@ -100,4 +103,3 @@ } else {

Parser.prototype._readFlow = function(howMany, callback) {
var chunk,
_this = this;
var chunk;
if (howMany) {

@@ -113,5 +115,7 @@ while (chunk = this.stream.read(howMany) || this.stream.read()) {

if (howMany) {
this.stream.once('readable', function() {
return _this._readFlow(howMany, callback);
});
this.stream.once('readable', (function(_this) {
return function() {
return _this._readFlow(howMany, callback);
};
})(this));
}

@@ -118,0 +122,0 @@ } else {

@@ -20,3 +20,2 @@ (function() {

function ProcStat(sync) {
var _this = this;
this.sync = sync;

@@ -26,5 +25,7 @@ this.interval = 1000;

this._ignore = {};
this._timer = setInterval(function() {
return _this.update();
}, this.interval);
this._timer = setInterval((function(_this) {
return function() {
return _this.update();
};
})(this), this.interval);
this.update();

@@ -40,48 +41,52 @@ }

ProcStat.prototype.update = function() {
var _this = this;
return this.sync.pull('/proc/stat', function(err, stream) {
if (err) {
return _this._error(err);
}
return _this._parse(stream);
});
return this.sync.pull('/proc/stat', (function(_this) {
return function(err, stream) {
if (err) {
return _this._error(err);
}
return _this._parse(stream);
};
})(this));
};
ProcStat.prototype._parse = function(stream) {
var lines, stats,
_this = this;
var lines, stats;
stats = this._emptyStats();
lines = stream.pipe(split());
lines.on('data', function(line) {
var cols, total, type, val, _i, _len;
cols = line.split(RE_COLSEP);
type = cols.shift();
if (_this._ignore[type] === line) {
return;
}
if (RE_CPU.test(type)) {
total = 0;
for (_i = 0, _len = cols.length; _i < _len; _i++) {
val = cols[_i];
total += +val;
lines.on('data', (function(_this) {
return function(line) {
var cols, total, type, val, _i, _len;
cols = line.split(RE_COLSEP);
type = cols.shift();
if (_this._ignore[type] === line) {
return;
}
return stats.cpus[type] = {
line: line,
user: +cols[0] || 0,
nice: +cols[1] || 0,
system: +cols[2] || 0,
idle: +cols[3] || 0,
iowait: +cols[4] || 0,
irq: +cols[5] || 0,
softirq: +cols[6] || 0,
steal: +cols[7] || 0,
guest: +cols[8] || 0,
guestnice: +cols[9] || 0,
total: total
};
}
});
return lines.on('end', function() {
return _this._set(stats);
});
if (RE_CPU.test(type)) {
total = 0;
for (_i = 0, _len = cols.length; _i < _len; _i++) {
val = cols[_i];
total += +val;
}
return stats.cpus[type] = {
line: line,
user: +cols[0] || 0,
nice: +cols[1] || 0,
system: +cols[2] || 0,
idle: +cols[3] || 0,
iowait: +cols[4] || 0,
irq: +cols[5] || 0,
softirq: +cols[6] || 0,
steal: +cols[7] || 0,
guest: +cols[8] || 0,
guestnice: +cols[9] || 0,
total: total
};
}
};
})(this));
return lines.on('end', (function(_this) {
return function() {
return _this._set(stats);
};
})(this));
};

@@ -88,0 +93,0 @@

@@ -47,51 +47,17 @@ (function() {

Sync.prototype.stat = function(path, callback) {
var _this = this;
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.STAT:
return _this.parser.readBytes(12, function(stat) {
var mode, mtime, size;
mode = stat.readUInt32LE(0);
size = stat.readUInt32LE(4);
mtime = stat.readUInt32LE(8);
if (mode === 0) {
return callback(_this._enoent(path));
} else {
return callback(null, new Stats(mode, size, mtime));
}
});
case Protocol.FAIL:
return _this._readError(callback);
default:
return _this.parser.unexpected(reply, callback);
}
});
this._sendCommandWithArg(Protocol.STAT, path);
return this;
};
Sync.prototype.readdir = function(path, callback) {
var files, readBlock,
_this = this;
files = [];
readBlock = function() {
return _this.parser.readAscii(4, function(reply) {
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.DENT:
return _this.parser.readBytes(16, function(stat) {
var mode, mtime, namelen, size;
case Protocol.STAT:
return _this.parser.readBytes(12, function(stat) {
var mode, mtime, size;
mode = stat.readUInt32LE(0);
size = stat.readUInt32LE(4);
mtime = stat.readUInt32LE(8);
namelen = stat.readUInt32LE(12);
return _this.parser.readBytes(namelen, function(name) {
name = name.toString();
if (!(name === '.' || name === '..')) {
files.push(new Entry(name, mode, size, mtime));
}
return setImmediate(readBlock);
});
if (mode === 0) {
return callback(_this._enoent(path));
} else {
return callback(null, new Stats(mode, size, mtime));
}
});
case Protocol.DONE:
return callback(null, files);
case Protocol.FAIL:

@@ -102,4 +68,40 @@ return _this._readError(callback);

}
});
};
};
})(this));
this._sendCommandWithArg(Protocol.STAT, path);
return this;
};
Sync.prototype.readdir = function(path, callback) {
var files, readBlock;
files = [];
readBlock = (function(_this) {
return function() {
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.DENT:
return _this.parser.readBytes(16, function(stat) {
var mode, mtime, namelen, size;
mode = stat.readUInt32LE(0);
size = stat.readUInt32LE(4);
mtime = stat.readUInt32LE(8);
namelen = stat.readUInt32LE(12);
return _this.parser.readBytes(namelen, function(name) {
name = name.toString();
if (!(name === '.' || name === '..')) {
files.push(new Entry(name, mode, size, mtime));
}
return setImmediate(readBlock);
});
});
case Protocol.DONE:
return callback(null, files);
case Protocol.FAIL:
return _this._readError(callback);
default:
return _this.parser.unexpected(reply, callback);
}
});
};
})(this);
readBlock();

@@ -152,4 +154,3 @@ this._sendCommandWithArg(Protocol.LIST, path);

Sync.prototype._writeData = function(stream, timeStamp, callback) {
var saturated, track, transfer, write,
_this = this;
var saturated, track, transfer, write;
if (callback) {

@@ -159,28 +160,32 @@ callback = once(callback);

transfer = new PushTransfer;
transfer.on('cancel', function() {
stream.end();
return _this.connection.end();
});
this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readBytes(4, function(zero) {
return transfer.end();
});
case Protocol.FAIL:
return _this._readError(function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
default:
return _this.parser.unexpected(reply, function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
}
});
transfer.on('cancel', (function(_this) {
return function() {
stream.end();
return _this.connection.end();
};
})(this));
this.parser.readAscii(4, (function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readBytes(4, function(zero) {
return transfer.end();
});
case Protocol.FAIL:
return _this._readError(function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
default:
return _this.parser.unexpected(reply, function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
}
};
})(this));
saturated = false;

@@ -190,26 +195,30 @@ track = function() {

};
write = function() {
var chunk, _results;
if (!saturated) {
_results = [];
while (chunk = stream.read(DATA_MAX_LENGTH) || stream.read()) {
_this._sendCommandWithLength(Protocol.DATA, chunk.length);
transfer.push(chunk.length);
if (!_this.connection.write(chunk, track)) {
saturated = true;
_results.push(stream.once('drain', function() {
saturated = false;
return write();
}));
} else {
_results.push(void 0);
write = (function(_this) {
return function() {
var chunk, _results;
if (!saturated) {
_results = [];
while (chunk = stream.read(DATA_MAX_LENGTH) || stream.read()) {
_this._sendCommandWithLength(Protocol.DATA, chunk.length);
transfer.push(chunk.length);
if (!_this.connection.write(chunk, track)) {
saturated = true;
_results.push(stream.once('drain', function() {
saturated = false;
return write();
}));
} else {
_results.push(void 0);
}
}
return _results;
}
return _results;
}
};
};
})(this);
stream.on('readable', write);
stream.on('end', function() {
return _this._sendCommandWithLength(Protocol.DONE, timeStamp);
});
stream.on('end', (function(_this) {
return function() {
return _this._sendCommandWithLength(Protocol.DONE, timeStamp);
};
})(this));
stream.on('error', function(err) {

@@ -230,4 +239,3 @@ transfer.emit('error', err);

Sync.prototype._readData = function(callback) {
var readBlock, transfer,
_this = this;
var readBlock, transfer;
if (callback) {

@@ -237,43 +245,47 @@ callback = once(callback);

transfer = new PullTransfer;
transfer.on('cancel', function() {
return _this.connection.end();
});
readBlock = function() {
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.DATA:
if (callback) {
callback(null, transfer);
}
return _this.parser.readBytes(4, function(lengthData) {
var length;
length = lengthData.readUInt32LE(0);
return _this.parser.readByteFlow(length, function(chunk, final) {
transfer.write(chunk);
if (final) {
return setImmediate(readBlock);
transfer.on('cancel', (function(_this) {
return function() {
return _this.connection.end();
};
})(this));
readBlock = (function(_this) {
return function() {
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.DATA:
if (callback) {
callback(null, transfer);
}
return _this.parser.readBytes(4, function(lengthData) {
var length;
length = lengthData.readUInt32LE(0);
return _this.parser.readByteFlow(length, function(chunk, final) {
transfer.write(chunk);
if (final) {
return setImmediate(readBlock);
}
});
});
case Protocol.DONE:
return _this.parser.readBytes(4, function(zero) {
return transfer.end();
});
case Protocol.FAIL:
return _this._readError(function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
});
case Protocol.DONE:
return _this.parser.readBytes(4, function(zero) {
return transfer.end();
});
case Protocol.FAIL:
return _this._readError(function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
default:
return _this.parser.unexpected(reply, function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
}
});
};
default:
return _this.parser.unexpected(reply, function(err) {
transfer.emit('error', err);
if (callback) {
return callback(err);
}
});
}
});
};
})(this);
readBlock();

@@ -284,8 +296,9 @@ return transfer;

Sync.prototype._readError = function(callback) {
var _this = this;
return this.parser.readBytes(4, function(zero) {
return _this.parser.readAll(function(buf) {
return callback(new Error(buf.toString()));
});
});
return this.parser.readBytes(4, (function(_this) {
return function(zero) {
return _this.parser.readAll(function(buf) {
return callback(new Error(buf.toString()));
});
};
})(this));
};

@@ -292,0 +305,0 @@

{
"name": "adbkit",
"version": "1.1.4",
"version": "1.1.5",
"description": "A pure Node.js client for the Android Debug Bridge.",

@@ -34,4 +34,4 @@ "keywords": [

"adbkit-monkey": "~1.0.1",
"async": "~0.2.9",
"debug": "~0.7.3",
"async": "~0.2.10",
"debug": "~0.7.4",
"once": "~1.3.0",

@@ -42,16 +42,16 @@ "split": "~0.2.10"

"bench": "~0.3.5",
"chai": "~1.8.1",
"coffee-script": "~1.6.3",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.11",
"grunt-coffeelint": "~0.0.7",
"chai": "~1.9.0",
"coffee-script": "~1.7.1",
"grunt": "~0.4.2",
"grunt-cli": "~0.1.13",
"grunt-coffeelint": "0.0.8",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-coffee": "~0.10.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-exec": "~0.4.2",
"grunt-jsonlint": "~1.0.2",
"grunt-exec": "~0.4.3",
"grunt-jsonlint": "~1.0.4",
"grunt-notify": "~0.2.16",
"mocha": "~1.14.0",
"sinon": "~1.7.3",
"sinon-chai": "~2.4.0"
"mocha": "~1.17.1",
"sinon": "~1.8.1",
"sinon-chai": "~2.5.0"
},

@@ -58,0 +58,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc