mobile-cli-lib
Version:
common lib used by different CLI
44 lines (43 loc) • 2.29 kB
JavaScript
;
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var android_debug_bridge_1 = require("./android-debug-bridge");
var DeviceAndroidDebugBridge = (function (_super) {
__extends(DeviceAndroidDebugBridge, _super);
function DeviceAndroidDebugBridge(identifier, $childProcess, $errors, $logger, $staticConfig, $androidDebugBridgeResultHandler) {
_super.call(this, $childProcess, $errors, $logger, $staticConfig, $androidDebugBridgeResultHandler);
this.identifier = identifier;
this.$childProcess = $childProcess;
this.$errors = $errors;
this.$logger = $logger;
this.$staticConfig = $staticConfig;
this.$androidDebugBridgeResultHandler = $androidDebugBridgeResultHandler;
}
DeviceAndroidDebugBridge.prototype.executeShellCommand = function (args, options) {
args.unshift("shell");
return _super.prototype.executeCommand.call(this, args, options);
};
DeviceAndroidDebugBridge.prototype.sendBroadcastToDevice = function (action, extras) {
var _this = this;
if (extras === void 0) { extras = {}; }
return (function () {
var broadcastCommand = ["am", "broadcast", "-a", ("" + action)];
_.each(extras, function (value, key) { return broadcastCommand.push("-e", key, value); });
var result = _this.executeShellCommand(broadcastCommand).wait();
_this.$logger.trace("Broadcast result " + result + " from " + broadcastCommand);
var match = result.match(/Broadcast completed: result=(\d+)/);
if (match) {
return +match[1];
}
_this.$errors.failWithoutHelp("Unable to broadcast to android device:\n%s", result);
}).future()();
};
DeviceAndroidDebugBridge.prototype.composeCommand = function (params) {
return _super.prototype.composeCommand.call(this, params, this.identifier);
};
return DeviceAndroidDebugBridge;
}(android_debug_bridge_1.AndroidDebugBridge));
exports.DeviceAndroidDebugBridge = DeviceAndroidDebugBridge;