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.
41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
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"));
|
|
}
|
|
}
|