-
Notifications
You must be signed in to change notification settings - Fork 839
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
base: master
Are you sure you want to change the base?
Conversation
I think this is a niche requirement. Besides, your implementation may encounter the following two issues:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Implement in both ADB and uiautomator2, wrap in
Device
class - Abstract function to wake device
get_interactive
should only be called when a pure black screenshot is received- No interactive check on emulators
if not self.device.get_interactive(): | ||
self.device.wake() | ||
self.device.sleep(1) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sleep is forbidden
@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']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there! I recently started running ALAS on a cheap android tablet with a 1 minute display timeout to save energy. I also have it configured to close the game on tasks completion.
However, after ALAS goes to idle and closes the game, it would always fail with logs that look like this and a pure black screenshot:
This seems to be because the device went to sleep, so I added a new function to check for device interactivity (which is set to false when display is off), and used it in the ui_get_current_page and handle_app_login loops to wake the device if not interactive.
I've been running with these changes for the past week and it hasn't required any manual interventions yet. I've defaulted the result of the function to true in the case where we can't find the expected adb outputs to keep behavior identical for older devices and emulators, but I haven't actually tested on an emulator yet since I don't have one set up. Would appreciate some help with this from folks that run ALAS on emulators!
I'm a bit of a python noob, so there might be some mistakes in here. Happy to update this as you see fit. Thanks!