With Java Android API `AccessibilityServiceInstance.getWindows()` does not return `scrcpy` virtual display window, why?
Apr 4, 11:37pm

The reason AccessibilityService.getWindows() does not return the scrcpy virtual display window is due to how Android's AccessibilityService and virtual displays work:

Key Explanation:

  • AccessibilityService only reports windows that are part of the standard Android window hierarchy, which are typically the windows rendered by apps and the system UI (status bar, navigation bar, etc.).
  • When you use scrcpy --new-display, it creates a virtual display on the Android device. This virtual display is managed by the Android system's DisplayManager and is not part of the standard window hierarchy that AccessibilityService monitors. As a result, getWindows() does not see or report this virtual display as a window.

Why?

  • Virtual displays are isolated from the main display hierarchy for security and performance reasons. They are not considered "windows" in the traditional sense that AccessibilityService is designed to detect.
  • AccessibilityService is primarily intended for user interface elements rendered by apps and the system, not for virtual displays created by tools like scrcpy.

Summary:
AccessibilityService.getWindows() will not return virtual displays created by scrcpy because those displays are not part of the standard window hierarchy that AccessibilityService is designed to monitor.

If you need to interact with or detect virtual displays, you would need to use the Android DisplayManager API directly, not AccessibilityService. Would you like more details on how to use DisplayManager for this purpose?

Apr 4, 11:37pm
Yes, I would like more details on how to use DisplayManager for this purpose.
Apr 4, 11:39pm
Empty message
Apr 4, 11:39pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.