Coder Social home page Coder Social logo

aop's Introduction

插件使用

  1. 在项目根目录的build.gradle里依赖AspectJX
dependencies {
  classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
  // 如果build:gradle在3.6.0以下,使用2.0.8版本
}
  1. 在app目录的build.gradle里添加Aspectj的插件 apply plugin: 'android-aspectjx'
  2. 在app目录的build.gradle里去掉不必要侵入的类 不去掉可能会导致 java.util.zip.ZipException: zip file is empty 或者 classNotDefFoundException
    aspectjx{
        exclude 'com.google','com.squareup','com.alipay','org.apache'
    }
    
  3. 如果你使用得分组件时androidx版本则用master分支,否则使用support分支

文章介绍

aop's People

Contributors

pettywing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aop's Issues

点击事件 长按事件均未入侵到

由于作者使用的aspectj插件版本未更新,所以尝试了 其他人提供的aspectj插件版本,(版本如下)
切入 hook的操作使用作者 源码
ViewAspect 中不能被切入点击事件,(execution(* android.view.View.OnClickListener+.onClick(..))) 未能侵入
但是 BottomNavigationView控件的tab切换 却能被入侵

Fragment.kt

        mBinding.testClick.setOnClickListener {
            LogUtils.d("testClick")
        }

Activity.kt

     binding.bottomNavigationView.setOnItemSelectedListener {
            switchPage(it.itemId)
            return@setOnItemSelectedListener true
        }
2022-10-14 14:30:29.367 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall -> view:com.google.android.material.bottomnavigation.BottomNavigationItemView{8dba269 VFE...C.. ..SP..ID 0,0-379,126 #7f080044 app:id/action_home}
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getTarget->com.google.android.material.navigation.NavigationBarMenuView$1@d419fae
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getThis->com.google.android.material.navigation.NavigationBarMenuView$1@d419fae
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getKind->method-execution
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getSourceLocation->NavigationBarMenuView.java:136
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getDeclaringTypeName->com.google.android.material.navigation.NavigationBarMenuView$1
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getModifiers->1
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getName->onClick
2022-10-14 14:30:29.368 23251-23251/com.xx.yhd_super.debug E/ViewAspect: afterOnClickMethodCall getDeclaringType->class com.google.android.material.navigation.NavigationBarMenuView$1

点击事件只有Hook

2022-10-14 14:30:30.495 23251-23251/com.xx.yhd_super.debug D/HookOnClickListener: testClick
2022-10-14 14:30:30.496 23251-23251/com.xx.yhd_super.debug D/HookOnClickListener: sendAccessibilityEvent: ViewRootImpl/DecorView[0]/LinearLayout[0]/FrameLayout[0]/FitWindowsLinearLayout[0]/ContentFrameLayout[0]/LinearLayout[0]/FrameLayout[0]/ConstraintLayout[0]/LinearLayout[0]/FlexboxLayout[0]/MaterialButton[13]

环境

kotlin 1.7.10
implementation org.aspectj:aspectjrt:1.9.6

    dependencies {
        //aop埋点
        classpath("io.github.wurensen:gradle-android-plugin-aspectjx:3.2.0")
    }
 implementation("androidx.appcompat:appcompat:1.5.1")
 implementation("com.google.android.material:material:1.6.1")
> Configure project :app
[ajx] agp version[7.2.1]
[ajx] gradle version[7.5.1] > 4.0
[ajx] auto add dependency: 'implementation org.aspectj:aspectjrt:1.9.6'
[ajx] register AJXTransform:[com.alibaba.android.arouter.register.core.RegisterTransform@2ce7cff4, com.hujiang.gradle.plugin.android.aspectjx.AJXTransform@65cff907]
[ajx] AJXExtension after optimize:AJXExtension(includes=[], excludes=[com.alibaba.android.arouter, com.alibaba.arouter, com.taobao.weex.ui.view.WXFrameLayout, io.dcloud.feature.nativeObj.NativeView, kotlin.internal, kotlin.jvm, kotlinx.coroutines.android, kotlinx.coroutines.internal], ajcArgs=[], enabled=true)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.