mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-20 06:54:19 +01:00
Convert server to an Android project
To simplify the device server-side build, use gradle to create an APK, even if we use it as a simple jar, by running its main() method.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.genymobile.scrcpy.wrappers;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ServiceManager {
|
||||
private final Method getServiceMethod;
|
||||
|
||||
public ServiceManager() {
|
||||
try {
|
||||
getServiceMethod = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", String.class);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private IInterface getService(String service, String type) {
|
||||
try {
|
||||
IBinder binder = (IBinder) getServiceMethod.invoke(null, service);
|
||||
Method asInterfaceMethod = Class.forName(type + "$Stub").getMethod("asInterface", IBinder.class);
|
||||
return (IInterface) asInterfaceMethod.invoke(null, binder);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public WindowManager getWindowManager() {
|
||||
return new WindowManager(getService("window", "android.view.IWindowManager"));
|
||||
}
|
||||
|
||||
public DisplayManager getDisplayManager() {
|
||||
return new DisplayManager(getService("display", "android.hardware.display.IDisplayManager"));
|
||||
}
|
||||
|
||||
public InputManager getInputManager() {
|
||||
return new InputManager(getService("input", "android.hardware.input.IInputManager"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user