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.).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?
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?