1. function main() {
    2. Java.perform(function () {
    3. console.log("--------------start hooking--------------");
    4. function showStack() {
    5. var log = Java.use("android.util.Log");
    6. var Throwable = Java.use("java.lang.Throwable");
    7. console.log(log.getStackTraceString(Throwable.$new()))
    8. }
    9. var btn_login_id = Java.use("com.dodonew.online.R$id").btn_login.value;
    10. console.log("btn_login_id", btn_login_id);
    11. var view = Java.use("android.view.View");
    12. view.setOnClickListener.implementation = function (a) {
    13. if(this.getId() == btn_login_id){
    14. showStack();
    15. console.log("view.id: " + this.getId());
    16. console.log("view.setOnClickListener is called");
    17. }
    18. return this.setOnClickListener(a);
    19. }
    20. })
    21. }
    22. setTimeout(main, 1000);
    1. hook这个函数,比对控件id,打印堆栈