fix: increase the number of reconnection attempts when the UiAutomator connection is disconnected

This commit is contained in:
徐聪
2025-05-03 20:34:12 +08:00
parent 032a130418
commit 37fd2e900d

View File

@@ -584,7 +584,7 @@ func (ud *UIA2Driver) Source(srcOpt ...option.SourceOption) (source string, err
}
func (ud *UIA2Driver) startUIA2Server() error {
const maxRetries = 3
const maxRetries = 20
for attempt := 1; attempt <= maxRetries; attempt++ {
log.Info().Str("package", ud.Device.Options.UIA2ServerTestPackageName).
Int("attempt", attempt).Msg("start uiautomator server")
@@ -594,7 +594,7 @@ func (ud *UIA2Driver) startUIA2Server() error {
out, err := ud.Device.RunShellCommand("am", "instrument", "-w",
ud.Device.Options.UIA2ServerTestPackageName)
if err != nil {
return errors.Wrap(err, "start uiautomator server failed")
log.Error().Err(err).Int("retryCount", maxRetries).Msg("start uiautomator server failed, retrying...")
}
if strings.Contains(out, "Process crashed") {
log.Error().Msg("uiautomator server crashed, retrying...")