How to call hooked method using xposed framework api?

98 Views Asked by At

I want to call a method within the app using the xposed framework API, but it doesn't work. I am not sure what is my fault or may have made some mistake.

    public static Method invokeMethod;
    public static Object invokeObject;
    public static String strParam1 = "";
    public static String strParam2 = "";
XposedHelpers.findAndHookMethod("com.sec.android.app.sbrowser.SBrowserLauncherActivity", classLoader, "startCustomTabActivityIfNeeded", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
             String strUserAgent1 = "Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-G918) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36";
                    strParam1 = "user-agent";
                    strParam2 = strUserAgent1;
                    invokeMethod.invoke(invokeObject, strParam1, strParam2);
            }
});
XposedHelpers.findAndHookMethod("com.sec.terrace.TerraceCommandLine", classLoader, "appendSwitchWithValue", String.class, String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                invokeMethod = (Method) param.method;
                invokeObject = param.thisObject;
                strParam1 = (String)param.args[0];
                strParam2 = (String)param.args[1];
                System.out.println("HOOKED!!!");
            }
        });

I tried calling another hooking method from within the hooking method. In this case: When this function "startCustomTabActivityIfNeeded" is called, the "appendSwitchWithValue" function must be executed.

"appendSwitchWithValue" is static method.

0

There are 0 best solutions below