I have some problems using the exposed framework, i don't understand why my logs aren't working in the beforehookedmethod and afterhookedmethod?
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);
}
}
}
And my log file is as follows:
06-12 11:42:50.319 I/Xposed ( 359): Loading class com.example.stefan.testxposed.Tutorial 06-12 11:42:50.335 I/Xposed ( 359): SimSettings (com.example.stefan.testxposed.Tutorial#initZygote(StartupParam)) Simding starting... 06-12 11:43:09.689 I/Xposed ( 5717): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:11.010 I/Xposed ( 5993): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:13.133 I/Xposed ( 6385): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:14.124 I/Xposed ( 6528): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:15.077 I/Xposed ( 6670): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:16.500 I/Xposed ( 6880): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:43:48.390 I/Xposed ( 8719): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:44:51.582 I/Xposed ( 9083): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:44:52.545 I/Xposed ( 9248): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:44:53.608 I/Xposed ( 9415): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:44:55.309 I/Xposed ( 9725): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting... 06-12 11:45:31.457 I/Xposed (10704): SimSettings (com.example.stefan.testxposed.Tutorial#handleLoadPackage(LoadPackageParam)) Gevonden starting...
In this log file i dont see these two lines back?: verboseLog(this, "beforeHookedMethod(MethodHookParam)", "In de hook..."); verboseLog(this, "beforeHookedMethod(MethodHookParam)", "In de hoook...");
It was something stupid, it already worked.. but i didn't trigger the WifiSettings onCreateContextMenu method. After the trigger it worked! I assumed xposed did trigger the function but it would not. So it was my own mistake