Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 753
Expand file tree
/
Copy pathMobileCommand.java
More file actions
Latest commit
632 lines (582 loc) · 27.8 KB
/
Copy pathMobileCommand.java
File metadata and controls
632 lines (582 loc) · 27.8 KB
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
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
packageio.appium.java_client;
importcom.google.common.collect.ImmutableMap;
importio.appium.java_client.imagecomparison.BaseComparisonOptions;
importio.appium.java_client.imagecomparison.ComparisonMode;
importio.appium.java_client.screenrecording.BaseStartScreenRecordingOptions;
importio.appium.java_client.screenrecording.BaseStopScreenRecordingOptions;
importorg.jspecify.annotations.Nullable;
importorg.openqa.selenium.remote.CommandInfo;
importorg.openqa.selenium.remote.http.HttpMethod;
importjava.nio.charset.StandardCharsets;
importjava.time.Duration;
importjava.util.Collections;
importjava.util.HashMap;
importjava.util.Map;
importjava.util.Optional;
importstaticcom.google.common.base.Strings.isNullOrEmpty;
/**
* The repository of mobile commands defined in the Mobile JSON
* wire protocol.
* Most of these commands are platform-specific obsolete things and should eventually be replaced with
* calls to corresponding `mobile:` extensions, so we don't abuse non-w3c APIs
*/
@SuppressWarnings({"checkstyle:HideUtilityClassConstructor", "checkstyle:ConstantName"})
publicclassMobileCommand {
//General
@Deprecated
protectedstaticfinalStringRESET;
@Deprecated
protectedstaticfinalStringGET_STRINGS;
@Deprecated
publicstaticfinalStringSET_VALUE;
@Deprecated
protectedstaticfinalStringPULL_FILE;
@Deprecated
protectedstaticfinalStringPULL_FOLDER;
@Deprecated
publicstaticfinalStringRUN_APP_IN_BACKGROUND;
@Deprecated
protectedstaticfinalStringPERFORM_TOUCH_ACTION;
@Deprecated
protectedstaticfinalStringPERFORM_MULTI_TOUCH;
@Deprecated
publicstaticfinalStringLAUNCH_APP;
@Deprecated
publicstaticfinalStringCLOSE_APP;
@Deprecated
protectedstaticfinalStringGET_DEVICE_TIME;
@Deprecated
protectedstaticfinalStringGET_SESSION;
protectedstaticfinalStringLOG_EVENT;
protectedstaticfinalStringGET_EVENTS;
//region Applications Management
@Deprecated
protectedstaticfinalStringIS_APP_INSTALLED;
@Deprecated
protectedstaticfinalStringINSTALL_APP;
@Deprecated
protectedstaticfinalStringACTIVATE_APP;
@Deprecated
protectedstaticfinalStringQUERY_APP_STATE;
@Deprecated
protectedstaticfinalStringTERMINATE_APP;
@Deprecated
protectedstaticfinalStringREMOVE_APP;
//endregion
//region Clipboard
@Deprecated
publicstaticfinalStringGET_CLIPBOARD;
@Deprecated
publicstaticfinalStringSET_CLIPBOARD;
//endregion
@Deprecated
protectedstaticfinalStringGET_PERFORMANCE_DATA;
@Deprecated
protectedstaticfinalStringGET_SUPPORTED_PERFORMANCE_DATA_TYPES;
@Deprecated
publicstaticfinalStringSTART_RECORDING_SCREEN;
@Deprecated
publicstaticfinalStringSTOP_RECORDING_SCREEN;
@Deprecated
protectedstaticfinalStringHIDE_KEYBOARD;
@Deprecated
protectedstaticfinalStringLOCK;
//iOS
@Deprecated
protectedstaticfinalStringSHAKE;
@Deprecated
protectedstaticfinalStringTOUCH_ID;
@Deprecated
protectedstaticfinalStringTOUCH_ID_ENROLLMENT;
//Android
@Deprecated
publicstaticfinalStringCURRENT_ACTIVITY;
@Deprecated
protectedstaticfinalStringEND_TEST_COVERAGE;
@Deprecated
protectedstaticfinalStringGET_DISPLAY_DENSITY;
@Deprecated
protectedstaticfinalStringGET_NETWORK_CONNECTION;
@Deprecated
protectedstaticfinalStringGET_SYSTEM_BARS;
@Deprecated
protectedstaticfinalStringIS_KEYBOARD_SHOWN;
@Deprecated
protectedstaticfinalStringIS_LOCKED;
@Deprecated
publicstaticfinalStringLONG_PRESS_KEY_CODE;
@Deprecated
protectedstaticfinalStringFINGER_PRINT;
@Deprecated
protectedstaticfinalStringOPEN_NOTIFICATIONS;
@Deprecated
publicstaticfinalStringPRESS_KEY_CODE;
@Deprecated
protectedstaticfinalStringPUSH_FILE;
@Deprecated
protectedstaticfinalStringSET_NETWORK_CONNECTION;
@Deprecated
protectedstaticfinalStringSTART_ACTIVITY;
@Deprecated
protectedstaticfinalStringTOGGLE_LOCATION_SERVICES;
@Deprecated
protectedstaticfinalStringUNLOCK;
@Deprecated
publicstaticfinalStringREPLACE_VALUE;
protectedstaticfinalStringGET_SETTINGS;
@Deprecated
protectedstaticfinalStringSET_SETTINGS;
@Deprecated
publicstaticfinalStringGET_CURRENT_PACKAGE;
@Deprecated
publicstaticfinalStringSEND_SMS;
@Deprecated
publicstaticfinalStringGSM_CALL;
@Deprecated
publicstaticfinalStringGSM_SIGNAL;
@Deprecated
publicstaticfinalStringGSM_VOICE;
@Deprecated
publicstaticfinalStringNETWORK_SPEED;
@Deprecated
publicstaticfinalStringPOWER_CAPACITY;
@Deprecated
publicstaticfinalStringPOWER_AC_STATE;
@Deprecated
protectedstaticfinalStringTOGGLE_WIFI;
@Deprecated
protectedstaticfinalStringTOGGLE_AIRPLANE_MODE;
@Deprecated
protectedstaticfinalStringTOGGLE_DATA;
protectedstaticfinalStringCOMPARE_IMAGES;
protectedstaticfinalStringEXECUTE_DRIVER_SCRIPT;
@Deprecated
protectedstaticfinalStringGET_ALLSESSION;
protectedstaticfinalStringEXECUTE_GOOGLE_CDP_COMMAND;
publicstaticfinalStringGET_SCREEN_ORIENTATION = "getScreenOrientation";
publicstaticfinalStringSET_SCREEN_ORIENTATION = "setScreenOrientation";
publicstaticfinalStringGET_SCREEN_ROTATION = "getScreenRotation";
publicstaticfinalStringSET_SCREEN_ROTATION = "setScreenRotation";
publicstaticfinalStringGET_CONTEXT_HANDLES = "getContextHandles";
publicstaticfinalStringGET_CURRENT_CONTEXT_HANDLE = "getCurrentContextHandle";
publicstaticfinalStringSWITCH_TO_CONTEXT = "switchToContext";
publicstaticfinalStringGET_LOCATION = "getLocation";
publicstaticfinalStringSET_LOCATION = "setLocation";
publicstaticfinalMap<String, CommandInfo> commandRepository;
static {
RESET = "reset";
GET_STRINGS = "getStrings";
SET_VALUE = "setValue";
PULL_FILE = "pullFile";
PULL_FOLDER = "pullFolder";
RUN_APP_IN_BACKGROUND = "runAppInBackground";
PERFORM_TOUCH_ACTION = "performTouchAction";
PERFORM_MULTI_TOUCH = "performMultiTouch";
LAUNCH_APP = "launchApp";
CLOSE_APP = "closeApp";
GET_DEVICE_TIME = "getDeviceTime";
GET_SESSION = "getSession";
LOG_EVENT = "logCustomEvent";
GET_EVENTS = "getLogEvents";
//region Applications Management
IS_APP_INSTALLED = "isAppInstalled";
QUERY_APP_STATE = "queryAppState";
TERMINATE_APP = "terminateApp";
ACTIVATE_APP = "activateApp";
REMOVE_APP = "removeApp";
INSTALL_APP = "installApp";
//endregion
//region Clipboard
SET_CLIPBOARD = "setClipboard";
GET_CLIPBOARD = "getClipboard";
//endregion
GET_PERFORMANCE_DATA = "getPerformanceData";
GET_SUPPORTED_PERFORMANCE_DATA_TYPES = "getSuppportedPerformanceDataTypes";
START_RECORDING_SCREEN = "startRecordingScreen";
STOP_RECORDING_SCREEN = "stopRecordingScreen";
HIDE_KEYBOARD = "hideKeyboard";
LOCK = "lock";
SHAKE = "shake";
TOUCH_ID = "touchId";
TOUCH_ID_ENROLLMENT = "toggleEnrollTouchId";
CURRENT_ACTIVITY = "currentActivity";
END_TEST_COVERAGE = "endTestCoverage";
GET_DISPLAY_DENSITY = "getDisplayDensity";
GET_NETWORK_CONNECTION = "getNetworkConnection";
GET_SYSTEM_BARS = "getSystemBars";
IS_KEYBOARD_SHOWN = "isKeyboardShown";
IS_LOCKED = "isLocked";
LONG_PRESS_KEY_CODE = "longPressKeyCode";
FINGER_PRINT = "fingerPrint";
OPEN_NOTIFICATIONS = "openNotifications";
PRESS_KEY_CODE = "pressKeyCode";
PUSH_FILE = "pushFile";
SET_NETWORK_CONNECTION = "setNetworkConnection";
START_ACTIVITY = "startActivity";
TOGGLE_LOCATION_SERVICES = "toggleLocationServices";
UNLOCK = "unlock";
REPLACE_VALUE = "replaceValue";
GET_SETTINGS = "getSettings";
SET_SETTINGS = "setSettings";
GET_CURRENT_PACKAGE = "getCurrentPackage";
SEND_SMS = "sendSMS";
GSM_CALL = "gsmCall";
GSM_SIGNAL = "gsmSignal";
GSM_VOICE = "gsmVoice";
NETWORK_SPEED = "networkSpeed";
POWER_CAPACITY = "powerCapacity";
POWER_AC_STATE = "powerAC";
TOGGLE_WIFI = "toggleWiFi";
TOGGLE_AIRPLANE_MODE = "toggleFlightMode";
TOGGLE_DATA = "toggleData";
COMPARE_IMAGES = "compareImages";
EXECUTE_DRIVER_SCRIPT = "executeDriverScript";
GET_ALLSESSION = "getAllSessions";
EXECUTE_GOOGLE_CDP_COMMAND = "executeCdp";
commandRepository = newHashMap<>();
commandRepository.put(RESET, postC("/session/:sessionId/appium/app/reset"));
commandRepository.put(GET_STRINGS, postC("/session/:sessionId/appium/app/strings"));
commandRepository.put(SET_VALUE, postC("/session/:sessionId/appium/element/:id/value"));
commandRepository.put(PULL_FILE, postC("/session/:sessionId/appium/device/pull_file"));
commandRepository.put(PULL_FOLDER, postC("/session/:sessionId/appium/device/pull_folder"));
commandRepository.put(HIDE_KEYBOARD, postC("/session/:sessionId/appium/device/hide_keyboard"));
commandRepository.put(RUN_APP_IN_BACKGROUND, postC("/session/:sessionId/appium/app/background"));
commandRepository.put(PERFORM_TOUCH_ACTION, postC("/session/:sessionId/touch/perform"));
commandRepository.put(PERFORM_MULTI_TOUCH, postC("/session/:sessionId/touch/multi/perform"));
commandRepository.put(LAUNCH_APP, postC("/session/:sessionId/appium/app/launch"));
commandRepository.put(CLOSE_APP, postC("/session/:sessionId/appium/app/close"));
commandRepository.put(LOCK, postC("/session/:sessionId/appium/device/lock"));
commandRepository.put(GET_SETTINGS, getC("/session/:sessionId/appium/settings"));
commandRepository.put(SET_SETTINGS, postC("/session/:sessionId/appium/settings"));
commandRepository.put(GET_DEVICE_TIME, getC("/session/:sessionId/appium/device/system_time"));
commandRepository.put(GET_SESSION, getC("/session/:sessionId/"));
commandRepository.put(GET_SUPPORTED_PERFORMANCE_DATA_TYPES,
postC("/session/:sessionId/appium/performanceData/types"));
commandRepository.put(GET_PERFORMANCE_DATA,
postC("/session/:sessionId/appium/getPerformanceData"));
commandRepository.put(START_RECORDING_SCREEN,
postC("/session/:sessionId/appium/start_recording_screen"));
commandRepository.put(STOP_RECORDING_SCREEN,
postC("/session/:sessionId/appium/stop_recording_screen"));
commandRepository.put(GET_EVENTS,
postC("/session/:sessionId/appium/events"));
commandRepository.put(LOG_EVENT,
postC("/session/:sessionId/appium/log_event"));
//region Applications Management
commandRepository.put(IS_APP_INSTALLED, postC("/session/:sessionId/appium/device/app_installed"));
commandRepository.put(INSTALL_APP, postC("/session/:sessionId/appium/device/install_app"));
commandRepository.put(ACTIVATE_APP, postC("/session/:sessionId/appium/device/activate_app"));
commandRepository.put(REMOVE_APP, postC("/session/:sessionId/appium/device/remove_app"));
commandRepository.put(TERMINATE_APP, postC("/session/:sessionId/appium/device/terminate_app"));
commandRepository.put(QUERY_APP_STATE, postC("/session/:sessionId/appium/device/app_state"));
//endregion
//region Clipboard
commandRepository.put(GET_CLIPBOARD, postC("/session/:sessionId/appium/device/get_clipboard"));
commandRepository.put(SET_CLIPBOARD, postC("/session/:sessionId/appium/device/set_clipboard"));
//endregion
//iOS
commandRepository.put(SHAKE, postC("/session/:sessionId/appium/device/shake"));
commandRepository.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id"));
commandRepository.put(TOUCH_ID_ENROLLMENT,
postC("/session/:sessionId/appium/simulator/toggle_touch_id_enrollment"));
//Android
commandRepository.put(CURRENT_ACTIVITY,
getC("/session/:sessionId/appium/device/current_activity"));
commandRepository.put(END_TEST_COVERAGE,
postC("/session/:sessionId/appium/app/end_test_coverage"));
commandRepository.put(GET_DISPLAY_DENSITY, getC("/session/:sessionId/appium/device/display_density"));
commandRepository.put(GET_NETWORK_CONNECTION, getC("/session/:sessionId/network_connection"));
commandRepository.put(GET_SYSTEM_BARS, getC("/session/:sessionId/appium/device/system_bars"));
commandRepository.put(IS_KEYBOARD_SHOWN, getC("/session/:sessionId/appium/device/is_keyboard_shown"));
commandRepository.put(IS_LOCKED, postC("/session/:sessionId/appium/device/is_locked"));
commandRepository.put(LONG_PRESS_KEY_CODE,
postC("/session/:sessionId/appium/device/long_press_keycode"));
commandRepository.put(FINGER_PRINT, postC("/session/:sessionId/appium/device/finger_print"));
commandRepository.put(OPEN_NOTIFICATIONS,
postC("/session/:sessionId/appium/device/open_notifications"));
commandRepository.put(PRESS_KEY_CODE,
postC("/session/:sessionId/appium/device/press_keycode"));
commandRepository.put(PUSH_FILE, postC("/session/:sessionId/appium/device/push_file"));
commandRepository.put(SET_NETWORK_CONNECTION,
postC("/session/:sessionId/network_connection"));
commandRepository.put(START_ACTIVITY,
postC("/session/:sessionId/appium/device/start_activity"));
commandRepository.put(TOGGLE_LOCATION_SERVICES,
postC("/session/:sessionId/appium/device/toggle_location_services"));
commandRepository.put(UNLOCK, postC("/session/:sessionId/appium/device/unlock"));
commandRepository.put(REPLACE_VALUE, postC("/session/:sessionId/appium/element/:id/replace_value"));
commandRepository.put(GET_CURRENT_PACKAGE, getC("/session/:sessionId/appium/device/current_package"));
commandRepository.put(SEND_SMS, postC("/session/:sessionId/appium/device/send_sms"));
commandRepository.put(GSM_CALL, postC("/session/:sessionId/appium/device/gsm_call"));
commandRepository.put(GSM_SIGNAL, postC("/session/:sessionId/appium/device/gsm_signal"));
commandRepository.put(GSM_VOICE, postC("/session/:sessionId/appium/device/gsm_voice"));
commandRepository.put(NETWORK_SPEED, postC("/session/:sessionId/appium/device/network_speed"));
commandRepository.put(POWER_CAPACITY, postC("/session/:sessionId/appium/device/power_capacity"));
commandRepository.put(POWER_AC_STATE, postC("/session/:sessionId/appium/device/power_ac"));
commandRepository.put(TOGGLE_WIFI, postC("/session/:sessionId/appium/device/toggle_wifi"));
commandRepository.put(TOGGLE_AIRPLANE_MODE, postC("/session/:sessionId/appium/device/toggle_airplane_mode"));
commandRepository.put(TOGGLE_DATA, postC("/session/:sessionId/appium/device/toggle_data"));
commandRepository.put(COMPARE_IMAGES, postC("/session/:sessionId/appium/compare_images"));
commandRepository.put(EXECUTE_DRIVER_SCRIPT, postC("/session/:sessionId/appium/execute_driver"));
commandRepository.put(GET_ALLSESSION, getC("/sessions"));
commandRepository.put(EXECUTE_GOOGLE_CDP_COMMAND, postC("/session/:sessionId/goog/cdp/execute"));
commandRepository.put(GET_SCREEN_ORIENTATION, getC("/session/:sessionId/orientation"));
commandRepository.put(SET_SCREEN_ORIENTATION, postC("/session/:sessionId/orientation"));
commandRepository.put(GET_SCREEN_ROTATION, getC("/session/:sessionId/rotation"));
commandRepository.put(SET_SCREEN_ROTATION, postC("/session/:sessionId/rotation"));
commandRepository.put(GET_CONTEXT_HANDLES, getC("/session/:sessionId/contexts"));
commandRepository.put(GET_CURRENT_CONTEXT_HANDLE, getC("/session/:sessionId/context"));
commandRepository.put(SWITCH_TO_CONTEXT, postC("/session/:sessionId/context"));
commandRepository.put(GET_LOCATION, getC("/session/:sessionId/location"));
commandRepository.put(SET_LOCATION, postC("/session/:sessionId/location"));
}
/**
* This methods forms GET commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
publicstaticAppiumCommandInfogetC(Stringurl) {
returnnewAppiumCommandInfo(url, HttpMethod.GET);
}
/**
* This methods forms POST commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
publicstaticAppiumCommandInfopostC(Stringurl) {
returnnewAppiumCommandInfo(url, HttpMethod.POST);
}
/**
* This methods forms DELETE commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
publicstaticAppiumCommandInfodeleteC(Stringurl) {
returnnewAppiumCommandInfo(url, HttpMethod.DELETE);
}
/**
* This method forms a {@link Map} of parameters for the keyboard hiding.
*
* @param keyName The button pressed by the mobile driver to attempt hiding the
* keyboard.
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> hideKeyboardCommand(StringkeyName) {
returnMap.entry(HIDE_KEYBOARD, Map.of("keyName", keyName));
}
/**
* This method forms a {@link Map} of parameters for the keyboard hiding.
*
* @param strategy HideKeyboardStrategy.
* @param keyName a String, representing the text displayed on the button of the
* keyboard you want to press. For example: "Done".
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> hideKeyboardCommand(Stringstrategy,
StringkeyName) {
returnMap.entry(HIDE_KEYBOARD, Map.of(
"strategy", strategy,
"key", keyName
));
}
/**
* Prepares single argument.
*
* @param param is a parameter name.
* @param value is the parameter value.
* @return built {@link ImmutableMap}.
* @deprecated Use {@link Map#of(Object, Object)}
*/
@Deprecated
publicstaticImmutableMap<String, Object> prepareArguments(Stringparam,
Objectvalue) {
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
builder.put(param, value);
returnbuilder.build();
}
/**
* Prepares collection of arguments.
*
* @param params is the array with parameter names.
* @param values is the array with parameter values.
* @return built {@link ImmutableMap}.
* @deprecated Use {@link Map#of(Object, Object, Object, Object)}
*/
@Deprecated
publicstaticImmutableMap<String, Object> prepareArguments(String[] params,
Object[] values) {
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
for (inti = 0; i < params.length; i++) {
if (!isNullOrEmpty(params[i]) && values[i] != null) {
builder.put(params[i], values[i]);
}
}
returnbuilder.build();
}
/**
* This method forms a {@link Map} of parameters for the key event invocation.
*
* @param key code for the key pressed on the device.
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> pressKeyCodeCommand(intkey) {
returnMap.entry(PRESS_KEY_CODE, Map.of("keycode", key));
}
/**
* This method forms a {@link Map} of parameters for the key event invocation.
*
* @param key code for the key pressed on the Android device.
* @param metastate metastate for the keypress.
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> pressKeyCodeCommand(intkey,
Integermetastate) {
returnMap.entry(PRESS_KEY_CODE, Map.of(
"keycode", key,
"metastate", metastate
));
}
/**
* This method forms a {@link Map} of parameters for the long key event invocation.
*
* @param key code for the long key pressed on the device.
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> longPressKeyCodeCommand(intkey) {
returnMap.entry(LONG_PRESS_KEY_CODE, Map.of("keycode", key));
}
/**
* This method forms a {@link Map} of parameters for the long key event invocation.
*
* @param key code for the long key pressed on the Android device.
* @param metastate metastate for the long key press.
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> longPressKeyCodeCommand(intkey,
Integermetastate) {
returnMap.entry(LONG_PRESS_KEY_CODE, Map.of(
"keycode", key,
"metastate", metastate
));
}
/**
* This method forms a {@link Map} of parameters for the device locking.
*
* @param duration for how long to lock the screen for. Minimum time resolution is one second
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> lockDeviceCommand(Durationduration) {
returnMap.entry(LOCK, Map.of("seconds", duration.getSeconds()));
}
/**
* This method forms a {@link Map} of parameters for the device unlocking.
*
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> unlockDeviceCommand() {
returnMap.entry(UNLOCK, Map.of());
}
/**
* This method forms a {@link Map} of parameters for the device locked query.
*
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> getIsDeviceLockedCommand() {
returnMap.entry(IS_LOCKED, Map.of());
}
publicstaticMap.Entry<String, Map<String, ?>> getSettingsCommand() {
returnMap.entry(GET_SETTINGS, Map.of());
}
publicstaticMap.Entry<String, Map<String, ?>> setSettingsCommand(Stringsetting, Objectvalue) {
returnsetSettingsCommand(Map.of(setting, value));
}
publicstaticMap.Entry<String, Map<String, ?>> setSettingsCommand(Map<String, Object> settings) {
returnMap.entry(SET_SETTINGS, Map.of("settings", settings));
}
/**
* This method forms a {@link Map} of parameters for the file pushing.
*
* @param remotePath Path to file to write data to on remote device
* @param base64Data Base64 encoded byte array of data to write to remote device
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> pushFileCommand(StringremotePath, byte[] base64Data) {
returnMap.entry(PUSH_FILE, Map.of(
"path", remotePath,
"data", newString(base64Data, StandardCharsets.UTF_8)
));
}
publicstaticMap.Entry<String, Map<String, ?>> startRecordingScreenCommand(BaseStartScreenRecordingOptionsopts) {
returnMap.entry(START_RECORDING_SCREEN, Map.of("options", opts.build()));
}
publicstaticMap.Entry<String, Map<String, ?>> stopRecordingScreenCommand(BaseStopScreenRecordingOptionsopts) {
returnMap.entry(STOP_RECORDING_SCREEN, Map.of("options", opts.build()));
}
/**
* Forms a {@link Map} of parameters for images comparison.
*
* @param mode one of possible comparison modes
* @param img1Data base64-encoded data of the first image
* @param img2Data base64-encoded data of the second image
* @param options comparison options
* @return key-value pairs
*/
publicstaticMap.Entry<String, Map<String, ?>> compareImagesCommand(ComparisonModemode,
byte[] img1Data, byte[] img2Data,
@NullableBaseComparisonOptionsoptions) {
varargs = newHashMap<String, Object>();
args.put("mode", mode.toString());
args.put("firstImage", newString(img1Data, StandardCharsets.UTF_8));
args.put("secondImage", newString(img2Data, StandardCharsets.UTF_8));
Optional.ofNullable(options).ifPresent(opts -> args.put("options", options.build()));
returnMap.entry(COMPARE_IMAGES, Collections.unmodifiableMap(args));
}
/**
* This method forms a {@link Map} of parameters for the checking of the keyboard state (is it shown or not).
*
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
* @deprecated This helper is deprecated and will be removed in future versions.
*/
@Deprecated
publicstaticMap.Entry<String, Map<String, ?>> isKeyboardShownCommand() {
returnMap.entry(IS_KEYBOARD_SHOWN, Map.of());
}
}