diff --git a/hrp/pkg/uixt/android_adb_driver.go b/hrp/pkg/uixt/android_adb_driver.go index cec901b5..94686fe9 100644 --- a/hrp/pkg/uixt/android_adb_driver.go +++ b/hrp/pkg/uixt/android_adb_driver.go @@ -295,8 +295,21 @@ func (ad *adbDriver) DoubleTap(x, y int) error { } func (ad *adbDriver) DoubleTapFloat(x, y float64) (err error) { - err = errDriverNotImplemented - return + // adb shell input tap x y + xStr := fmt.Sprintf("%.1f", x) + yStr := fmt.Sprintf("%.1f", y) + _, err = ad.adbClient.RunShellCommand( + "input", "tap", xStr, yStr) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr)) + } + time.Sleep(time.Duration(100) * time.Millisecond) + _, err = ad.adbClient.RunShellCommand( + "input", "tap", xStr, yStr) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr)) + } + return nil } func (ad *adbDriver) TouchAndHold(x, y int, second ...float64) (err error) { diff --git a/hrp/pkg/uixt/android_device.go b/hrp/pkg/uixt/android_device.go index 87c54671..61e3bd5b 100644 --- a/hrp/pkg/uixt/android_device.go +++ b/hrp/pkg/uixt/android_device.go @@ -195,10 +195,6 @@ func (dev *AndroidDevice) Init() error { return nil } -func (dev *AndroidDevice) System() string { - return "android" -} - func (dev *AndroidDevice) UUID() string { return dev.SerialNumber } diff --git a/hrp/pkg/uixt/android_uia2_driver.go b/hrp/pkg/uixt/android_uia2_driver.go index c7d7056e..b5747fb5 100644 --- a/hrp/pkg/uixt/android_uia2_driver.go +++ b/hrp/pkg/uixt/android_uia2_driver.go @@ -286,6 +286,32 @@ func (ud *uiaDriver) Orientation() (orientation Orientation, err error) { return } +func (ud *uiaDriver) DoubleTap(x, y int) error { + return ud.DoubleFloatTap(float64(x), float64(y)) +} + +func (ud *uiaDriver) DoubleFloatTap(x, y float64) error { + data := map[string]interface{}{ + "actions": []interface{}{ + map[string]interface{}{ + "type": "pointer", + "parameters": map[string]string{"pointerType": "touch"}, + "id": "touch", + "actions": []interface{}{ + map[string]interface{}{"type": "pointerMove", "duration": 0, "x": x, "y": y, "origin": "viewport"}, + map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0}, + map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0}, + map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0}, + map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0}, + }, + }, + }, + } + + _, err := ud.httpPOST(data, "/session", ud.sessionId, "actions/tap") + return err +} + func (ud *uiaDriver) Tap(x, y int, options ...ActionOption) error { return ud.TapFloat(float64(x), float64(y), options...) } diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 8af4d8a7..0ff06cf3 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -457,9 +457,10 @@ func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) { } func (vc *VideoCrawler) getLivePreviewProb() float64 { - if vc.driverExt.Device.System() == "ios" { + if _, ok := vc.driverExt.Device.(*IOSDevice); ok { return 0.5326 - } else if vc.driverExt.Device.System() == "android" { + } + if _, ok := vc.driverExt.Device.(*AndroidDevice); ok { return 0.3414 } return -1