diff --git a/lib/units/device/plugins/install.js b/lib/units/device/plugins/install.js index 3592e657..ad06cda8 100644 --- a/lib/units/device/plugins/install.js +++ b/lib/units/device/plugins/install.js @@ -11,6 +11,13 @@ var wire = require('../../../wire') var wireutil = require('../../../wire/util') var promiseutil = require('../../../util/promiseutil') +// The error codes are available at https://github.com/android/ +// platform_frameworks_base/blob/master/core/java/android/content/ +// pm/PackageManager.java +function InstallationError(err) { + return err.code && /^INSTALL_/.test(err.code) +} + module.exports = syrup.serial() .dependency(require('../support/adb')) .dependency(require('../support/router')) @@ -164,15 +171,22 @@ module.exports = syrup.serial() , reply.fail('timeout') ]) }) - .catch(function(err) { - log.error('Installation of package "%s" failed', pkg, err.stack) - // The error codes are available at https://github.com/android/ - // platform_frameworks_base/blob/master/core/java/android/content/ - // pm/PackageManager.java, although this could be some other - // error as well. + .catch(InstallationError, function(err) { + log.important( + 'Tried to install package "%s", got "%s"' + , pkg + , err.code + ) push.send([ channel - , reply.fail(err.code || 'fail') + , reply.fail(err.code) + ]) + }) + .catch(function(err) { + log.error('Installation of package "%s" failed', pkg, err.stack) + push.send([ + channel + , reply.fail('fail') ]) }) })