Add support for expandNotificationsPanel() variant

Some custom vendor ROM added an int as a parameter.

Fixes #2551 <https://github.com/Genymobile/scrcpy/issues/2551>
This commit is contained in:
Romain Vimont 2021-09-11 10:46:25 +02:00
parent 069fe93f74
commit fa100b814b

View File

@ -11,6 +11,7 @@ public class StatusBarManager {
private final IInterface manager; private final IInterface manager;
private Method expandNotificationsPanelMethod; private Method expandNotificationsPanelMethod;
private boolean expandNotificationPanelMethodCustomVersion;
private Method expandSettingsPanelMethod; private Method expandSettingsPanelMethod;
private boolean expandSettingsPanelMethodNewVersion = true; private boolean expandSettingsPanelMethodNewVersion = true;
private Method collapsePanelsMethod; private Method collapsePanelsMethod;
@ -21,7 +22,13 @@ public class StatusBarManager {
private Method getExpandNotificationsPanelMethod() throws NoSuchMethodException { private Method getExpandNotificationsPanelMethod() throws NoSuchMethodException {
if (expandNotificationsPanelMethod == null) { if (expandNotificationsPanelMethod == null) {
expandNotificationsPanelMethod = manager.getClass().getMethod("expandNotificationsPanel"); try {
expandNotificationsPanelMethod = manager.getClass().getMethod("expandNotificationsPanel");
} catch (NoSuchMethodException e) {
// Custom version for custom vendor ROM: <https://github.com/Genymobile/scrcpy/issues/2551>
expandNotificationsPanelMethod = manager.getClass().getMethod("expandNotificationsPanel", int.class);
expandNotificationPanelMethodCustomVersion = true;
}
} }
return expandNotificationsPanelMethod; return expandNotificationsPanelMethod;
} }
@ -50,7 +57,11 @@ public class StatusBarManager {
public void expandNotificationsPanel() { public void expandNotificationsPanel() {
try { try {
Method method = getExpandNotificationsPanelMethod(); Method method = getExpandNotificationsPanelMethod();
method.invoke(manager); if (expandNotificationPanelMethodCustomVersion) {
method.invoke(manager, 0);
} else {
method.invoke(manager);
}
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e); Ln.e("Could not invoke method", e);
} }