-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
1496 lines (1391 loc) · 60.5 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from .commandos import (
modulecfg,
get_simple_click_command_echo_e_n,
UniversalADBExecutor,
get_simple_click_command_printf,
get_long_click_command_echo_e_n,
get_long_click_command_printf,
get_swipe_command_from_many_points_printf,
get_swipe_command_from_many_points_echo_e_n,
get_n_coordinates_from_circle,
get_n_coordinates_from_rectangle,
get_n_coordinates_from_ellipse,
get_n_coordinates_from_polygon,
get_n_coordinates_from_circle,
get_swipe_command_from_2_coordinates_echo_e_n,
get_swipe_command_from_2_coordinates_printf,
get_swipe_command_from_a_couple_of_coordinates_printf,
get_swipe_command_from_a_couple_of_coordinates_echo_e_n,
get_drag_and_drop_command_printf,
get_drag_and_drop_command_echo_e_n,
)
from typing import Literal
class CodeExec:
def __init__(
self,
executer,
init_cmd,
main_cmd,
) -> None:
self.init_cmd = init_cmd
self.main_cmd = main_cmd
self.init_cmd_str = (
init_cmd.decode("utf-8", "backslashreplace")
if init_cmd and isinstance(init_cmd, bytes)
else init_cmd
if isinstance(init_cmd, str)
else "intital command not needed"
)[:300] + "..."
self.main_cmd_str = (
main_cmd.decode("utf-8", "backslashreplace")
if main_cmd and isinstance(main_cmd, bytes)
else main_cmd
if isinstance(main_cmd, str)
else "intital command not needed"
)[:300]
self.executer = executer
if not init_cmd:
self.inital_command_success = True
else:
self.inital_command_success = False
def __repr__(self) -> str:
return f"INITAL COMMAND:\n{self.init_cmd_str}\n\n\nMAIN COMMAND:\n{self.main_cmd_str}"
def __str__(self) -> str:
return self.__repr__()
def __call__(self, **kwargs):
if not self.inital_command_success:
self.run_init_command()
self.run_main_command()
return self
def run_init_command(self, **kwargs):
self.executer.shell_without_capturing_stdout_and_stderr(self.init_cmd, **kwargs)
self.inital_command_success = True
return self
def run_main_command(self, **kwargs):
self.executer.shell_without_capturing_stdout_and_stderr(self.main_cmd, **kwargs)
return self
class SendEventOnRoids:
r"""
This module provides tools for handling advanced commands for simulating user inputs on Android devices.
It includes two main classes:
1. CodeExec: Executes shell commands on the Android device via adb.
2. SendEventOnRoids: Handles advanced gestures and command sequences such as taps, swipes, and drags using adb commands.
Classes:
CodeExec: Manages and executes a single adb command.
SendEventOnRoids: Facilitates the creation of complex adb command sequences.
"""
def __init__(
self,
adb_path=None,
device_serial=None,
input_device="/dev/input/event4",
x_max=None,
y_max=None,
screen_width=None,
screen_height=None,
number_of_finish_commands=2,
su_exe="su",
blocksize=72,
prefered_execution: Literal["exec", "eval"] = "exec",
chunk_size=1024,
) -> None:
r"""
Initializes an instance of SendEventOnRoids, setting up the Android Debug Bridge (ADB) environment
for executing touch and swipe commands on a connected Android device.
Args:
adb_path (str, optional): The full path to the adb executable. If None, it will assume adb is in the system path.
device_serial (str, optional): The serial number of the target Android device. If None, ADB commands will target the only connected device.
input_device (str, optional): The device file for the input device in the Android filesystem. Defaults to '/dev/input/event4', commonly used for touchscreen inputs.
x_max (int, optional): The maximum x-coordinate for the device's touchscreen. Needed for coordinate scaling.
y_max (int, optional): The maximum y-coordinate for the device's touchscreen. Needed for coordinate scaling.
screen_width (int, optional): The actual screen width in pixels of the Android device.
screen_height (int, optional): The actual screen height in pixels of the Android device.
number_of_finish_commands (int, optional): The number of 'finish' commands (zero bytes) to send after executing touch or swipe actions. This helps ensure that all actions are registered correctly on the device.
su_exe (str, optional): The command to execute 'superuser' actions, always needed. Defaults to 'su'.
blocksize (int, optional): The size of each block of data sent in a command, this controls the speed of the command, ajust it in steps of 72.
prefered_execution (str, optional): Preferred method of executing the ADB commands, can be 'exec' (default) or 'eval' (slower) for evaluating expressions.
chunk_size (int, optional): The size of data chunks processed at one time during execution, relevant when handling large sets of commands or data (swipes).
Example:
start_on_device = False
if start_on_device: # you can do that if you installed python as root on your device -> https://github.com/hansalemaos/termuxfree
device_serial = None
input_device = "/dev/input/event4"
adb_path = None
android_automation = SendEventOnRoids(
adb_path=adb_path,
device_serial=device_serial,
input_device=input_device,
x_max=32767,
y_max=32767,
screen_width=900,
screen_height=1600,
number_of_finish_commands=2,
su_exe="/system/xbin/su",
blocksize=72,
prefered_execution="exec",
chunk_size=1024,
)
else: # via adb
adb_path = shutil.which("adb")
device_serial = "127.0.0.1:5645"
input_device = "/dev/input/event4"
android_automation = SendEventOnRoids(
adb_path=adb_path,
device_serial=device_serial,
input_device=input_device,
x_max=None,
y_max=None,
screen_width=None,
screen_height=None,
number_of_finish_commands=2,
su_exe="/system/xbin/su",
blocksize=72,
prefered_execution="exec",
chunk_size=1024,
)
"""
self.adb_path = adb_path
self.device_serial = device_serial
self.input_device = input_device
self.x_max = x_max
self.y_max = y_max
self.screen_width = screen_width
self.screen_height = screen_height
self.randomize_data = False
self.number_of_finish_commands = number_of_finish_commands
self.su_exe = su_exe
self.blocksize = blocksize
self.prefered_execution = prefered_execution
self.chunk_size = chunk_size
if all(
[device_serial, input_device, x_max, y_max, screen_width, screen_height]
):
modulecfg.cache_screen_size_dict[(device_serial, input_device)] = {
"x_max": x_max,
"y_max": y_max,
"screen_width": screen_width,
"screen_height": screen_height,
}
self.adb_shell = UniversalADBExecutor(self.adb_path, self.device_serial)
def echo_input_tap(self, x, y, input_device=None, number_of_finish_commands=2):
r"""
Simulates a tap on the Android device at a specified (x, y) coordinate using echo commands
Args:
x (int): X-coordinate where the tap will occur.
y (int): Y-coordinate where the tap will occur.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): How many times the command should finalize (sending zero bytes). Defaults to 2.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
input_tap_echo = self.echo_input_tap(
x=300,
y=400,
input_device=None,
number_of_finish_commands=2,
)
input_tap_echo()
"""
clickcmd = get_simple_click_command_echo_e_n(
x=int(x),
y=int(y),
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
su_exe=self.su_exe,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=b"",
main_cmd=clickcmd,
)
def printf_input_tap(self, x, y, input_device=None, number_of_finish_commands=2):
r"""
Simulates a tap on the Android device at a specified (x, y) coordinate using printf commands.
Args:
x (int): X-coordinate where the tap will occur.
y (int): Y-coordinate where the tap will occur.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): How many times the command should finalize (sending zero bytes). Defaults to 2.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
input_tap_printf = self.printf_input_tap(
x=600,
y=200,
input_device=None,
number_of_finish_commands=2,
)
input_tap_printf()
"""
clickcmd = get_simple_click_command_printf(
x=int(x),
y=int(y),
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
su_exe=self.su_exe,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=b"",
main_cmd=clickcmd,
)
def echo_long_input_tap(
self,
x,
y,
duration=2,
input_device=None,
number_of_finish_commands=2,
):
r"""
Simulates a long tap on the Android device at a specified (x, y) coordinate using echo commands
Args:
x (int): X-coordinate where the long tap will occur.
y (int): Y-coordinate where the long tap will occur.
duration (int): Duration of the long tap in seconds. Defaults to 2 seconds.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): How many times the command should finalize (sending zero bytes). Defaults to 2.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
long_input_tap_echo = self.echo_long_input_tap(
x=100,
y=400,
duration=2,
input_device=None,
number_of_finish_commands=2,
)
long_input_tap_echo()
"""
clickcmd = get_long_click_command_echo_e_n(
x=int(x),
y=int(y),
duration=duration,
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
su_exe=self.su_exe,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=b"",
main_cmd=clickcmd,
)
def printf_long_input_tap(
self,
x,
y,
duration=2,
input_device=None,
number_of_finish_commands=2,
):
r"""
Simulates a long tap on the Android device at a specified (x, y) coordinate using printf commands via adb.
Args:
x (int): X-coordinate where the long tap will occur.
y (int): Y-coordinate where the long tap will occur.
duration (int): Duration of the long tap in seconds. Defaults to 2 seconds.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): How many times the command should finalize (sending zero bytes). Defaults to 2.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
long_input_tap_printf = self.printf_long_input_tap(
x=600,
y=600,
duration=2,
input_device=None,
number_of_finish_commands=2,
)
long_input_tap_printf()
"""
clickcmd = get_long_click_command_printf(
x=int(x),
y=int(y),
duration=duration,
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
su_exe=self.su_exe,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=b"",
main_cmd=clickcmd,
)
def printf_swipe_through_continuous_coordinates(
self,
coordinates,
output_path="/sdcard/printf_swipe_through_continuous_coordinates.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Executes a swipe through a sequence of continuous coordinates using printf commands.
Args:
coordinates (list of tuple): List of (x, y) coordinates to swipe through.
output_path (str): Path on the device to store the swipe command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each swipe. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
printf_swipe_through_continuous_coordinates = (
self.printf_swipe_through_continuous_coordinates(
coordinates=circle_coords,
output_path="/sdcard/printf_swipe_through_continuous_coordinates.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 10,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
)
printf_swipe_through_continuous_coordinates()
"""
(
executable_swipe_command_with_printf,
executable_swipe_command_with_printf_after_copy,
) = get_swipe_command_from_many_points_printf(
x_y_coordinates=coordinates,
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
output_path=output_path,
su_exe=self.su_exe,
blocksize=blocksize or self.blocksize,
sleepbetweencommand=sleep_between_each_pixel,
exec_or_eval=exec_or_eval or self.prefered_execution,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=executable_swipe_command_with_printf,
main_cmd=executable_swipe_command_with_printf_after_copy,
)
def echo_swipe_through_continuous_coordinates(
self,
coordinates,
output_path="/sdcard/echo_swipe_through_continuous_coordinates.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Executes a swipe through a sequence of continuous coordinates using echo commands.
Args:
coordinates (list of tuple): List of (x, y) coordinates to swipe through.
output_path (str): Path on the device to store the swipe command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each swipe. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
echo_swipe_through_continuous_coordinates = (
self.echo_swipe_through_continuous_coordinates(
coordinates=circle_coords,
output_path="/sdcard/echo_swipe_through_continuous_coordinates.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 10,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
)
echo_swipe_through_continuous_coordinates()
"""
(
executable_swipe_command_with_echo,
executable_swipe_command_with_echo_after_copy,
) = get_swipe_command_from_many_points_echo_e_n(
x_y_coordinates=coordinates,
device_serial=self.device_serial,
inputdev=input_device or self.input_device,
adb_path=self.adb_path,
x_max=self.x_max,
y_max=self.y_max,
screen_width=self.screen_width,
screen_height=self.screen_height,
randomize_data=False,
number_of_finish_commands=number_of_finish_commands,
output_path=output_path,
su_exe=self.su_exe,
blocksize=blocksize or self.blocksize,
sleepbetweencommand=sleep_between_each_pixel,
exec_or_eval=exec_or_eval or self.prefered_execution,
)
return CodeExec(
executer=self.adb_shell,
init_cmd=executable_swipe_command_with_echo,
main_cmd=executable_swipe_command_with_echo_after_copy,
)
def echo_brute_force_swipe_rectangle_area(
self,
x,
y,
width,
height,
numer_of_coordinates=100,
output_path="/sdcard/echo_brute_force_swipe_rectangle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe across a rectangular area, generating numerous coordinates within the rectangle and executing echo commands for each.
Args:
x, y (int): Top-left corner of the rectangle.
width, height (int): Dimensions of the rectangle.
numer_of_coordinates (int): Number of coordinates to generate within the rectangle for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.echo_brute_force_swipe_rectangle_area(
x=20,
y=20,
width=100,
height=300,
numer_of_coordinates=30,
output_path="/sdcard/echo_brute_force_swipe_rectangle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_rectangle(
x=int(x),
y=int(y),
width=int(width),
height=int(height),
numer_of_coordinates=int(numer_of_coordinates),
)
return self.echo_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def printf_brute_force_swipe_rectangle_area(
self,
x,
y,
width,
height,
numer_of_coordinates=100,
output_path="/sdcard/printf_brute_force_swipe_rectangle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe across a rectangular area, generating numerous coordinates within the rectangle and executing printf commands for each.
Args:
x, y (int): Top-left corner of the rectangle.
width, height (int): Dimensions of the rectangle.
numer_of_coordinates (int): Number of coordinates to generate within the rectangle for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.printf_brute_force_swipe_rectangle_area(
x=20,
y=20,
width=100,
height=300,
numer_of_coordinates=30,
output_path="/sdcard/printf_brute_force_swipe_rectangle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_rectangle(
x=int(x),
y=int(y),
width=int(width),
height=int(height),
numer_of_coordinates=int(numer_of_coordinates),
)
return self.printf_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def echo_brute_force_swipe_ellipse_area(
self,
x_center,
y_center,
rx,
ry,
numer_of_coordinates=100,
output_path="/sdcard/echo_brute_force_swipe_ellipse_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe across an elliptical area by generating numerous coordinates within the ellipse and executing echo commands for each.
Args:
x_center, y_center (int): Center coordinates of the ellipse.
rx, ry (int): Radii of the ellipse along the x and y axes.
numer_of_coordinates (int): Number of coordinates to generate within the ellipse for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.echo_brute_force_swipe_ellipse_area(
x_center=200,
y_center=400,
rx=100,
ry=50,
numer_of_coordinates=30,
output_path="/sdcard/echo_brute_force_swipe_ellipse_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_ellipse(
x_center=int(x_center),
y_center=int(y_center),
rx=int(rx),
ry=int(ry),
numer_of_coordinates=int(numer_of_coordinates),
)
return self.echo_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def printf_brute_force_swipe_ellipse_area(
self,
x_center,
y_center,
rx,
ry,
numer_of_coordinates=100,
output_path="/sdcard/printf_brute_force_swipe_ellipse_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe across an elliptical area by generating numerous coordinates within the ellipse and executing printf commands for each.
Args:
x_center, y_center (int): Center coordinates of the ellipse.
rx, ry (int): Radii of the ellipse along the x and y axes.
numer_of_coordinates (int): Number of coordinates to generate within the ellipse for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.printf_brute_force_swipe_ellipse_area(
x_center=200,
y_center=400,
rx=100,
ry=50,
numer_of_coordinates=30,
output_path="/sdcard/printf_brute_force_swipe_ellipse_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_ellipse(
x_center=int(x_center),
y_center=int(y_center),
rx=int(rx),
ry=int(ry),
numer_of_coordinates=int(numer_of_coordinates),
)
return self.printf_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def echo_brute_force_swipe_polygon_area(
self,
vertices,
numer_of_coordinates=100,
output_path="/sdcard/echo_brute_force_swipe_polygon_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe over a polygonal area by generating multiple coordinates along the edges defined by the given vertices using echo commands.
Args:
vertices (list of tuple): List of (x, y) tuples defining the vertices of the polygon.
numer_of_coordinates (int): Number of coordinates to generate along the polygon for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.echo_brute_force_swipe_polygon_area(
vertices=[
(350, 100),
(450, 450),
(150, 400),
(100, 200),
(350, 100),
(200, 300),
(350, 350),
(300, 200),
(200, 300),
],
numer_of_coordinates=30,
output_path="/sdcard/echo_brute_force_swipe_polygon_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_polygon(
vertices=vertices,
numer_of_coordinates=numer_of_coordinates,
)
return self.echo_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def printf_brute_force_swipe_polygon_area(
self,
vertices,
numer_of_coordinates=100,
output_path="/sdcard/printf_brute_force_swipe_polygon_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe over a polygonal area by generating multiple coordinates along the edges defined by the given vertices using printf commands.
Args:
vertices (list of tuple): List of (x, y) tuples defining the vertices of the polygon.
numer_of_coordinates (int): Number of coordinates to generate along the polygon for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.printf_brute_force_swipe_polygon_area(
vertices=[
(350, 100),
(450, 450),
(150, 400),
(100, 200),
(350, 100),
(200, 300),
(350, 350),
(300, 200),
(200, 300),
],
numer_of_coordinates=30,
output_path="/sdcard/printf_brute_force_swipe_polygon_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_polygon(
vertices=vertices,
numer_of_coordinates=int(numer_of_coordinates),
)
return self.printf_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def echo_brute_force_swipe_circle_area(
self,
x,
y,
radius,
numer_of_coordinates=100,
output_path="/sdcard/echo_brute_force_swipe_circle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe over a circular area by generating multiple coordinates along the circumference of the circle using echo commands.
Args:
x, y (int): Center coordinates of the circle.
radius (int): Radius of the circle.
numer_of_coordinates (int): Number of coordinates to generate along the circle for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.echo_brute_force_swipe_circle_area(
x=500,
y=500,
radius=150,
numer_of_coordinates=30,
output_path="/sdcard/echo_brute_force_swipe_circle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_circle(
x=int(x),
y=int(y),
radius=int(radius),
numer_of_coordinates=numer_of_coordinates,
)
return self.echo_swipe_through_continuous_coordinates(
coordinates=line_coords,
output_path=output_path,
input_device=input_device,
number_of_finish_commands=number_of_finish_commands,
blocksize=blocksize,
exec_or_eval=exec_or_eval,
sleep_between_each_pixel=sleep_between_each_pixel,
)
def printf_brute_force_swipe_circle_area(
self,
x,
y,
radius,
numer_of_coordinates=100,
output_path="/sdcard/printf_brute_force_swipe_circle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=None,
exec_or_eval=None,
sleep_between_each_pixel=0,
):
r"""
Simulates a swipe over a circular area by generating multiple coordinates along the circumference of the circle using printf commands.
Args:
x, y (int): Center coordinates of the circle.
radius (int): Radius of the circle.
numer_of_coordinates (int): Number of coordinates to generate along the circle for swiping.
output_path (str): Path on the device to store the command data.
input_device (str, optional): The input device path in the Android system. Defaults to class attribute.
number_of_finish_commands (int): Number of times to finalize the command.
blocksize (int, optional): Size of data blocks to write in each action. Defaults to class attribute.
exec_or_eval (str, optional): Execution method, can be 'exec' or 'eval'. Defaults to class attribute.
sleep_between_each_pixel (int, optional): Sleep duration in seconds between swipe actions.
Returns:
CodeExec: An executable command object ready to be executed.
Example:
exampledata = self.printf_brute_force_swipe_circle_area(
x=500,
y=500,
radius=150,
numer_of_coordinates=30,
output_path="/sdcard/printf_brute_force_swipe_circle_area.bin",
input_device=None,
number_of_finish_commands=2,
blocksize=72 * 8,
exec_or_eval=None,
sleep_between_each_pixel=0,
)
exampledata()
"""
line_coords = get_n_coordinates_from_circle(