From f6d49495e0030fc55ea0b281cbcf96db5b7e91af Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Tue, 10 Dec 2024 10:27:16 +0800 Subject: [PATCH] fix: replace adb with gadb shell command --- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/android_adb_driver.go | 3 +-- hrp/pkg/uixt/android_device.go | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index cf95d97a..50619079 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2412081512 +v5.0.0+2412101027 diff --git a/hrp/pkg/uixt/android_adb_driver.go b/hrp/pkg/uixt/android_adb_driver.go index 50a5cdc2..45939eee 100644 --- a/hrp/pkg/uixt/android_adb_driver.go +++ b/hrp/pkg/uixt/android_adb_driver.go @@ -17,7 +17,6 @@ import ( "syscall" "time" - "github.com/httprunner/funplugin/myexec" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -797,7 +796,7 @@ func (ad *adbDriver) StopCaptureLog() (result interface{}, err error) { log.Info().Msg("action log is null, use action file >>>") logFilePathPrefix := fmt.Sprintf("%v/data", config.ActionLogFilePath) files := []string{} - myexec.RunCommand("adb", "-s", ad.adbClient.Serial(), "pull", config.DeviceActionLogFilePath, config.ActionLogFilePath) + ad.adbClient.RunShellCommand("pull", config.DeviceActionLogFilePath, config.ActionLogFilePath) err = filepath.Walk(config.ActionLogFilePath, func(path string, info fs.FileInfo, err error) error { // 只是需要日志文件 if ok := strings.Contains(path, logFilePathPrefix); ok { diff --git a/hrp/pkg/uixt/android_device.go b/hrp/pkg/uixt/android_device.go index 571a6060..dcfdc4eb 100644 --- a/hrp/pkg/uixt/android_device.go +++ b/hrp/pkg/uixt/android_device.go @@ -362,7 +362,8 @@ func (dev *AndroidDevice) StopPcap() string { } func (dev *AndroidDevice) Uninstall(packageName string) error { - return myexec.RunCommand("adb", "-s", dev.SerialNumber, "uninstall", packageName) + _, err := dev.d.RunShellCommand("uninstall", packageName) + return err } func (dev *AndroidDevice) Install(apkPath string, options ...InstallOption) error { @@ -689,6 +690,7 @@ func (l *AdbLogcat) CatchLogcat(filter string) (err error) { return nil } + // FIXME: replace with gadb shell command // clear logcat if err = myexec.RunCommand("adb", "-s", l.serial, "shell", "logcat", "-c"); err != nil { return