Skip to content

Commit

Permalink
Use DisplayManagerGlobal instance
Browse files Browse the repository at this point in the history
Use the client instance to communicate with the DisplayManager server.

Fixes #3446 <#3446>

Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
DerekWuYD authored and rom1v committed Aug 19, 2022
1 parent d19606e commit 9c1722f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import com.genymobile.scrcpy.DisplayInfo;
import com.genymobile.scrcpy.Size;

import android.os.IInterface;

public final class DisplayManager {
private final IInterface manager;
private final Object manager; // instance of hidden class android.hardware.display.DisplayManagerGlobal

public DisplayManager(IInterface manager) {
public DisplayManager(Object manager) {
this.manager = manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ public WindowManager getWindowManager() {

public DisplayManager getDisplayManager() {
if (displayManager == null) {
displayManager = new DisplayManager(getService("display", "android.hardware.display.IDisplayManager"));
try {
Class<?> clazz = Class.forName("android.hardware.display.DisplayManagerGlobal");
Method getInstanceMethod = clazz.getDeclaredMethod("getInstance");
Object dmg = getInstanceMethod.invoke(null);
displayManager = new DisplayManager(dmg);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new AssertionError(e);
}
}
return displayManager;
}
Expand Down

0 comments on commit 9c1722f

Please sign in to comment.