``
public class ClipHook {
private static final String TAG = "ClipHook";
public static void hook(XC_LoadPackage.LoadPackageParam lpparam) {
Log.e(TAG, "ClipHook start");
try {
final Class clazz = XposedHelpers.findClass("android.content.ClipData", lpparam.classLoader);
XposedHelpers.findAndHookMethod(clazz, "newPlainText", CharSequence.class, CharSequence.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
Object[] args = param.args;
CharSequence arg = (CharSequence) args[0];
CharSequence arg1 = (CharSequence) args[1];
Log.e(TAG, "replaceHookedMethod: arg="+arg+";arg1="+arg1 );
args[1]="你的粘贴数据被替换了";
return XposedBridge.invokeOriginalMethod(param.method,param.thisObject,args);
}
});
} catch (Throwable e) {
Log.e(TAG, "hook: ", e);
}
Log.e(TAG, "ClipHook end");
}
}
调用invokeOriginalMethod方法,将复制粘贴的内容统一替换成了“你的粘贴数据被替换了”;