mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Uninstall app first if installation fails due to inconsistent certificates.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user