Skip to content

Commit 2ef45ee

Browse files
author
Mykola Mokhnach
committed
Address review comments
1 parent 0777907 commit 2ef45ee

File tree

5 files changed

+29
-88
lines changed

5 files changed

+29
-88
lines changed

src/main/java/io/appium/java_client/ios/LocksIOSDevice.java renamed to src/main/java/io/appium/java_client/LocksDevice.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,38 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.appium.java_client.ios;
17+
package io.appium.java_client;
18+
19+
import java.time.Duration;
1820

1921
import static io.appium.java_client.MobileCommand.getIsDeviceLockedCommand;
2022
import static io.appium.java_client.MobileCommand.lockDeviceCommand;
2123
import static io.appium.java_client.MobileCommand.unlockDeviceCommand;
2224

23-
import io.appium.java_client.CommandExecutionHelper;
24-
import io.appium.java_client.ExecutesMethod;
25-
26-
import java.time.Duration;
25+
public interface LocksDevice extends ExecutesMethod {
26+
/**
27+
* Check if the device is locked.
28+
*
29+
* @deprecated Use {@link #isDeviceLocked()} instead
30+
* @return true if device is locked. False otherwise
31+
*/
32+
@Deprecated
33+
default boolean isLocked() {
34+
return CommandExecutionHelper.execute(this, getIsDeviceLockedCommand());
35+
}
2736

28-
public interface LocksIOSDevice extends ExecutesMethod {
37+
/**
38+
* This method locks a device. It will return silently if the device
39+
* is already locked.
40+
*/
41+
default void lockDevice() {
42+
lockDevice(Duration.ofSeconds(0));
43+
}
2944

3045
/**
3146
* Lock the device (bring it to the lock screen) for a given number of
3247
* seconds or forever (until the command for unlocking is called). The call
33-
* is ignored if the device already locked.
48+
* is ignored if the device has been already locked.
3449
*
3550
* @param duration for how long to lock the screen. Minimum time resolution is one second.
3651
* A negative/zero value will lock the device and return immediately.
@@ -40,19 +55,19 @@ default void lockDevice(Duration duration) {
4055
}
4156

4257
/**
43-
* Unlocks the device if it is locked or returns immediately if the device is already unlocked.
58+
* Unlock the device if it is locked. This method will return silently if the device
59+
* is not locked.
4460
*/
4561
default void unlockDevice() {
4662
CommandExecutionHelper.execute(this, unlockDeviceCommand());
4763
}
4864

4965
/**
50-
* Get the current state of the device.
66+
* Check if the device is locked.
5167
*
5268
* @return true if the device is locked or false otherwise.
5369
*/
5470
default boolean isDeviceLocked() {
5571
return CommandExecutionHelper.execute(this, getIsDeviceLockedCommand());
5672
}
57-
5873
}

src/main/java/io/appium/java_client/android/AndroidDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.appium.java_client.AppiumDriver;
2424
import io.appium.java_client.CommandExecutionHelper;
2525
import io.appium.java_client.FindsByAndroidUIAutomator;
26+
import io.appium.java_client.LocksDevice;
2627
import io.appium.java_client.PressesKeyCode;
2728
import io.appium.java_client.remote.MobilePlatform;
2829
import io.appium.java_client.service.local.AppiumDriverLocalService;
@@ -46,7 +47,7 @@
4647
public class AndroidDriver<T extends WebElement>
4748
extends AppiumDriver<T>
4849
implements PressesKeyCode, HasNetworkConnection, PushesFiles, StartsActivity,
49-
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasAndroidSettings, HasDeviceDetails,
50+
FindsByAndroidUIAutomator<T>, LocksDevice, HasAndroidSettings, HasDeviceDetails,
5051
HasSupportedPerformanceDataType, AuthenticatesByFinger {
5152

5253
private static final String ANDROID_PLATFORM = MobilePlatform.ANDROID;

src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ public class AndroidMobileCommandHelper extends MobileCommand {
172172
IS_KEYBOARD_SHOWN, ImmutableMap.<String, Object>of());
173173
}
174174

175-
/**
176-
* This method forms a {@link java.util.Map} of parameters for the
177-
* checking of the device state (is it locked or not).
178-
*
179-
* @return a key-value pair. The key is the command name. The value is a
180-
* {@link java.util.Map} command arguments.
181-
*/
182-
public static Map.Entry<String, Map<String, ?>> isLockedCommand() {
183-
return new AbstractMap.SimpleEntry<>(
184-
IS_LOCKED, ImmutableMap.<String, Object>of());
185-
}
186-
187175
/**
188176
* This method forms a {@link java.util.Map} of parameters for the
189177
* finger print authentication invocation.
@@ -284,18 +272,6 @@ public class AndroidMobileCommandHelper extends MobileCommand {
284272
return new AbstractMap.SimpleEntry<>(TOGGLE_LOCATION_SERVICES, ImmutableMap.<String, Object>of());
285273
}
286274

287-
/**
288-
* This method forms a {@link java.util.Map} of parameters for the
289-
* device unlocking.
290-
*
291-
* @return a key-value pair. The key is the command name. The value is a
292-
* {@link java.util.Map} command arguments.
293-
*/
294-
public static Map.Entry<String, Map<String, ?>> unlockCommand() {
295-
return new AbstractMap.SimpleEntry<>(UNLOCK, ImmutableMap.<String, Object>of());
296-
}
297-
298-
299275
/**
300276
* This method forms a {@link java.util.Map} of parameters for the element
301277
* value replacement. It is used against input elements

src/main/java/io/appium/java_client/android/LocksAndroidDevice.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/main/java/io/appium/java_client/ios/IOSDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.appium.java_client.FindsByIosNSPredicate;
2525
import io.appium.java_client.FindsByIosUIAutomation;
2626
import io.appium.java_client.HidesKeyboardWithKeyName;
27+
import io.appium.java_client.LocksDevice;
2728
import io.appium.java_client.remote.MobilePlatform;
2829
import io.appium.java_client.service.local.AppiumDriverLocalService;
2930
import io.appium.java_client.service.local.AppiumServiceBuilder;
@@ -51,7 +52,7 @@
5152
public class IOSDriver<T extends WebElement>
5253
extends AppiumDriver<T>
5354
implements HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings,
54-
FindsByIosUIAutomation<T>, LocksIOSDevice, PerformsTouchID, FindsByIosNSPredicate<T>,
55+
FindsByIosUIAutomation<T>, LocksDevice, PerformsTouchID, FindsByIosNSPredicate<T>,
5556
FindsByIosClassChain<T>, PushesFiles {
5657

5758
private static final String IOS_PLATFORM = MobilePlatform.IOS;

0 commit comments

Comments
 (0)