Use xposed installer to implement Android hooks, the article reference the official tutorial, there are changes.
1, install xposed installer frame apk to the mobile phone, the phone must root;
2, code writing;
Declared in the manifest file:
<application Android:allowbackup= "true" android:icon= "@drawable/ic_launcher" android: Label= "@string/app_name" android:theme= "@style/apptheme" > <meta-data android:name= " Xposedmodule " android:value=" true "/> <meta-data android:name=" Xposeddescription "an Droid:value= "Easy example which changes the color of all app"/> <meta-data android:name= "Xposedmi Nversion " android:value="/></application> "
Add xposed library file to Libs; Create a new Main.java class with the following code:
Public classMainImplementsixposedhookloadpackage,ixposedhookzygoteinit{@Override Public voidInitzygote (Startupparam Startupparam)throwsthrowable {hookrescolor (); } voidHookrescolor () {Xposedhelpers.findandhookmethod (Resources.class, "GetColor", Integer.type,Newxc_methodreplacement () {@OverrideprotectedObject replacehookedmethod (methodhookparam param)throwsthrowable {Object color=Xposedbridge.invokeoriginalmethod (Param.method, Param.thisobject, Param.args); if(ColorinstanceofInteger) {Integer new_name=(Integer) color; returnNew_name & ~0X0000FF00 | 0x00ff0000; } return NULL ; } }); } @Override Public voidHandleloadpackage (Loadpackageparam Lpparam)throwsthrowable {hookclock (Lpparam); } voidHookclock (Loadpackageparam lpparam) {if(!lpparam.packagename.equals ("Com.android.systemui")) return; Xposedhelpers.findandhookmethod ("Com.android.systemui.statusbar.policy.Clock", Lpparam.classloader,"Updateclock",NewXc_methodhook () {@Overrideprotected voidAfterhookedmethod (methodhookparam param)throwsthrowable {System.out.println ("Replacehookedmethod---updateclock"); XposedBridge.log ("Replacehookedmethod---updateclock-->>"); TextView TV=(TextView) param.thisobject; String text=Tv.gettext (). toString (); Tv.settext (Text+ ":)--"); Tv.settextcolor (color.red); } }); }
add a name of xposed_init files to the assets directory, the file content is "Com.app.xposed.example.Main", which is the full package name of the Main class above.
Right-click on the project to choose the properties, in the Java Build path to remove the check option (here a bit of pit, must be removed check, otherwise after running no effect, do not know if it is related to the development environment),
To run the project, the effect is as follows:
So it seems that xposed, like Cydia substrate, needs to rely on Java reflection, and if the code is confusing or encrypted, is this framework useful?
Using xposed installer to implement Android hooks