The right-click is almost useless on Android, so use it to turn the screen on. Add a new control event type (command) to request the server to turn the screen on.master
parent
228545cefd
commit
a139509f11
@ -0,0 +1,30 @@
|
|||||||
|
package com.genymobile.scrcpy.wrappers;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.IInterface;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
public class PowerManager {
|
||||||
|
private final IInterface manager;
|
||||||
|
private final Method isScreenOnMethod;
|
||||||
|
|
||||||
|
public PowerManager(IInterface manager) {
|
||||||
|
this.manager = manager;
|
||||||
|
try {
|
||||||
|
String methodName = Build.VERSION.SDK_INT >= 20 ? "isInteractive" : "isScreenOn";
|
||||||
|
isScreenOnMethod = manager.getClass().getMethod(methodName);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScreenOn() {
|
||||||
|
try {
|
||||||
|
return (Boolean) isScreenOnMethod.invoke(manager);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue