Refactor InputAgent into STFService. Support copypasting (only pasting implemented in the UI right now though).

This commit is contained in:
Simo Kinnunen
2014-04-01 11:47:20 +09:00
parent 514fc3554d
commit 09eb8c539d
13 changed files with 379 additions and 50 deletions

View File

@@ -11,16 +11,21 @@ var logger = require('../../../util/logger')
module.exports = syrup.serial()
.dependency(require('../support/adb'))
.define(function(options, adb) {
var log = logger.createLogger('device:resources:inputagent')
var log = logger.createLogger('device:resources:service')
var resource = {
requiredVersion: '~0.2.0'
, pkg: 'jp.co.cyberagent.stf.input.agent'
, main: 'jp.co.cyberagent.stf.input.agent.InputAgent'
, apk: pathutil.vendor('InputAgent/InputAgent.apk')
, proto: ProtoBuf.loadProtoFile(
pathutil.vendor('InputAgent/proto/agent.proto')
).build().jp.co.cyberagent.stf.input.agent.proto
, pkg: 'jp.co.cyberagent.stf'
, main: 'jp.co.cyberagent.stf.InputAgent'
, apk: pathutil.vendor('STFService/STFService.apk')
, agentProto: ProtoBuf.loadProtoFile(
pathutil.vendor('STFService/proto/agent.proto')
).build().jp.co.cyberagent.stf.proto
, serviceProto: ProtoBuf.loadProtoFile(
pathutil.vendor('STFService/proto/service.proto')
).build().jp.co.cyberagent.stf.proto
, startAction: 'jp.co.cyberagent.stf.ACTION_START'
, stopAction: 'jp.co.cyberagent.stf.ACTION_STOP'
}
function getPath() {
@@ -34,7 +39,7 @@ module.exports = syrup.serial()
}
function install() {
log.info('Checking whether we need to install InputAgent.apk')
log.info('Checking whether we need to install STFService')
return getPath()
.then(function(installedPath) {
log.info('Running version check')
@@ -49,6 +54,10 @@ module.exports = syrup.serial()
.timeout(10000)
.then(function(buffer) {
var version = buffer.toString()
throw new Error(util.format(
'Incompatible version %s'
, version
))
if (semver.satisfies(version, resource.requiredVersion)) {
return installedPath
}
@@ -62,7 +71,7 @@ module.exports = syrup.serial()
})
})
.catch(function() {
log.info('Installing InputAgent.apk')
log.info('Installing STFService')
return adb.install(options.serial, resource.apk)
.then(function() {
return getPath()
@@ -72,12 +81,8 @@ module.exports = syrup.serial()
return install()
.then(function(path) {
log.info('InputAgent.apk up to date')
return {
path: path
, pkg: resource.pkg
, main: resource.main
, proto: resource.proto
}
log.info('STFService up to date')
resource.path = path
return resource
})
})