mirror of https://github.com/Genymobile/scrcpy
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.5 KiB
Java
82 lines
2.5 KiB
Java
package com.genymobile.scrcpy.wrappers;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.graphics.Rect;
|
|
import android.os.IBinder;
|
|
import android.view.Surface;
|
|
|
|
@SuppressLint("PrivateApi")
|
|
public final class SurfaceControl {
|
|
|
|
private static final Class<?> CLASS;
|
|
|
|
static {
|
|
try {
|
|
CLASS = Class.forName("android.view.SurfaceControl");
|
|
} catch (ClassNotFoundException e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
private SurfaceControl() {
|
|
// only static methods
|
|
}
|
|
|
|
public static void openTransaction() {
|
|
try {
|
|
CLASS.getMethod("openTransaction").invoke(null);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static void closeTransaction() {
|
|
try {
|
|
CLASS.getMethod("closeTransaction").invoke(null);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static void setDisplayProjection(IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect) {
|
|
try {
|
|
CLASS.getMethod("setDisplayProjection", IBinder.class, int.class, Rect.class, Rect.class)
|
|
.invoke(null, displayToken, orientation, layerStackRect, displayRect);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static void setDisplayLayerStack(IBinder displayToken, int layerStack) {
|
|
try {
|
|
CLASS.getMethod("setDisplayLayerStack", IBinder.class, int.class).invoke(null, displayToken, layerStack);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static void setDisplaySurface(IBinder displayToken, Surface surface) {
|
|
try {
|
|
CLASS.getMethod("setDisplaySurface", IBinder.class, Surface.class).invoke(null, displayToken, surface);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static IBinder createDisplay(String name, boolean secure) {
|
|
try {
|
|
return (IBinder) CLASS.getMethod("createDisplay", String.class, boolean.class).invoke(null, name, secure);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
public static void destroyDisplay(IBinder displayToken) {
|
|
try {
|
|
CLASS.getMethod("destroyDisplay", IBinder.class).invoke(null, displayToken);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
}
|