Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding method to hook for Xposed Module

I am trying to make a Xposed module. I read a tutorial first which had instructions to manipulate the clock. The code is like:

package de.robv.android.xposed.mods.tutorial;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import android.graphics.Color;
import android.widget.TextView;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class Tutorial implements IXposedHookLoadPackage {
    public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
        if (!lpparam.packageName.equals("com.android.systemui"))
            return;

        findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                TextView tv = (TextView) param.thisObject;
                String text = tv.getText().toString();
                tv.setText(text + " :)");
                tv.setTextColor(Color.RED);
            }
        });
    }
}

I want to make my own module now in which i have to perform some operation after the pattern lock is entered. After the pattern is entered i want to read the pattern and perform some operation according to the pattern. Please help me out in this respect. I am not even able to identify the method to hook. I was trying to find it at: http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/

Thanks!

like image 652
Himanshu Jain Avatar asked May 02 '15 09:05

Himanshu Jain


People also ask

What is xposed hook?

Xposed is a framework that enables developers to write custom modules for hooking into Android apps and thus modifying their flow at runtime. The Xposed framework was released by rovo89 in 2012.

How do I use xposed modules?

Download and install Xposed Framework Install the Xposed APK—you'll need to have Unknown Sources ticked first. Launch the Xposed Installer app. To activate it tap Framework followed by Install/Update. Grant Superuser permissions when prompted then tap OK and your device will reboot.

Does xposed framework require root?

Root is a requirement to install the Xposed Framework, any additional modules can be installed (may not explicitly state root requirement) but need the Xposed framework to function, so in short yes root is needed. As the other answer states, root is a requirement only if you're using the framework installer.


1 Answers

I searched a bit in the keyguard sources on android git, and I found this method featuring this method you should hook. In this method, you get direct access to the pattern at the right time.

findAndHookMethod("com.android.internal.widget.LockPatternUtils", lpparam.classLoader, "checkPattern", List.class /*You need to name the attribute's data type, I'm still not sure if List.class is enough, as the type is List<LockPatternView.Cell>*/, new XC_MethodHook() {
@Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            List<?> pattern = param.args[0];
            // Proceed…
        }
});

As a little extra, I found a static method you could use to convert the pattern to a String for better usability: LockPatternUtils.patternToString()

Class[] c = new Class[1];
c[0] = List.class;
XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.android.internal.widget.LockPatternUtils", lpparam.classLoader), "patternToString", c, pattern);
like image 194
Maxr1998 Avatar answered Sep 26 '22 12:09

Maxr1998