[Galaxy Note II Original Android Development] pulser_g2:
How to make your own such modification

This information is NOT complete. This example only uses 1 of about 10 different types of modification. I have spoken to rovo89 and he has said it would probably be possible to document this further. This example covers ONE usage case - I am going to override an entire method.

1. Create a new empty Android project in Eclipse.

2. Within the "application" section of your AndroidManifest.xml, add the following metadata:

<meta-data android:name="xposedmodule" android:value="true"/>
<meta-data android:name="xposedminversion" android:value="2.0rc1.*" />

3. Within the assets folder of the project, add a plain text file, "xposed_init". Within this, I have put

uk.co.villainrom.pulser.allowlongsms.AllowLongSMS

uk.co.villainrom.pulser.allowlongsms is the PACKAGE name of my Java package. AllowLongSMS is my class name. The purpose of this is to tell the Xposed Framework what to run.

4. Within AllowLongSMS.java (ie. the class name, with .java on the end), I put the following code:

package uk.co.villainrom.pulser.allowlongsms; //this sets the package for our project, this is the first part of the value in xposed_init file in assets.

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

//above includes all the required parts of the xposed framework that we need here

public class AllowLongSMS implements IXposedHookLoadPackage { //here we declare the class AllowLongSMS. We say it implements IXposedHookLoadPackage, as we want to make use of the hook-in on package load. Other options are available here for working with native libs etc, and resources, but I'm not using these right now.
public static final String MY_PACKAGE_NAME = AllowLongSMS.class.getPackage()
.getName(); //this doesn't do anything, I just left it here for if I needed to write logs and wanted to have the package name easily accessible.
public static final String TAG = "PulserMmsTweak"; //same here, this doesn't do anything.

@Override //we are going to override the method handleLoadPackage, if it exists further up the hierarchy
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
//this method is called every time a package is loaded. We have a parameter that we're going to call lpparam, that is passed in, that relates to what package was loaded
if (lpparam.packageName.equals("com.android.mms")) { //if the package that has just been loaded is called "com.android.mms" then
ClassLoader classLoader = lpparam.classLoader; //create a classloader object that we can now use
XC_MethodReplacement methodreplacer = new XC_MethodReplacement() { //create a method replacer object, as we are going to REPLACE an entire method within the mms app.
protected Object replaceHookedMethod( //we make an object here, that passes in the parameters of what to actually change
XC_MethodHook.MethodHookParam paramAnonymousMethodHookParam)
throws Throwable {
return Integer.valueOf(255);
/* THIS IS THE IMPORTANT LINE
* This line returns the value 255. Why this happens won't make sense yet, but THIS is where you put your "new method" code.
*
*/

}
};
XposedHelpers.findAndHookMethod("com.android.mms.MmsConfig", //here we say that we want to find and hook into the method "getSMSToMmsTextThreshold" which is part of the class com.android.mms.MmsConfig. We then say that we're passing this to methodreplacer, which we defined earlier
classLoader, "getSmsToMmsTextThreshold", methodreplacer);
}
//if the package wasn't com.android.mms, do nothing.

}

}