mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Wake up and unlock device when it's being used. A bit messy, pending refactor.
This commit is contained in:
parent
999e5113bf
commit
a25df0b293
6 changed files with 183 additions and 20 deletions
|
@ -91,6 +91,36 @@ devutil.waitForPort = function(adb, serial, port) {
|
|||
})
|
||||
}
|
||||
|
||||
devutil.waitForPortToFree = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
.then(function(conn) {
|
||||
var resolver = Promise.defer()
|
||||
|
||||
function endListener() {
|
||||
resolver.resolve(port)
|
||||
}
|
||||
|
||||
function errorListener(err) {
|
||||
resolver.reject(err)
|
||||
}
|
||||
|
||||
conn.on('end', endListener)
|
||||
conn.on('error', errorListener)
|
||||
|
||||
return resolver.promise.finally(function() {
|
||||
conn.removeListener('end', endListener)
|
||||
conn.removeListener('error', errorListener)
|
||||
conn.end()
|
||||
})
|
||||
})
|
||||
.catch(closedError, function(err) {
|
||||
return port
|
||||
})
|
||||
}
|
||||
|
||||
devutil.listPidsByComm = function(adb, serial, comm, bin) {
|
||||
var users = {
|
||||
shell: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue