feat: 新增oppo手动启动一次settings

This commit is contained in:
余泓铮
2024-06-21 11:57:36 +08:00
parent 30d4dcbaa2
commit 3094c3369b
4 changed files with 28 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v4/hrp/internal/code"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/json"
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
)
@@ -157,6 +158,20 @@ type AndroidDevice struct {
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"`
}
func (dev *AndroidDevice) Init() error {
brand, err := dev.d.Brand()
if err != nil {
return fmt.Errorf("failed to init android device. brand is null %v", err)
}
if strings.ToLower(brand) == "huawei" {
// 启动一次io.appium.settings。防止oppo设备上切换输入法失败
myexec.RunCommand("adb", "-s", dev.SerialNumber, "shell",
"monkey", "-p", "io.appium.settings", "-c", "android.intent.category.LAUNCHER", "1")
}
myexec.RunCommand("adb", "-s", dev.SerialNumber, "shell", "rm", "-r", env.DeviceActionLogFilePath)
return nil
}
func (dev *AndroidDevice) UUID() string {
return dev.SerialNumber
}

View File

@@ -468,6 +468,7 @@ func WithDriverPlugin(plugin funplugin.IPlugin) DriverOption {
// current implemeted device: IOSDevice, AndroidDevice
type Device interface {
Init() error // init android device
UUID() string // ios udid or android serial
LogEnabled() bool
NewDriver(...DriverOption) (driverExt *DriverExt, err error)

View File

@@ -295,6 +295,10 @@ type IOSDevice struct {
pcapFile string // saved pcap file path
}
func (dev *IOSDevice) Init() error {
return nil
}
func (dev *IOSDevice) UUID() string {
return dev.UDID
}