diff --git a/devlib/target.py b/devlib/target.py index fdef1bd..ae2d559 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -2213,6 +2213,11 @@ class AndroidTarget(Target): def reboot_bootloader(self, timeout=30): self.conn.reboot_bootloader() + @asyn.asyncf + async def is_screen_locked(self): + screen_state = await self.execute.asyn('dumpsys window') + return 'mDreamingLockscreen=true' in screen_state + @asyn.asyncf async def is_screen_on(self): output = await self.execute.asyn('dumpsys power') diff --git a/doc/target.rst b/doc/target.rst index 17b2bbd..ad641b1 100644 --- a/doc/target.rst +++ b/doc/target.rst @@ -747,10 +747,15 @@ Android Target .. method:: AndroidTarget.is_screen_on() - Returns ``True`` if the targets screen is currently on and ``False`` + Returns ``True`` if the target's screen is currently on and ``False`` otherwise. If the display is in a "Doze" mode or similar always on state, this will return ``True``. +.. method:: AndroidTarget.is_screen_locked() + + Returns ``True`` if the target's screen is currently locked and ``False`` + otherwise. + .. method:: AndroidTarget.wait_for_device(timeout=30) Returns when the devices becomes available withing the given timeout