1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 12:00:08 +02:00

Uninstall app first if installation fails due to inconsistent certificates.

This commit is contained in:
Simo Kinnunen 2014-07-17 19:37:52 +09:00
parent a0ed5f93ad
commit 7c93351dd4

View file

@ -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')