|
|
|
@ -30,6 +30,8 @@ public final class SurfaceControl {
|
|
|
|
|
|
|
|
|
|
private static Method getBuiltInDisplayMethod;
|
|
|
|
|
private static Method setDisplayPowerModeMethod;
|
|
|
|
|
private static Method getPhysicalDisplayTokenMethod;
|
|
|
|
|
private static Method getPhysicalDisplayIdsMethod;
|
|
|
|
|
|
|
|
|
|
private SurfaceControl() {
|
|
|
|
|
// only static methods
|
|
|
|
@ -98,7 +100,6 @@ public final class SurfaceControl {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IBinder getBuiltInDisplay() {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Method method = getGetBuiltInDisplayMethod();
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
|
|
|
@ -114,6 +115,40 @@ public final class SurfaceControl {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Method getGetPhysicalDisplayTokenMethod() throws NoSuchMethodException {
|
|
|
|
|
if (getPhysicalDisplayTokenMethod == null) {
|
|
|
|
|
getPhysicalDisplayTokenMethod = CLASS.getMethod("getPhysicalDisplayToken", long.class);
|
|
|
|
|
}
|
|
|
|
|
return getPhysicalDisplayTokenMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IBinder getPhysicalDisplayToken(long physicalDisplayId) {
|
|
|
|
|
try {
|
|
|
|
|
Method method = getGetPhysicalDisplayTokenMethod();
|
|
|
|
|
return (IBinder) method.invoke(null, physicalDisplayId);
|
|
|
|
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Method getGetPhysicalDisplayIdsMethod() throws NoSuchMethodException {
|
|
|
|
|
if (getPhysicalDisplayIdsMethod == null) {
|
|
|
|
|
getPhysicalDisplayIdsMethod = CLASS.getMethod("getPhysicalDisplayIds");
|
|
|
|
|
}
|
|
|
|
|
return getPhysicalDisplayIdsMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static long[] getPhysicalDisplayIds() {
|
|
|
|
|
try {
|
|
|
|
|
Method method = getGetPhysicalDisplayIdsMethod();
|
|
|
|
|
return (long[]) method.invoke(null);
|
|
|
|
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Method getSetDisplayPowerModeMethod() throws NoSuchMethodException {
|
|
|
|
|
if (setDisplayPowerModeMethod == null) {
|
|
|
|
|
setDisplayPowerModeMethod = CLASS.getMethod("setDisplayPowerMode", IBinder.class, int.class);
|
|
|
|
|