diff --git a/lib/roles/app.js b/lib/roles/app.js index d3695691..c5ddd47e 100644 --- a/lib/roles/app.js +++ b/lib/roles/app.js @@ -434,6 +434,16 @@ module.exports = function(options) { ) ]) }) + .on('device.uninstall', function(channel, responseChannel, data) { + joinChannel(responseChannel) + push.send([ + channel + , wireutil.transaction( + responseChannel + , new wire.UninstallMessage(data) + ) + ]) + }) }) .finally(function() { // Clean up all listeners and subscriptions diff --git a/lib/roles/device/plugins/install.js b/lib/roles/device/plugins/install.js index 55af672c..5a750f7a 100644 --- a/lib/roles/device/plugins/install.js +++ b/lib/roles/device/plugins/install.js @@ -132,4 +132,35 @@ module.exports = syrup.serial() ]) }) }) + + router.on(wire.UninstallMessage, function(channel, message) { + log.info('Uninstalling "%s"', message.package) + + var seq = 0 + + adb.uninstall(options.serial, message.package) + .then(function() { + push.send([ + channel + , wireutil.envelope(new wire.TransactionDoneMessage( + options.serial + , seq++ + , true + , 'success' + )) + ]) + }) + .catch(function(err) { + log.error('Uninstallation failed', err.stack) + push.send([ + channel + , wireutil.envelope(new wire.TransactionDoneMessage( + options.serial + , seq++ + , false + , 'fail' + )) + ]) + }) + }) }) diff --git a/lib/wire/wire.proto b/lib/wire/wire.proto index 65d74466..b3eb2ee9 100644 --- a/lib/wire/wire.proto +++ b/lib/wire/wire.proto @@ -329,6 +329,10 @@ message InstallMessage { optional LaunchActivityMessage launchActivity = 2; } +message UninstallMessage { + required string package = 1; +} + message LaunchActivityMessage { required string action = 1; required string component = 2; diff --git a/res/app/components/stf/control/control-service.js b/res/app/components/stf/control/control-service.js index 1bf1ac43..e47b1adb 100644 --- a/res/app/components/stf/control/control-service.js +++ b/res/app/components/stf/control/control-service.js @@ -135,6 +135,14 @@ module.exports = function ControlServiceFactory( return tx }) } + + this.uninstall = function(pkg) { + var tx = TransactionService.create(target) + socket.emit('device.uninstall', channel, tx.channel, { + package: pkg + }) + return tx + } } controlService.create = function(target, channel) {