diff --git a/lib/roles/device/plugins/install.js b/lib/roles/device/plugins/install.js index 71d8b01b..e49726ae 100644 --- a/lib/roles/device/plugins/install.js +++ b/lib/roles/device/plugins/install.js @@ -19,7 +19,9 @@ module.exports = syrup.serial() var log = logger.createLogger('device:plugins:install') router.on(wire.InstallMessage, function(channel, message) { - log.info('Installing "%s"', message.href) + var pkg = message.manifest.package + + log.info('Installing package "%s" from "%s"', pkg, message.href) var reply = wireutil.reply(options.serial) @@ -94,6 +96,21 @@ module.exports = syrup.serial() sendProgress('installing_app', guesstimate) return promiseutil.periodicNotify( adb.installRemote(options.serial, apk) + .catch(function(err) { + switch (err.code) { + case 'INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES': + log.info( + 'Uninstalling "%s" first due to inconsistent certificates' + , pkg + ) + return adb.uninstall(options.serial, pkg) + .then(function() { + return adb.installRemote(options.serial, apk) + }) + default: + throw err + } + }) , 250 ) .progressed(function() { @@ -103,7 +120,7 @@ module.exports = syrup.serial() ) sendProgress('installing_app', guesstimate) }) - .timeout(30000) + .timeout(35000) }) .then(function() { if (message.launch) { @@ -113,7 +130,7 @@ module.exports = syrup.serial() action: 'android.intent.action.MAIN' , component: util.format( '%s/%s' - , manifest.package + , pkg , manifest.application.launcherActivities[0].name ) , category: ['android.intent.category.LAUNCHER'] @@ -139,7 +156,7 @@ module.exports = syrup.serial() ]) }) .catch(function(err) { - log.error('Installation failed', err.stack) + log.error('Installation of package "%s" failed', pkg, err.stack) push.send([ channel , reply.fail('fail')