我在使用暴露的框架时遇到一些问题,我不明白为什么我的日志在beforehooked方法和afterhooked方法中不起作用?
package com.example.stefan.testxposed;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.XC_MethodHook.MethodHookParam;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class Tutorial implements IXposedHookZygoteInit, IXposedHookLoadPackage {
public static final boolean verbose = true;
// What to hook
private static final String PACKAGE_SETTINGS =
"com.android.settings";
private static final String CLASS_SIM =
//"com.android.settings.sim.SimDialogActivity";
"com.android.settings.wifi.WifiSettings";
private static XSharedPreferences mPreferences;
@Override
public void initZygote(StartupParam param) throws Throwable {
verboseLog(this, "initZygote(StartupParam)", "Simding starting...");
//mPreferences = new XSharedPreferences(WiFiKeyView.class.getPackage().getName());
//mPreferences.makeWorldReadable();
}
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(PACKAGE_SETTINGS)) return;
verboseLog(this, "handleLoadPackage(LoadPackageParam)", "Gevonden starting...");
final Class<?> SettingsClazz = XposedHelpers.findClass(CLASS_SIM, lpparam.classLoader);
XposedHelpers.findAndHookMethod(CLASS_SIM, lpparam.classLoader,"onCreateContextMenu", ContextMenu.class, View.class, ContextMenuInfo.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
verboseLog(this, "beforeHookedMethod(MethodHookParam)", "In de hook...");
//Tutorial.verboseLog(this, "beforeHookedMethod(MethodHookParam)", "ding.");
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("AFTER");
verboseLog(this, "beforeHookedMethod(MethodHookParam)", "In de hoook...");
//Tutorial.verboseLog(this, "afterHookedMethod(MethodHookParam)", "ding.");
}
});
}
public static void verboseLog(Object who, String methodAndParams, String what) {
if (verbose) {
String packageAndClass = (who instanceof Class) ? ((Class<?>) who).getCanonicalName() : who.getClass().getCanonicalName();
String tag = "SimSettings (" + packageAndClass + "#" + methodAndParams + ")";
Log.v(tag, what);
XposedBridge.log(tag + " " + what);
}
}
}
我的日志文件如下:
06-12 11:42:50.319 I / Xposed(359):加载类com.example.stefan.testxposed.Tutorial 06-12 11:42:50.335 I / Xposed(359):SimSettings(com.example.stefan.testxposed.Tutorial #initZygote(StartupParam))模拟开始...... 06-12 11:43:09.689 I / Xposed(5717):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:11.010 I / Xposed(5993):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:13.133 I / Xposed(6385):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:14.124 I / Xposed(6528):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:15.077 I / Xposed(6670):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:16.500 I / Xposed(6880):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:43:48.390 I / Xposed(8719):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:44:51.582 I / Xposed(9083):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:44:52.545 I / Xposed(9248):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:44:53.608 I / Xposed(9415):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:44:55.309 I / Xposed(9725):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始...... 06-12 11:45:31.457 I / Xposed(10704):SimSettings(com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam))Gevonden开始......
在这个日志文件中,我看不到这两行?: verboseLog(this,“beforeHookedMethod(MethodHookParam)”,“In de hook ...”); verboseLog(this,“beforeHookedMethod(MethodHookParam)”,“In de hoook ...”);
答案 0 :(得分:0)
这是一些愚蠢的事情,它已经奏效了..但我没有触发WifiSettings onCreateContextMenu方法。触发后它工作了!我假设xposed确实触发了这个功能,但事实并非如此。所以这是我自己的错误