mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:23:28 +02:00
Add timeouts everywhere. Should help if the ADB socket gets stuck like it sometimes does.
This commit is contained in:
@@ -37,9 +37,11 @@ module.exports = syrup.serial()
|
||||
function openAgent() {
|
||||
log.info('Launching input agent')
|
||||
return stopAgent()
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return devutil.ensureUnusedPort(adb, options.serial, agent.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, util.format(
|
||||
"export CLASSPATH='%s'; exec app_process /system/bin '%s'"
|
||||
@@ -47,6 +49,7 @@ module.exports = syrup.serial()
|
||||
, apk.main
|
||||
))
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
lifecycle.share('InputAgent shell', out)
|
||||
streamutil.talk(log, 'InputAgent says: "%s"', out)
|
||||
@@ -54,6 +57,7 @@ module.exports = syrup.serial()
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, agent.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(conn) {
|
||||
agent.socket = conn
|
||||
agent.writer = new ms.DelimitingStream()
|
||||
@@ -76,22 +80,26 @@ module.exports = syrup.serial()
|
||||
'am startservice --user 0 %s'
|
||||
, intent
|
||||
))
|
||||
.timeout(15000)
|
||||
.then(function(out) {
|
||||
return streamutil.findLine(out, /^Error/)
|
||||
.finally(function() {
|
||||
out.end()
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(line) {
|
||||
if (line.indexOf('--user') !== -1) {
|
||||
return adb.shell(options.serial, util.format(
|
||||
'am startservice %s'
|
||||
, intent
|
||||
))
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return streamutil.findLine(out, /^Error/)
|
||||
.finally(function() {
|
||||
out.end()
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(line) {
|
||||
throw new Error(util.format(
|
||||
'Service had an error: "%s"'
|
||||
@@ -119,15 +127,18 @@ module.exports = syrup.serial()
|
||||
function openService() {
|
||||
log.info('Launching input service')
|
||||
return stopService()
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return devutil.waitForPortToFree(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return callService(util.format("-a '%s'", apk.startAction))
|
||||
})
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(15000)
|
||||
.then(function(conn) {
|
||||
service.socket = conn
|
||||
service.reader = conn.pipe(new ms.DelimitedStream())
|
||||
@@ -159,6 +170,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.VERSION
|
||||
, new apk.serviceProto.VersionRequest()
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.VersionResponse.decode(data)
|
||||
if (response.success) {
|
||||
@@ -173,6 +185,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_KEYGUARD_STATE
|
||||
, new apk.serviceProto.SetKeyguardStateRequest(false)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetKeyguardStateResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -186,6 +199,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_KEYGUARD_STATE
|
||||
, new apk.serviceProto.SetKeyguardStateRequest(true)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetKeyguardStateResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -199,6 +213,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_WAKE_LOCK
|
||||
, new apk.serviceProto.SetWakeLockRequest(true)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetWakeLockResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -212,6 +227,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_WAKE_LOCK
|
||||
, new apk.serviceProto.SetWakeLockRequest(false)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetWakeLockResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -225,6 +241,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.IDENTIFY
|
||||
, new apk.serviceProto.IdentifyRequest(options.serial)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.IdentifyResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -241,6 +258,7 @@ module.exports = syrup.serial()
|
||||
, text
|
||||
)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetClipboardResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -256,6 +274,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.ClipboardType.TEXT
|
||||
)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.GetClipboardResponse.decode(data)
|
||||
if (response.success) {
|
||||
@@ -273,6 +292,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.GET_BROWSERS
|
||||
, new apk.serviceProto.GetBrowsersRequest()
|
||||
)
|
||||
.timeout(15000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.GetBrowsersResponse.decode(data)
|
||||
if (response.success) {
|
||||
|
||||
Reference in New Issue
Block a user