mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Use 'ps -lef' instead of 'ps' to list Pids on Android 8.x
This commit is contained in:
parent
2dac3d1bbd
commit
fa50c56bb9
1 changed files with 42 additions and 22 deletions
|
@ -5,6 +5,8 @@ var Promise = require('bluebird')
|
||||||
|
|
||||||
var devutil = module.exports = Object.create(null)
|
var devutil = module.exports = Object.create(null)
|
||||||
|
|
||||||
|
var commands = Object.create(null)
|
||||||
|
|
||||||
function closedError(err) {
|
function closedError(err) {
|
||||||
return err.message.indexOf('closed') !== -1
|
return err.message.indexOf('closed') !== -1
|
||||||
}
|
}
|
||||||
|
@ -39,28 +41,46 @@ devutil.listPidsByComm = function(adb, serial, comm, bin) {
|
||||||
shell: true
|
shell: true
|
||||||
}
|
}
|
||||||
|
|
||||||
return adb.shell(serial, ['ps'])
|
return new Promise(function(resolve) {
|
||||||
.then(function(out) {
|
if ('ps' in commands) {
|
||||||
return new Promise(function(resolve) {
|
resolve(commands)
|
||||||
var header = true
|
} else {
|
||||||
var pids = []
|
adb.getProperties(serial)
|
||||||
out.pipe(split())
|
.then(function (properties) {
|
||||||
.on('data', function(chunk) {
|
version = properties['ro.build.version.release']
|
||||||
if (header) {
|
if (version.match(/^8\./) != null) {
|
||||||
header = false
|
commands['ps'] = 'ps -lef'
|
||||||
}
|
} else {
|
||||||
else {
|
commands['ps'] = 'ps'
|
||||||
var cols = chunk.toString().split(/\s+/)
|
}
|
||||||
if (cols.pop() === bin && users[cols[0]]) {
|
resolve(commands)
|
||||||
pids.push(Number(cols[1]))
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
.then(function (commands) {
|
||||||
.on('end', function() {
|
return adb.shell(serial, [commands['ps']])
|
||||||
resolve(pids)
|
.then(function (out) {
|
||||||
})
|
return new Promise(function (resolve) {
|
||||||
})
|
var header = true
|
||||||
})
|
var pids = []
|
||||||
|
out.pipe(split())
|
||||||
|
.on('data', function (chunk) {
|
||||||
|
if (header) {
|
||||||
|
header = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var cols = chunk.toString().split(/\s+/)
|
||||||
|
if (cols.pop() === bin && users[cols[0]]) {
|
||||||
|
pids.push(Number(cols[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('end', function () {
|
||||||
|
resolve(pids)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
devutil.waitForProcsToDie = function(adb, serial, comm, bin) {
|
devutil.waitForProcsToDie = function(adb, serial, comm, bin) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue