Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactivity check for physical devices with display timeout #3635

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions module/device/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,41 @@ def get_orientation(self):
logger.attr('Device Orientation', f'{o} ({Connection._orientation_description.get(o, "Unknown")})')
return o

@retry
def get_interactive(self):
"""
Makes sure device is interactive before starting tasks
"""
_INTERACTIVE_RE = re.compile(
r'mInteractive=(?P<interactive>.+)'
)
output = self.adb_shell(['dumpsys', 'input_method'])
Comment on lines +722 to +730
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


interactive = _INTERACTIVE_RE.search(output, 0)

result = True
if interactive:
o = interactive.group('interactive')
if o == "true":
pass
elif o == "false":
result = False
else:
logger.warning(f'Invalid device interactivity: {o}, assume it is normal')
else:
logger.warning('Unable to get device interactivity, assume it is normal')

logger.attr('Device interactive', {result})
return result

@retry
def wake(self):
"""
Attempts to wake device by pressing power button
"""
logger.info('Attempting to wake device')
self.adb_shell(['input', 'keyevent', 'KEYCODE_POWER'])

@retry
def list_device(self):
"""
Expand Down
6 changes: 6 additions & 0 deletions module/handler/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def _handle_app_login(self):
login_success = False

while 1:
# Make sure device is interactive
if not self.device.get_interactive():
self.device.wake()
self.device.sleep(1)
continue

# Watch device rotation
if not login_success and orientation_timer.reached():
# Screen may rotate after starting an app
Expand Down
4 changes: 4 additions & 0 deletions module/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def rotation_check():

timeout = Timer(10, count=20).start()
while 1:
if not self.device.get_interactive():
self.device.wake()
self.device.sleep(1)
continue
Comment on lines +147 to +150
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using sleep is forbidden

if skip_first_screenshot:
skip_first_screenshot = False
if not hasattr(self.device, "image") or self.device.image is None:
Expand Down