1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target: Add helper function to check Android screen's locking state

Introduce is_screen_locked() which returns true if device screen is
locked and false otherwise.

This will be useful to automate unlocking the screen [1].

Also fix a typo in is_screen_on()'s documentation.

[1] https://github.com/ARM-software/workload-automation/pull/1246

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
This commit is contained in:
Metin Kaya 2024-01-08 09:05:06 +00:00 committed by Marc Bonnici
parent 07294251c8
commit 14b4e2069b
2 changed files with 11 additions and 1 deletions

View File

@ -2213,6 +2213,11 @@ class AndroidTarget(Target):
def reboot_bootloader(self, timeout=30): def reboot_bootloader(self, timeout=30):
self.conn.reboot_bootloader() 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 @asyn.asyncf
async def is_screen_on(self): async def is_screen_on(self):
output = await self.execute.asyn('dumpsys power') output = await self.execute.asyn('dumpsys power')

View File

@ -747,10 +747,15 @@ Android Target
.. method:: AndroidTarget.is_screen_on() .. 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, otherwise. If the display is in a "Doze" mode or similar always on state,
this will return ``True``. 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) .. method:: AndroidTarget.wait_for_device(timeout=30)
Returns when the devices becomes available withing the given timeout Returns when the devices becomes available withing the given timeout