Compare commits
1 Commits
issue4492
...
getdisplay
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d98160984 |
@@ -3,12 +3,10 @@ package com.genymobile.scrcpy.wrappers;
|
|||||||
import com.genymobile.scrcpy.DisplayInfo;
|
import com.genymobile.scrcpy.DisplayInfo;
|
||||||
import com.genymobile.scrcpy.Size;
|
import com.genymobile.scrcpy.Size;
|
||||||
|
|
||||||
import android.os.IInterface;
|
|
||||||
|
|
||||||
public final class DisplayManager {
|
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;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ public final class ServiceManager {
|
|||||||
|
|
||||||
public DisplayManager getDisplayManager() {
|
public DisplayManager getDisplayManager() {
|
||||||
if (displayManager == null) {
|
if (displayManager == null) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
displayManager = new DisplayManager(getService("display", "android.hardware.display.IDisplayManager"));
|
displayManager = new DisplayManager(getService("display", "android.hardware.display.IDisplayManager"));
|
||||||
}
|
}
|
||||||
return displayManager;
|
return displayManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user