From e11399aff0562a45e397beb9a98743be1c411710 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 18 Sep 2025 10:01:29 +0200 Subject: [PATCH] Ignore unknown methods in IDisplayWindowListener New Android versions may add methods to IDisplayWindowListener.aidl. When these methods are called by the system, they result in an AbstractMethodError because they are not implemented on the scrcpy side. To avoid releasing a new version for each newly added method, ignore them at the Binder level. Refs afaca80b375a2fbdb966c15f52645abb578071f4 Fixes #6362 --- .../android/view/IDisplayWindowListener.aidl | 23 ---------- .../wrappers/DisplayWindowListener.java | 45 ++++++------------- 2 files changed, 14 insertions(+), 54 deletions(-) diff --git a/server/src/main/aidl/android/view/IDisplayWindowListener.aidl b/server/src/main/aidl/android/view/IDisplayWindowListener.aidl index 3e664e81..0d1f1979 100644 --- a/server/src/main/aidl/android/view/IDisplayWindowListener.aidl +++ b/server/src/main/aidl/android/view/IDisplayWindowListener.aidl @@ -48,27 +48,4 @@ oneway interface IDisplayWindowListener { * Called when a display is removed from the hierarchy. */ void onDisplayRemoved(int displayId); - - /** - * Called when fixed rotation is started on a display. - */ - void onFixedRotationStarted(int displayId, int newRotation); - - /** - * Called when the previous fixed rotation on a display is finished. - */ - void onFixedRotationFinished(int displayId); - - /** - * Called when the keep clear ares on a display have changed. - */ - void onKeepClearAreasChanged(int displayId, in List restricted, in List unrestricted); - - /** - * Called when the eligibility of the desktop mode for a display have changed. - */ - void onDesktopModeEligibleChanged(int displayId); - - void onDisplayAddSystemDecorations(int displayId); - void onDisplayRemoveSystemDecorations(int displayId); } diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayWindowListener.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayWindowListener.java index b8b00e44..1573d817 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayWindowListener.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayWindowListener.java @@ -1,10 +1,11 @@ package com.genymobile.scrcpy.wrappers; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.view.IDisplayWindowListener; +import com.genymobile.scrcpy.util.Ln; -import java.util.List; +import android.content.res.Configuration; +import android.os.Parcel; +import android.os.RemoteException; +import android.view.IDisplayWindowListener; public class DisplayWindowListener extends IDisplayWindowListener.Stub { @Override @@ -23,32 +24,14 @@ public class DisplayWindowListener extends IDisplayWindowListener.Stub { } @Override - public void onFixedRotationStarted(int displayId, int newRotation) { - // empty default implementation - } - - @Override - public void onFixedRotationFinished(int displayId) { - // empty default implementation - } - - @Override - public void onKeepClearAreasChanged(int displayId, List restricted, List unrestricted) { - // empty default implementation - } - - @Override - public void onDesktopModeEligibleChanged(int displayId) { - // empty default implementation - } - - @Override - public void onDisplayAddSystemDecorations(int displayId) { - // empty default implementation - } - - @Override - public void onDisplayRemoveSystemDecorations(int displayId) { - // empty default implementation + public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { + try { + return super.onTransact(code, data, reply, flags); + } catch (AbstractMethodError e) { + Ln.v("Ignoring AbstractMethodError: " + e.getMessage()); + // Ignore unknown methods, write default response to reply parcel + reply.writeNoException(); + return true; + } } }