3
3
import json
4
4
import uuid
5
5
from 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+
12
7
13
8
from . import logger
14
9
from .utils import delay
@@ -146,7 +141,7 @@ def screen_off(self):
146
141
def unlock (self ):
147
142
self .screen_on ()
148
143
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 )
150
145
151
146
@cached_property
152
147
def display_size (self ) -> Tuple [int , int ]:
@@ -268,7 +263,7 @@ def long_click(self, x: Union[int, float], y: Union[int, float]):
268
263
self ._invoke (api , args = [point .x , point .y ])
269
264
270
265
@delay
271
- def swipe (self , x1 , y1 , x2 , y2 , speed = 1000 ):
266
+ def swipe (self , x1 , y1 , x2 , y2 , speed = 2000 ):
272
267
"""
273
268
Perform a swipe action on the device screen.
274
269
@@ -277,12 +272,18 @@ def swipe(self, x1, y1, x2, y2, speed=1000):
277
272
y1 (float): The start Y coordinate as a percentage or absolute value.
278
273
x2 (float): The end X coordinate as a percentage or absolute value.
279
274
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 .
281
276
"""
277
+
282
278
point1 = self ._to_abs_pos (x1 , y1 )
283
279
point2 = self ._to_abs_pos (x2 , y2 )
284
280
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 ])
286
287
287
288
@delay
288
289
def input_text (self , x , y , text : str ):
0 commit comments