From aa604763a8998feb1fe65bd9c77beadf2f67a31c Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 17 Apr 2021 18:22:58 +0100 Subject: [PATCH] expandSettingsPanel() changed API with android 9 Now it gets a parameter. However, it can be null https://code.yawk.at/android/android-9.0.0_r35/android/app/StatusBarManager.java#android.app.StatusBarManager%23expandSettingsPanel(java.lang.String) For now, I don't have android 10's but it's probably a version without the noargument method --- .../scrcpy/wrappers/StatusBarManager.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java index 92b5790a01..99fa57c5c7 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java @@ -12,6 +12,7 @@ public class StatusBarManager { private final IInterface manager; private Method expandNotificationsPanelMethod; private Method expandSettingsPanelMethod; + private Object[] expandSettingsPanelArgs; private Method collapsePanelsMethod; public StatusBarManager(IInterface manager) { @@ -27,7 +28,19 @@ private Method getExpandNotificationsPanelMethod() throws NoSuchMethodException private Method getExpandSettingsPanel() throws NoSuchMethodException { if (expandSettingsPanelMethod == null) { - expandSettingsPanelMethod = manager.getClass().getMethod("expandSettingsPanel"); + try{ + expandSettingsPanelMethod = manager.getClass().getMethod("expandSettingsPanel"); + expandSettingsPanelArgs = new Object[] {}; + } catch (NoSuchMethodException e){ + try{ + expandSettingsPanelMethod = manager.getClass().getMethod("expandSettingsPanel", String.class); + expandSettingsPanelArgs = new Object[] {null}; + } catch (NoSuchMethodException f){ + f.initCause(e); + throw f; + } + } + } return expandSettingsPanelMethod; } @@ -50,7 +63,7 @@ public void expandNotificationsPanel() { public void expandSettingsPanel() { try { Method method = getExpandSettingsPanel(); - method.invoke(manager); + method.invoke(manager, expandSettingsPanelArgs); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { Ln.e("Could not invoke method", e); }