Screen off PoC
This commit is contained in:
parent
a16cf95b8e
commit
5b56c57795
@ -57,6 +57,8 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||
MediaFormat format = createFormat(bitRate, frameRate, iFrameInterval);
|
||||
device.setRotationListener(this);
|
||||
IBinder d = SurfaceControl.getBuiltInDisplay(0);
|
||||
SurfaceControl.setDisplayPowerMode(d, SurfaceControl.POWER_MODE_OFF);
|
||||
boolean alive;
|
||||
try {
|
||||
do {
|
||||
|
@ -10,6 +10,11 @@ public final class SurfaceControl {
|
||||
|
||||
private static final Class<?> CLASS;
|
||||
|
||||
public static final int POWER_MODE_OFF = 0;
|
||||
public static final int POWER_MODE_DOZE = 1;
|
||||
public static final int POWER_MODE_NORMAL = 2;
|
||||
public static final int POWER_MODE_DOZE_SUSPEND = 3;
|
||||
|
||||
static {
|
||||
try {
|
||||
CLASS = Class.forName("android.view.SurfaceControl");
|
||||
@ -71,6 +76,22 @@ public final class SurfaceControl {
|
||||
}
|
||||
}
|
||||
|
||||
public static IBinder getBuiltInDisplay(int builtInDisplayId) {
|
||||
try {
|
||||
return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDisplayPowerMode(IBinder displayToken, int mode) {
|
||||
try {
|
||||
CLASS.getMethod("setDisplayPowerMode", IBinder.class, int.class).invoke(null, displayToken, mode);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyDisplay(IBinder displayToken) {
|
||||
try {
|
||||
CLASS.getMethod("destroyDisplay", IBinder.class).invoke(null, displayToken);
|
||||
|
Loading…
x
Reference in New Issue
Block a user