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:
Crepieux Pierre
2021-05-31 18:00:28 +02:00
parent 69e2a3651e
commit bb1c20d1f7
9 changed files with 80 additions and 30 deletions

View File

@@ -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)
}
}
})

View File

@@ -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')