mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 09:53:21 +02:00
@@ -10,6 +10,7 @@ var pathutil = require('../../../util/pathutil')
|
||||
var devutil = require('../../../util/devutil')
|
||||
var streamutil = require('../../../util/streamutil')
|
||||
var Resource = require('./util/resource')
|
||||
var deviceClient = require('@devicefarmer/adbkit').DeviceClient
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
@@ -67,9 +68,11 @@ module.exports = syrup.serial()
|
||||
, mode: 0755
|
||||
})
|
||||
}
|
||||
|
||||
var client = deviceClient(adb, options.serial)
|
||||
|
||||
function removeResource(res) {
|
||||
return adb.shell(options.serial, ['rm', '-f', res.dest])
|
||||
return client.shell(['rm', '-f', res.dest])
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
return streamutil.readAll(out)
|
||||
@@ -78,7 +81,7 @@ module.exports = syrup.serial()
|
||||
}
|
||||
|
||||
function pushResource(res) {
|
||||
return adb.push(options.serial, res.src, res.dest, res.mode)
|
||||
return client.push(res.src, res.dest, res.mode)
|
||||
.timeout(10000)
|
||||
.then(function(transfer) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
@@ -93,7 +96,7 @@ module.exports = syrup.serial()
|
||||
log.info('Installing "%s" as "%s"', res.src, res.dest)
|
||||
|
||||
function checkExecutable(res) {
|
||||
return adb.stat(options.serial, res.dest)
|
||||
return client.stat(res.dest)
|
||||
.timeout(5000)
|
||||
.then(function(stats) {
|
||||
// Can't use fs.constants.S_IXUSR due to differences on Windows.
|
||||
|
||||
@@ -3,6 +3,7 @@ var util = require('util')
|
||||
var syrup = require('@devicefarmer/stf-syrup')
|
||||
var ProtoBuf = require('protobufjs')
|
||||
var semver = require('semver')
|
||||
var deviceClient = require('@devicefarmer/adbkit').DeviceClient
|
||||
|
||||
var pathutil = require('../../../util/pathutil')
|
||||
var streamutil = require('../../../util/streamutil')
|
||||
@@ -30,7 +31,8 @@ module.exports = syrup.serial()
|
||||
}
|
||||
|
||||
function getPath() {
|
||||
return adb.shell(options.serial, ['pm', 'path', resource.pkg])
|
||||
var client = deviceClient(adb, options.serial)
|
||||
return client.shell(['pm', 'path', resource.pkg])
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
return streamutil.findLine(out, (/^package:/))
|
||||
@@ -46,7 +48,8 @@ module.exports = syrup.serial()
|
||||
return getPath()
|
||||
.then(function(installedPath) {
|
||||
log.info('Running version check')
|
||||
return adb.shell(options.serial, util.format(
|
||||
var client = deviceClient(adb, options.serial)
|
||||
return client.shell(util.format(
|
||||
"export CLASSPATH='%s';" +
|
||||
" exec app_process /system/bin '%s' --version 2>/dev/null"
|
||||
, installedPath
|
||||
@@ -74,11 +77,13 @@ module.exports = syrup.serial()
|
||||
log.info('Installing STFService')
|
||||
// Uninstall first to make sure we don't have any certificate
|
||||
// issues.
|
||||
return adb.uninstall(options.serial, resource.pkg)
|
||||
var client = deviceClient(adb, options.serial)
|
||||
|
||||
return client.uninstall(resource.pkg)
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return promiseutil.periodicNotify(
|
||||
adb.install(options.serial, resource.apk)
|
||||
client.install(resource.apk)
|
||||
, 20000
|
||||
)
|
||||
.timeout(65000)
|
||||
|
||||
Reference in New Issue
Block a user