diff --git a/cmd/deploy.go b/cmd/deploy.go index 2502d1f..3238417 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -230,7 +230,24 @@ var deployCmd = &cobra.Command{ for i := 0; i <= 120; i++ { if i == 120 { ofoxSpinner.Stop() - logger.Error("Recovery device timeout") + logger.Warn("Recovery device timeout") + logger.Info("Trying to restart adb server") + err := adbc.KillServer(); + if err != nil { + logger.Error("Failed to kill server") + os.Exit(173); + } + err = adbc.StartServer(); + if err != nil { + logger.Error("Failed to start server") + os.Exit(173); + } + adbd = adbc.Device(adb.DeviceWithSerial(serail)); + if s, _ := adbd.State(); s == adb.StateRecovery { + logger.Info("Device found") + break + } + logger.Error("Device not found") os.Exit(173) } if s, _ := adbd.State(); s == adb.StateRecovery { @@ -276,7 +293,24 @@ var deployCmd = &cobra.Command{ for i := 0; i <= 120; i++ { if i == 120 { ofoxSpinner.Stop() - logger.Error("Recovery device timeout") + logger.Warn("Recovery device timeout") + logger.Info("Trying to restart adb server") + err := adbc.KillServer(); + if err != nil { + logger.Error("Failed to kill server") + os.Exit(173); + } + err = adbc.StartServer(); + if err != nil { + logger.Error("Failed to start server") + os.Exit(173); + } + adbd = adbc.Device(adb.DeviceWithSerial(serail)); + if s, _ := adbd.State(); s == adb.StateRecovery { + logger.Info("Device found") + break + } + logger.Error("Device not found") os.Exit(173) } if s, _ := adbd.State(); s == adb.StateRecovery { @@ -284,7 +318,8 @@ var deployCmd = &cobra.Command{ break } time.Sleep(time.Second) - } + } + port, err := utils.GetFreePort() if err != nil {