33import json
44import uuid
55from typing import Type , Any , Tuple , Dict , Union , List
6-
7- try :
8- # Python3.8+
9- from functools import cached_property
10- except ImportError :
11- from cached_property import cached_property
6+ from functools import cached_property # python3.8+
127
138from . import logger
149from .utils import delay
@@ -146,7 +141,7 @@ def screen_off(self):
146141 def unlock (self ):
147142 self .screen_on ()
148143 w , h = self .display_size
149- self .hdc . swipe (0.5 * w , 0.8 * h , 0.5 * w , 0.2 * h , speed = 600 )
144+ self .swipe (0.5 * w , 0.8 * h , 0.5 * w , 0.2 * h , speed = 6000 )
150145
151146 @cached_property
152147 def display_size (self ) -> Tuple [int , int ]:
@@ -268,7 +263,7 @@ def long_click(self, x: Union[int, float], y: Union[int, float]):
268263 self ._invoke (api , args = [point .x , point .y ])
269264
270265 @delay
271- def swipe (self , x1 , y1 , x2 , y2 , speed = 1000 ):
266+ def swipe (self , x1 , y1 , x2 , y2 , speed = 2000 ):
272267 """
273268 Perform a swipe action on the device screen.
274269
@@ -277,12 +272,18 @@ def swipe(self, x1, y1, x2, y2, speed=1000):
277272 y1 (float): The start Y coordinate as a percentage or absolute value.
278273 x2 (float): The end X coordinate as a percentage or absolute value.
279274 y2 (float): The end Y coordinate as a percentage or absolute value.
280- speed (int, optional): The swipe speed in pixels per second. Default is 1000 . Range: 200-40000. If not within the range, set to default value of 600 .
275+ speed (int, optional): The swipe speed in pixels per second. Default is 2000 . Range: 200-40000. If not within the range, set to default value of 2000 .
281276 """
277+
282278 point1 = self ._to_abs_pos (x1 , y1 )
283279 point2 = self ._to_abs_pos (x2 , y2 )
284280
285- self .hdc .swipe (point1 .x , point1 .y , point2 .x , point2 .y , speed = speed )
281+ if speed < 200 or speed > 40000 :
282+ logger .warning ("`speed` is not in the range[200-40000], Set to default value of 2000." )
283+ speed = 2000
284+
285+ api = "Driver.swipe"
286+ self ._invoke (api , args = [point1 .x , point1 .y , point2 .x , point2 .y , speed ])
286287
287288 @delay
288289 def input_text (self , x , y , text : str ):
0 commit comments