mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Fix adb invocations (#202)
This commit is contained in:
@@ -3,6 +3,7 @@ var events = require('events')
|
||||
|
||||
var syrup = require('@devicefarmer/stf-syrup')
|
||||
var Promise = require('bluebird')
|
||||
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default
|
||||
|
||||
var wire = require('../../../wire')
|
||||
var wireutil = require('../../../wire/util')
|
||||
@@ -36,6 +37,7 @@ module.exports = syrup.serial()
|
||||
.dependency(require('../support/sdk'))
|
||||
.dependency(require('../resources/service'))
|
||||
.define(function(options, adb, router, push, sdk, apk) {
|
||||
var deviceClient = new DeviceClient(adb, options.serial)
|
||||
var log = logger.createLogger('device:plugins:service')
|
||||
var messageResolver = new MessageResolver()
|
||||
var plugin = new events.EventEmitter()
|
||||
@@ -65,7 +67,7 @@ module.exports = syrup.serial()
|
||||
function callService(intent) {
|
||||
var startServiceCmd = (sdk.level < 26) ? 'startservice' : 'start-foreground-service'
|
||||
log.info('using \'%s\' command for API %s', startServiceCmd, sdk.level)
|
||||
return adb.shell(options.serial, util.format(
|
||||
return deviceClient.shell(util.format(
|
||||
'am %s --user 0 %s'
|
||||
, startServiceCmd, intent
|
||||
))
|
||||
@@ -78,7 +80,7 @@ module.exports = syrup.serial()
|
||||
.timeout(10000)
|
||||
.then(function(line) {
|
||||
if (line.indexOf('--user') !== -1) {
|
||||
return adb.shell(options.serial, util.format(
|
||||
return deviceClient.shell(util.format(
|
||||
'am %s %s'
|
||||
, startServiceCmd, intent
|
||||
))
|
||||
@@ -277,7 +279,7 @@ module.exports = syrup.serial()
|
||||
.timeout(10000)
|
||||
})
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, util.format(
|
||||
return deviceClient.shell(util.format(
|
||||
"export CLASSPATH='%s'; exec app_process /system/bin '%s'"
|
||||
, apk.path
|
||||
, apk.main
|
||||
|
||||
Reference in New Issue
Block a user