找到你要的答案

Q:finding method to hook for Xposed Module

Q:寻找方法来钩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!

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/

谢谢!

answer1: 回答1:

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);

我搜索了在Android上的Git的键盘锁源点,我发现这个方法,这个方法你应该的。在这种方法中,您可以在正确的时间直接访问模式。

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…
        }
});

作为一个额外的,我发现了一个静态方法,你可以使用转换模式到一个更好的可用性: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);
java  android  xposed-framework