Fix adb invocations (#202)

This commit is contained in:
Karol Wrótniak
2021-03-10 14:50:33 +01:00
committed by GitHub
parent 50ee38c2ce
commit 5dfdd9ac63
18 changed files with 79 additions and 43 deletions

View File

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