mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 23:53:25 +02:00
Introduce support for new VM based minicap to support Android 12
This commit introduce a new option to use a new minicap implementation by specifying --screen-grabber or the env variable SCREEN_GRABBER. The current native minicap is the default and is refered as 'minicap-bin'. The new minicap which is packaged in an apk is usable with 'minicap-apk' and will be used as a fallback. At the moment, this apk is expected to be included in minicap-prebuilt node package at this location minicap-prebuilt/prebuilt/noarch/minicap.apk. STFService.apk has also been updated to take into account Android 12 Signed-off-by: Crepieux Pierre <pierre.crepieux@orange.com>
This commit is contained in:
@@ -33,7 +33,7 @@ module.exports = syrup.serial()
|
||||
log.info('Capturing screenshot')
|
||||
|
||||
var file = util.format('/data/local/tmp/minicap_%d.jpg', Date.now())
|
||||
return minicap.run(util.format(
|
||||
return minicap.run('minicap-apk', util.format(
|
||||
'-P %s -s >%s', projectionFormat(), file))
|
||||
.then(adbkit.util.readAll)
|
||||
.then(function() {
|
||||
|
||||
@@ -25,8 +25,9 @@ module.exports = syrup.serial()
|
||||
.dependency(require('./options'))
|
||||
.define(function(options, adb, minicap, display, screenOptions) {
|
||||
var log = logger.createLogger('device:plugins:screen:stream')
|
||||
log.info("ScreenGrabber option set to %s", options.screenGrabber)
|
||||
|
||||
function FrameProducer(config) {
|
||||
function FrameProducer(config, grabber) {
|
||||
EventEmitter.call(this)
|
||||
this.actionQueue = []
|
||||
this.runningState = FrameProducer.STATE_STOPPED
|
||||
@@ -37,6 +38,7 @@ module.exports = syrup.serial()
|
||||
this.banner = null
|
||||
this.parser = null
|
||||
this.frameConfig = config
|
||||
this.grabber = options.screenGrabber
|
||||
this.readable = false
|
||||
this.needsReadable = false
|
||||
this.failCounter = new FailCounter(3, 10000)
|
||||
@@ -102,7 +104,7 @@ module.exports = syrup.serial()
|
||||
.catch(function(err) {
|
||||
return this._stop().finally(function() {
|
||||
this.failCounter.inc()
|
||||
this.emit('error', err)
|
||||
this.grabber = 'minicap-apk'
|
||||
})
|
||||
})
|
||||
.finally(function() {
|
||||
@@ -227,13 +229,13 @@ module.exports = syrup.serial()
|
||||
}
|
||||
|
||||
FrameProducer.prototype._startService = function() {
|
||||
log.info('Launching screen service')
|
||||
return minicap.run(util.format(
|
||||
'-S -Q %d -P %s'
|
||||
, options.screenJpegQuality
|
||||
, this.frameConfig.toString()
|
||||
))
|
||||
.timeout(10000)
|
||||
log.info('Launching screen service %s', this.grabber)
|
||||
return minicap.run(this.grabber,util.format(
|
||||
'-S -Q %d -P %s'
|
||||
, options.screenJpegQuality
|
||||
, this.frameConfig.toString()
|
||||
))
|
||||
.timeout(10000)
|
||||
}
|
||||
|
||||
FrameProducer.prototype._readOutput = function(out) {
|
||||
@@ -448,6 +450,7 @@ module.exports = syrup.serial()
|
||||
|
||||
return createServer()
|
||||
.then(function(wss) {
|
||||
log.info("creating FrameProducer: %s", options.screenGrabber)
|
||||
var frameProducer = new FrameProducer(
|
||||
new FrameConfig(display.properties, display.properties))
|
||||
var broadcastSet = frameProducer.broadcastSet = new BroadcastSet()
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = syrup.serial()
|
||||
, lib: new Resource({
|
||||
// @todo The lib ABI should match the bin ABI. Currently we don't
|
||||
// have an x86_64 version of the binary while the lib supports it.
|
||||
src: pathutil.requiredMatch(abi.all.reduce(function(all, supportedAbi) {
|
||||
src: pathutil.match(abi.all.reduce(function(all, supportedAbi) {
|
||||
return all.concat([
|
||||
pathutil.module(util.format(
|
||||
'@devicefarmer/minicap-prebuilt/prebuilt/%s/lib/android-%s/minicap.so'
|
||||
@@ -59,6 +59,12 @@ module.exports = syrup.serial()
|
||||
, comm: 'minicap.so' // Not actually used for anything but log output
|
||||
, mode: 0755
|
||||
})
|
||||
, apk: new Resource({
|
||||
src: pathutil.match([pathutil.module('@devicefarmer/minicap-prebuilt/prebuilt/noarch/minicap.apk')])
|
||||
, dest: ['/data/local/tmp/minicap.apk']
|
||||
, comm: 'minicap.apk'
|
||||
, mode: 0755
|
||||
})
|
||||
}
|
||||
|
||||
function removeResource(res) {
|
||||
@@ -113,10 +119,15 @@ module.exports = syrup.serial()
|
||||
}
|
||||
|
||||
function installAll() {
|
||||
return Promise.all([
|
||||
installResource(resources.bin)
|
||||
, installResource(resources.lib)
|
||||
])
|
||||
var resourcesToBeinstalled = []
|
||||
if(resources.lib.src !== undefined) {
|
||||
resourcesToBeinstalled.push(installResource(resources.bin))
|
||||
resourcesToBeinstalled.push(installResource(resources.lib))
|
||||
}
|
||||
if(resources.apk.src !== undefined) {
|
||||
resourcesToBeinstalled.push(installResource(resources.apk))
|
||||
}
|
||||
return Promise.all(resourcesToBeinstalled)
|
||||
}
|
||||
|
||||
function stop() {
|
||||
@@ -135,13 +146,27 @@ module.exports = syrup.serial()
|
||||
return {
|
||||
bin: resources.bin.dest
|
||||
, lib: resources.lib.dest
|
||||
, run: function(cmd) {
|
||||
return adb.shell(options.serial, util.format(
|
||||
'LD_LIBRARY_PATH=%s exec %s %s'
|
||||
, path.dirname(resources.lib.dest)
|
||||
, resources.bin.dest
|
||||
, cmd
|
||||
))
|
||||
, apk: resources.apk.dest
|
||||
, run: function(mode, cmd) {
|
||||
var runCmd
|
||||
if(mode === 'minicap-bin' && resources.lib.src !== undefined) {
|
||||
runCmd = util.format(
|
||||
'LD_LIBRARY_PATH=%s exec %s %s'
|
||||
, path.dirname(resources.lib.dest)
|
||||
, resources.bin.dest
|
||||
, cmd
|
||||
)
|
||||
} else if(mode === 'minicap-apk' && resources.apk.src !== undefined ) {
|
||||
runCmd = util.format(
|
||||
'CLASSPATH=%s app_process /system/bin io.devicefarmer.minicap.Main %s'
|
||||
, resources.apk.dest
|
||||
, cmd
|
||||
)
|
||||
} else {
|
||||
log.error("Missing resources/unknown minicap grabber: %s", mode)
|
||||
}
|
||||
log.info(runCmd)
|
||||
return adb.shell(options.serial, runCmd)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = syrup.serial()
|
||||
pathutil.vendor('STFService/wire.proto'))
|
||||
|
||||
var resource = {
|
||||
requiredVersion: '2.4.6'
|
||||
requiredVersion: '2.4.7'
|
||||
, pkg: 'jp.co.cyberagent.stf'
|
||||
, main: 'jp.co.cyberagent.stf.Agent'
|
||||
, apk: pathutil.vendor('STFService/STFService.apk')
|
||||
|
||||
Reference in New Issue
Block a user