Skip to content

Commit

Permalink
Register rotation watcher on selected display
Browse files Browse the repository at this point in the history
PR #1275 <#1275>

Signed-off-by: Kostiantyn Luzan <[email protected]>
Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
vblack authored and rom1v committed Apr 8, 2020
1 parent f07d21f commit c1ebea2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions server/src/main/java/com/genymobile/scrcpy/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onRotationChanged(int rotation) throws RemoteException {
}
}
}
});
}, displayId);

if ((displayInfoFlags & DisplayInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS) == 0) {
Ln.w("Display doesn't have FLAG_SUPPORTS_PROTECTED_BUFFERS flag, mirroring can be restricted");
Expand Down Expand Up @@ -138,8 +138,8 @@ public boolean isScreenOn() {
return serviceManager.getPowerManager().isScreenOn();
}

public void registerRotationWatcher(IRotationWatcher rotationWatcher) {
serviceManager.getWindowManager().registerRotationWatcher(rotationWatcher);
public void registerRotationWatcher(IRotationWatcher rotationWatcher, int displayId) {
serviceManager.getWindowManager().registerRotationWatcher(rotationWatcher, displayId);
}

public synchronized void setRotationListener(RotationListener rotationListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public void thawRotation() {
}
}

public void registerRotationWatcher(IRotationWatcher rotationWatcher) {
public void registerRotationWatcher(IRotationWatcher rotationWatcher, int displayId) {
try {
Class<?> cls = manager.getClass();
try {
// display parameter added since this commit:
// https://android.googlesource.com/platform/frameworks/base/+/35fa3c26adcb5f6577849fd0df5228b1f67cf2c6%5E%21/#F1
cls.getMethod("watchRotation", IRotationWatcher.class, int.class).invoke(manager, rotationWatcher, 0);
cls.getMethod("watchRotation", IRotationWatcher.class, int.class).invoke(manager, rotationWatcher, displayId);
} catch (NoSuchMethodException e) {
// old version
cls.getMethod("watchRotation", IRotationWatcher.class).invoke(manager, rotationWatcher);
Expand Down

0 comments on commit c1ebea2

Please sign in to comment.