Activity launches when Android desktop mode is active (Android 16 QPR1+ / Android 17)#6722
Draft
lmichaelwar wants to merge 7 commits intoGenymobile:masterfrom
Draft
Activity launches when Android desktop mode is active (Android 16 QPR1+ / Android 17)#6722lmichaelwar wants to merge 7 commits intoGenymobile:masterfrom
lmichaelwar wants to merge 7 commits intoGenymobile:masterfrom
Conversation
…ay desktop mode - Add VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS unconditionally for API 34+ alongside OWN_FOCUS to ensure desktop mode compatibility - Add WindowContainerTransaction-based setDisplayWindowingMode() to WindowManager using reflection to set WINDOWING_MODE_FREEFORM on the virtual display's default task area after creation - Call setDisplayWindowingMode after virtual display creation on API 34+ Co-authored-by: lmichaelwar <20604470+lmichaelwar@users.noreply.github.com>
Co-authored-by: lmichaelwar <20604470+lmichaelwar@users.noreply.github.com>
…play-launches Fix virtual display activity routing for Android desktop mode
… Binder descriptor, respect vdSystemDecorations flag 1. WindowManager.java: Replace manual reflection for window_organizer service with ServiceManager.getService() to avoid duplicating reflection logic. 2. WindowManager.java: Attach correct AIDL interface descriptor to the organizer Binder and override onTransact to safely handle callbacks. 3. NewDisplayCapture.java: Remove unconditional SHOULD_SHOW_SYSTEM_DECORATIONS from API 34+ block so --no-vd-system-decorations remains effective. Co-authored-by: lmichaelwar <20604470+lmichaelwar@users.noreply.github.com>
…eview-comments Address code review feedback on virtual display desktop mode fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Problem
Virtual displays created by scrcpy don't correctly route activity launches when Android desktop mode is active (Android 16 QPR1+ / Android 17). Apps launched from the virtual display's desktop launcher open on the phone's main screen instead of the virtual display.
Root Cause
VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS was only set conditionally (via user option), not guaranteed on API 34+
The virtual display area was never assigned WINDOWING_MODE_FREEFORM via WindowContainerTransaction, which is required for freeform windowing in desktop mode
Changes Made
NewDisplayCapture.java (2 changes):
Added VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS to the unconditional API 34+ flag block — ensures the display is always treated as a full windowing environment on modern Android
Added call to setDisplayWindowingMode() after virtual display creation to set freeform windowing mode
WindowManager.java (1 new method + 2 constants):
Added WINDOWING_MODE_FREEFORM constant (= 5, from android.app.WindowConfiguration)
Added FEATURE_DEFAULT_TASK_CONTAINER constant (= 1, from android.window.DisplayAreaOrganizer)
Added setDisplayWindowingMode(int displayId, int windowingMode) method that:
Gets the IWindowOrganizerController service via reflection
Temporarily registers a no-op DisplayAreaOrganizer to obtain the display area's WindowContainerToken
Creates and applies a WindowContainerTransaction to set the windowing mode
Properly unregisters the organizer in a finally block
Gracefully handles failures with warning logs