mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-11 17:55:55 +00:00
Use DisplayManagerGlobal instance
Use the client instance to communicate with the DisplayManager server. Fixes #3446 <https://github.com/Genymobile/scrcpy/issues/3446> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
d19606eb0c
commit
9c1722f428
@ -3,12 +3,10 @@ package com.genymobile.scrcpy.wrappers;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,14 @@ public final class ServiceManager {
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user