mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
Address PR #1 review comments: reuse ServiceManager.getService(), fix 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>
This commit is contained in:
parent
14ac8040f1
commit
342444373d
2 changed files with 22 additions and 12 deletions
|
|
@ -188,8 +188,7 @@ public class NewDisplayCapture extends SurfaceCapture {
|
|||
| VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED;
|
||||
if (Build.VERSION.SDK_INT >= AndroidVersions.API_34_ANDROID_14) {
|
||||
flags |= VIRTUAL_DISPLAY_FLAG_OWN_FOCUS
|
||||
| VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP
|
||||
| VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
|
||||
| VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP;
|
||||
}
|
||||
}
|
||||
virtualDisplay = ServiceManager.getDisplayManager()
|
||||
|
|
|
|||
|
|
@ -283,23 +283,34 @@ public final class WindowManager {
|
|||
@TargetApi(AndroidVersions.API_34_ANDROID_14)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setDisplayWindowingMode(int displayId, int windowingMode) {
|
||||
// A Binder token used to identify this organizer during registration/unregistration with the system server
|
||||
IBinder organizerBinder = new Binder();
|
||||
// A Binder token with the correct AIDL interface descriptor, so that any system server
|
||||
// callbacks during registration are properly identified and silently handled
|
||||
IBinder organizerBinder = new Binder() {
|
||||
{
|
||||
attachInterface(null, "android.window.IDisplayAreaOrganizer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags)
|
||||
throws android.os.RemoteException {
|
||||
if (super.onTransact(code, data, reply, flags)) {
|
||||
return true;
|
||||
}
|
||||
// Silently accept any organizer callback transactions
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Object organizerProxy = null;
|
||||
Object daoController = null;
|
||||
try {
|
||||
// Get the IWindowOrganizerController
|
||||
Class<?> serviceManagerClass = Class.forName("android.os.ServiceManager");
|
||||
Method getServiceMethod = serviceManagerClass.getDeclaredMethod("getService", String.class);
|
||||
IBinder wocBinder = (IBinder) getServiceMethod.invoke(null, "window_organizer");
|
||||
if (wocBinder == null) {
|
||||
// Get the IWindowOrganizerController via ServiceManager
|
||||
IInterface windowOrganizerController = ServiceManager.getService("window_organizer",
|
||||
"android.window.IWindowOrganizerController");
|
||||
if (windowOrganizerController == null) {
|
||||
Ln.w("window_organizer service not available");
|
||||
return;
|
||||
}
|
||||
|
||||
Class<?> iWocStubClass = Class.forName("android.window.IWindowOrganizerController$Stub");
|
||||
Object windowOrganizerController = iWocStubClass.getDeclaredMethod("asInterface", IBinder.class).invoke(null, wocBinder);
|
||||
|
||||
// Get the IDisplayAreaOrganizerController
|
||||
daoController = windowOrganizerController.getClass().getMethod("getDisplayAreaOrganizerController").invoke(windowOrganizerController);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue