From 90358196ddf7d9e43565969909759544d80ed5dc Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Thu, 7 Nov 2024 20:17:08 +0800 Subject: [PATCH] change: init android device --- hrp/internal/version/VERSION | 2 +- hrp/pkg/server/context.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index ea4d6670..dd7a179d 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411051738 +v5.0.0+2411072017 diff --git a/hrp/pkg/server/context.go b/hrp/pkg/server/context.go index b5954564..2f6f6064 100644 --- a/hrp/pkg/server/context.go +++ b/hrp/pkg/server/context.go @@ -37,17 +37,23 @@ func handleDeviceContext() gin.HandlerFunc { case "android": device, err := uixt.NewAndroidDevice(uixt.WithSerialNumber(serial), uixt.WithStub(true)) if err != nil { - log.Error().Err(err).Str("platform", platform).Str("serial", serial).Msg(fmt.Sprintf("[%s]: Device Not Found", c.HandlerName())) - c.JSON(http.StatusBadRequest, HttpResponse{ - Code: code.GetErrorCode(err), - Message: err.Error(), - }) + log.Error().Err(err).Str("platform", platform).Str("serial", serial). + Msg("device not found") + c.JSON(http.StatusBadRequest, + HttpResponse{ + Code: code.GetErrorCode(err), + Message: err.Error(), + }, + ) c.Abort() return } + device.Init() + driver, err := device.NewDriver(uixt.WithDriverImageService(true), uixt.WithDriverResultFolder(true)) if err != nil { - log.Error().Err(err).Str("platform", platform).Str("serial", serial).Msg(fmt.Sprintf("[%s]: Failed New Driver", c.HandlerName())) + log.Error().Err(err).Str("platform", platform).Str("serial", serial). + Msg("failed to init driver") c.JSON(http.StatusInternalServerError, HttpResponse{ Code: code.GetErrorCode(err),