Skip to content

Commit

Permalink
Add support for expandNotificationsPanel() variant
Browse files Browse the repository at this point in the history
Some custom vendor ROM added an int as a parameter.

Fixes #2551 <#2551>
  • Loading branch information
rom1v committed Oct 21, 2021
1 parent 96e3963 commit 691bdb9
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class StatusBarManager {

private final IInterface manager;
private Method expandNotificationsPanelMethod;
private boolean expandNotificationPanelMethodCustomVersion;
private Method expandSettingsPanelMethod;
private boolean expandSettingsPanelMethodNewVersion = true;
private Method collapsePanelsMethod;
Expand All @@ -21,7 +22,13 @@ public StatusBarManager(IInterface manager) {

private Method getExpandNotificationsPanelMethod() throws NoSuchMethodException {
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;
}
Expand Down Expand Up @@ -50,7 +57,11 @@ private Method getCollapsePanelsMethod() throws NoSuchMethodException {
public void expandNotificationsPanel() {
try {
Method method = getExpandNotificationsPanelMethod();
method.invoke(manager);
if (expandNotificationPanelMethodCustomVersion) {
method.invoke(manager, 0);
} else {
method.invoke(manager);
}
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e);
}
Expand Down

0 comments on commit 691bdb9

Please sign in to comment.