6.3,GraphicsStats Hook
结构图如下,
Hook 类 | IGraphicsStatsBinderHook |
Hook 代理类 | IGraphicsStatsHookHandle |
Hook 方法实现类 | requestBufferForProcess |
IGraphicsStatsHookHandle的内部类IGraphicsStatsHookHandle的beforeInvoke方法如下,
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
int index = 0;
if (args != null && args.length > index && args[index] instanceof String) {
String pkg = ((String) args[index]);
if (!TextUtils.equals(pkg, mHostContext.getPackageName())) {
args[index] = mHostContext.getPackageName();
}
}
return super.beforeInvoke(receiver, method, args);
}
6.4,InputMethodManager Hook
结构图如下,
Hook 类 | IInputMethodManagerBinderHook |
Hook 代理类 | IInputMethodManagerHookHandle |
Hook 方法实现类 | startInput |
windowGainedFocus |
IinputMethodManagerHookHandle的内部类IinputMethodManagerHookedMethodHandler的beforeInvoke方法如下,
if (args != null && args.length > 0) {
for (Object arg : args) {
if (arg instanceof EditorInfo) {
EditorInfo info = ((EditorInfo) arg);
if (!TextUtils.equals(mHostContext.getPackageName(), info.packageName)) {
info.packageName = mHostContext.getPackageName();
}
}
}
}
6.5 MediaRouterService Hook
结构图如下,
Hook 类 | IMediaRouterServiceBinderHook |
Hook 代理类 | IMediaRouterServiceHookHandle |
Hook 方法实现类 | registerClientAsUser |
IMediaRouterServiceHookHandle的内部类registerClientAsUser的beforeInvoke方法如下,
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
int index = 1;
if (args != null && args.length > index && args[index] instanceof String) {
String pkg = (String) args[index];
if (!TextUtils.equals(pkg, mHostContext.getPackageName())) {
args[index] = mHostContext.getPackageName();
}
}
return super.beforeInvoke(receiver, method, args);
}