mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:23:28 +02:00
Add an alternate install location for binary resources. Fixes devices where /data/local/tmp is mounted as noexec, like ZUK Z1. Closes #436.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var util = require('util')
|
||||
var fs = require('fs')
|
||||
|
||||
var Promise = require('bluebird')
|
||||
var syrup = require('stf-syrup')
|
||||
@@ -7,15 +8,16 @@ var logger = require('../../../util/logger')
|
||||
var pathutil = require('../../../util/pathutil')
|
||||
var devutil = require('../../../util/devutil')
|
||||
var streamutil = require('../../../util/streamutil')
|
||||
var Resource = require('./util/resource')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
.dependency(require('../support/abi'))
|
||||
.define(function(options, adb, abi) {
|
||||
logger.createLogger('device:resources:minitouch')
|
||||
var log = logger.createLogger('device:resources:minitouch')
|
||||
|
||||
var resources = {
|
||||
bin: {
|
||||
bin: new Resource({
|
||||
src: pathutil.requiredMatch(abi.all.map(function(supportedAbi) {
|
||||
return pathutil.vendor(util.format(
|
||||
'minitouch/%s/minitouch%s'
|
||||
@@ -23,10 +25,13 @@ module.exports = syrup.serial()
|
||||
, abi.pie ? '' : '-nopie'
|
||||
))
|
||||
}))
|
||||
, dest: '/data/local/tmp/minitouch'
|
||||
, dest: [
|
||||
'/data/local/tmp/minitouch'
|
||||
, '/data/data/com.android.shell/minitouch'
|
||||
]
|
||||
, comm: 'minitouch'
|
||||
, mode: 0755
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeResource(res) {
|
||||
@@ -38,7 +43,7 @@ module.exports = syrup.serial()
|
||||
.return(res)
|
||||
}
|
||||
|
||||
function installResource(res) {
|
||||
function pushResource(res) {
|
||||
return adb.push(options.serial, res.src, res.dest, res.mode)
|
||||
.timeout(10000)
|
||||
.then(function(transfer) {
|
||||
@@ -50,9 +55,38 @@ module.exports = syrup.serial()
|
||||
.return(res)
|
||||
}
|
||||
|
||||
function installResource(res) {
|
||||
log.info('Installing "%s" as "%s"', res.comm, res.dest)
|
||||
|
||||
function checkExecutable(res) {
|
||||
return adb.stat(options.serial, res.dest)
|
||||
.timeout(5000)
|
||||
.then(function(stats) {
|
||||
return (stats.mode & fs.constants.S_IXUSR) === fs.constants.S_IXUSR
|
||||
})
|
||||
}
|
||||
|
||||
return removeResource(res)
|
||||
.then(pushResource)
|
||||
.then(function(res) {
|
||||
return checkExecutable(res).then(function(ok) {
|
||||
if (!ok) {
|
||||
log.info(
|
||||
'Pushed "%s" not executable, attempting fallback location'
|
||||
, res.comm
|
||||
)
|
||||
res.shift()
|
||||
return installResource(res)
|
||||
}
|
||||
return res
|
||||
})
|
||||
})
|
||||
.return(res)
|
||||
}
|
||||
|
||||
function installAll() {
|
||||
return Promise.all([
|
||||
removeResource(resources.bin).then(installResource)
|
||||
installResource(resources.bin)
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user