@@ -640,17 +640,32 @@ def end_test_coverage(self, intent, path):
640640 return self .execute (Command .END_TEST_COVERAGE , data )['value' ]
641641
642642 def lock (self , seconds ):
643- """Lock the device for a certain period of time. iOS only .
643+ """Lock the device. No changes are made if the device is already unlocked .
644644
645645 :Args:
646- - the duration to lock the device, in seconds
646+ - seconds - the duration to lock the device, in seconds.
647+ The device is going to be locked forever until `unlock` is called
648+ if it equals or is less than zero, otherwise this call blocks until
649+ the timeout expires and unlocks the screen automatically.
647650 """
648- data = {
649- 'seconds' : seconds ,
650- }
651- self .execute (Command .LOCK , data )
651+ self .execute (Command .LOCK , {'seconds' : seconds })
652652 return self
653653
654+ def unlock (self ):
655+ """Unlock the device. No changes are made if the device
656+ is already locked.
657+ """
658+ self .execute (Command .UNLOCK )
659+ return self
660+
661+ def is_locked (self ):
662+ """Checks whether the device is locked.
663+
664+ :returns:
665+ Either True or False
666+ """
667+ return self .execute (Command .IS_LOCKED )['value' ]
668+
654669 def shake (self ):
655670 """Shake the device.
656671 """
@@ -850,6 +865,10 @@ def _addCommands(self):
850865 ('POST' , '/session/$sessionId/appium/app/end_test_coverage' )
851866 self .command_executor ._commands [Command .LOCK ] = \
852867 ('POST' , '/session/$sessionId/appium/device/lock' )
868+ self .command_executor ._commands [Command .UNLOCK ] = \
869+ ('POST' , '/session/$sessionId/appium/device/unlock' )
870+ self .command_executor ._commands [Command .IS_LOCKED ] = \
871+ ('POST' , '/session/$sessionId/appium/device/is_locked' )
853872 self .command_executor ._commands [Command .SHAKE ] = \
854873 ('POST' , '/session/$sessionId/appium/device/shake' )
855874 self .command_executor ._commands [Command .TOUCH_ID ] = \
0 commit comments