Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA-15737 Get the market name from the device #59

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ STF consists of multiple independent processes communicating via [ZeroMQ](http:/

Each unit and its function will be explained later in the document.

Market name(on UI) for device take from device's settings(if vendor's market name reachable by command `settings get global device_name`), if you would like to have other market name just change settings.

## Assumptions

For this example deployment, the following assumptions will be made. You will need to adjust them as you see fit. Note that this deployment was designed to be relatively easy to set up without external tools, and may not be optimal. They're also configured so that you can run everything on a single host if required.
Expand Down
21 changes: 11 additions & 10 deletions lib/units/device/plugins/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default syrup.serial()
.dependency(push)
.dependency(sdk)
.dependency(service)
.define(async function(options, adb, router, push, sdk, apk) {
.dependency(devutil)
.define(async function(options, adb, router, push, sdk, apk, devutil) {
var log = logger.createLogger('device:plugins:service')
var messageResolver = new MessageResolver()
var plugin = new events.EventEmitter()
Expand All @@ -51,7 +52,7 @@ export default syrup.serial()
, sock: 'localabstract:stfservice'
}
function stopAgent() {
return devutil.killProcsByComm(adb, options.serial, 'stf.agent', 'stf.agent')
return devutil.killProcsByComm('stf.agent', 'stf.agent')
}
function callService(intent) {
var startServiceCmd = (sdk.level < 26) ? 'startservice' : 'start-foreground-service'
Expand Down Expand Up @@ -174,7 +175,7 @@ export default syrup.serial()
log.info('Launching service')
return callService(util.format("-a '%s' -n '%s'", apk.startIntent.action, apk.startIntent.component))
.then(function() {
return devutil.waitForLocalSocket(adb, options.serial, service.sock)
return devutil.waitForLocalSocket(service.sock)
})
.then(function(conn) {
service.socket = conn
Expand All @@ -185,9 +186,9 @@ export default syrup.serial()
return prepareForServiceDeath(conn)
})
.then(function() {
devutil.executeShellCommand(adb, options.serial, 'settings put system screen_brightness 0')
devutil.executeShellCommand(adb, options.serial, 'settings put system screen_brightness_mode 0')
devutil.executeShellCommand(adb, options.serial, 'input keyevent 26')
devutil.executeShellCommand('settings put system screen_brightness 0')
devutil.executeShellCommand('settings put system screen_brightness_mode 0')
devutil.executeShellCommand('input keyevent 26')
})
}
function prepareForAgentDeath(conn) {
Expand All @@ -213,10 +214,10 @@ export default syrup.serial()
async function openAgent() {
log.info('Launching agent')
await stopAgent()
await devutil.ensureUnusedLocalSocket(adb, options.serial, agent.sock)
await devutil.ensureUnusedLocalSocket(agent.sock)
const out = await adb.getDevice(options.serial).shell(util.format("CLASSPATH='%s' exec app_process /system/bin '%s'", apk.path, apk.main))
streamutil.talk(log, 'Agent says: "%s"', out)
const conn = await devutil.waitForLocalSocket(adb, options.serial, agent.sock)
const conn = await devutil.waitForLocalSocket(agent.sock)
agent.socket = conn
agent.writer = new ms.DelimitingStream()
agent.writer.pipe(conn)
Expand All @@ -229,7 +230,7 @@ export default syrup.serial()
return runAgentCommand(apk.wire.MessageType.DO_KEYEVENT, new apk.wire.KeyEventRequest(data))
}
plugin.type = function(text) {
devutil.executeShellCommand(adb, options.serial, "am broadcast -a ADB_INPUT_TEXT --es msg '" + text + "'")
devutil.executeShellCommand("am broadcast -a ADB_INPUT_TEXT --es msg '" + text + "'")
}
plugin.paste = function(text) {
return plugin.setClipboard(text)
Expand Down Expand Up @@ -544,7 +545,7 @@ export default syrup.serial()
}
plugin.sendCommand = function(command) {
log.info('Executing shell command ' + command + ' on ' + options.serial)
devutil.executeShellCommand(adb, options.serial, command)
devutil.executeShellCommand(command)
}
plugin.setBluetoothEnabled = function(enabled) {
return runServiceCommand(apk.wire.MessageType.SET_BLUETOOTH_ENABLED, new apk.wire.SetBluetoothEnabledRequest(enabled))
Expand Down
11 changes: 6 additions & 5 deletions lib/units/device/plugins/util/identity.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import syrup from '@devicefarmer/stf-syrup'
import devutil from '../../../../util/devutil.js'
import logger from '../../../../util/logger.js'
import properties from '../../support/properties.js'
import display from './display.js'
import phone from './phone.js'
export default syrup.serial()
.dependency(properties)
.dependency(display)
.dependency(phone)
.define(function(options, properties, display, phone) {
.dependency(devutil)
.define(function(options, display, phone, devutil) {
var log = logger.createLogger('device:plugins:identity')
function solve() {

async function solve() {
log.info('Solving identity')
let identity = devutil.makeIdentity(options.serial, properties)
let identity = await devutil.makeIdentity()
identity.display = display.properties
identity.phone = phone
if (options.deviceName) {
identity.module = options.deviceName
}
return identity
}

return solve()
})
7 changes: 3 additions & 4 deletions lib/units/device/resources/minicap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import devutil from '../../../util/devutil.js'
import * as streamutil from '../../../util/streamutil.js'
import Resource from './util/resource.js'
import adb from '../support/adb.js'
import properties from '../support/properties.js'
import abi from '../support/abi.js'
import sdk from '../support/sdk.js'
export default syrup.serial()
.dependency(adb)
.dependency(properties)
.dependency(abi)
.dependency(sdk)
.define(function(options, adb, properties, abi, sdk) {
.dependency(devutil)
.define(function(options, adb, abi, sdk, devutil) {
let log = logger.createLogger('device:resources:minicap')
let resources = {
bin: new Resource({
Expand Down Expand Up @@ -92,7 +91,7 @@ export default syrup.serial()
return Promise.all(resourcesToBeinstalled)
}
function stop() {
return devutil.killProcsByComm(adb, options.serial, resources.bin.comm, resources.bin.dest)
return devutil.killProcsByComm(resources.bin.comm, resources.bin.dest)
}
return stop()
.then(installAll)
Expand Down
7 changes: 3 additions & 4 deletions lib/units/device/resources/minirev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import devutil from '../../../util/devutil.js'
import * as streamutil from '../../../util/streamutil.js'
import Resource from './util/resource.js'
import adb from '../support/adb.js'
import properties from '../support/properties.js'
import abi from '../support/abi.js'
export default syrup.serial()
.dependency(adb)
.dependency(properties)
.dependency(abi)
.define(function(options, adb, properties, abi) {
.dependency(devutil)
.define(function(options, adb, abi, devutil) {
var log = logger.createLogger('device:resources:minirev')
var resources = {
bin: new Resource({
Expand Down Expand Up @@ -61,7 +60,7 @@ export default syrup.serial()
])
}
function stop() {
return devutil.killProcsByComm(adb, options.serial, resources.bin.comm, resources.bin.dest)
return devutil.killProcsByComm(resources.bin.comm, resources.bin.dest)
}
return stop()
.then(installAll)
Expand Down
5 changes: 3 additions & 2 deletions lib/units/device/resources/minitouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import abi from '../support/abi.js'
export default syrup.serial()
.dependency(adb)
.dependency(abi)
.define(function(options, adb, abi) {
.dependency(devutil)
.define(function(options, adb, abi, devutil) {
var log = logger.createLogger('device:resources:minitouch')
var resources = {
bin: new Resource({
Expand Down Expand Up @@ -59,7 +60,7 @@ export default syrup.serial()
])
}
function stop() {
return devutil.killProcsByComm(adb, options.serial, resources.bin.comm, resources.bin.dest)
return devutil.killProcsByComm(resources.bin.comm, resources.bin.dest)
}
return stop()
.then(installAll)
Expand Down
Loading