1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Push vendor files to devices.

This commit is contained in:
Simo Kinnunen 2014-01-29 00:13:29 +09:00
parent a4725fe71c
commit 216592a995
12 changed files with 83 additions and 8 deletions

View file

@ -1,4 +1,5 @@
var assert = require('assert')
var util = require('util')
var Promise = require('bluebird')
var zmq = require('zmq')
@ -8,11 +9,14 @@ var logger = require('../util/logger')
var wire = require('../wire')
var wireutil = require('../util/wireutil')(wire)
var devutil = require('../util/devutil')
var pathutil = require('../util/pathutil')
var promiseutil = require('../util/promiseutil')
var ChannelManager = require('../wire/channelmanager')
module.exports = function(options) {
var log = logger.createLogger('device')
var identity = Object.create(null)
var vendor = Object.create(null)
var solo = wireutil.makePrivateChannel()
var channels = new ChannelManager()
@ -43,18 +47,44 @@ module.exports = function(options) {
push.send([channel, wireutil.makeLeaveGroupMessage(options.serial)])
})
promiseutil.periodicNotify(adb.waitBootCompleteAsync(options.serial), 1000)
.progressed(function() {
log.info('Waiting for boot to complete')
})
.then(function() {
log.info('Gathering properties')
return adb.getPropertiesAsync(options.serial)
})
.then(function(properties) {
log.info('Solving identity')
return identity = devutil.makeIdentity(options.serial, properties)
})
.then(function() {
vendor = devutil.vendorFiles(identity)
return Promise.all(Object.keys(vendor).map(function(id) {
var res = vendor[id]
log.info(util.format('Pushing vendor file "%s"', res.dest))
return adb.pushAsync(options.serial, res.src, res.dest, res.mode)
.then(function(transfer) {
return new Promise(function(resolve, reject) {
transfer.on('end', resolve)
})
})
}))
})
.done(function() {
log.info('Ready for instructions')
poke()
})
sub.on('message', function(channel, data) {
var wrapper = wire.Envelope.decode(data)
channels.keepalive(channel)
switch (wrapper.type) {
case wire.MessageType.PROBE:
var message = wire.ProbeMessage.decode(wrapper.message)
adb.getPropertiesAsync(options.serial)
.then(function(properties) {
identity = devutil.makeIdentity(options.serial, properties)
push.send([channel,
wireutil.makeDeviceIdentityMessage(options.serial, identity)])
})
break
case wire.MessageType.GROUP:
var message = wire.GroupMessage.decode(wrapper.message)
@ -145,6 +175,4 @@ module.exports = function(options) {
process.on('SIGTERM', function() {
gracefullyExit()
})
poke()
}

View file

@ -1,9 +1,27 @@
var util = require('util')
var wire = require('../wire')
var pathutil = require('./pathutil')
var devutil = module.exports = Object.create(null)
devutil.vendorFiles = function(identity) {
return {
bin: {
src: pathutil.vendor(util.format(
'remote/libs/%s/remote', identity.abi))
, dest: '/data/local/tmp/remote'
, mode: 0755
}
, so: {
src: pathutil.vendor(util.format(
'remote/external/android-%d/remote_external.so', identity.sdk))
, dest: '/data/local/tmp/remote_external.so'
, mode: 0755
}
}
}
devutil.platform = function(platform) {
switch (platform) {
case 'android':

View file

@ -4,3 +4,8 @@ var path = require('path')
module.exports.resource = function(target) {
return path.resolve(__dirname, '../../res', target)
}
// Export
module.exports.vendor = function(target) {
return path.resolve(__dirname, '../../vendor', target)
}

24
lib/util/promiseutil.js Normal file
View file

@ -0,0 +1,24 @@
var Promise = require('bluebird')
module.exports.periodicNotify = function(promise, interval) {
var resolver = Promise.defer()
, timer = setInterval(notify, interval)
function notify() {
resolver.progress()
}
function resolve() {
resolver.resolve()
}
function reject() {
resolver.reject()
}
promise.then(resolve, reject)
return resolver.promise.finally(function() {
clearInterval(timer)
})
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
vendor/remote/libs/armeabi-v7a/remote vendored Executable file

Binary file not shown.