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