FlyJingFish / AndroidAOP

🔥🔥🔥帮助 Android App 改造成AOP架构的框架,一个注解就可以请求权限、切换线程、禁止多点、监测所有点击事件、监测生命周期等等(Help you transform into an Android platform framework with AOP architecture)
https://flyjingfish.github.io/AndroidAOP/
Apache License 2.0
467 stars 30 forks source link

Don't know how to get AndroidAOP to work #38

Closed tpkarras closed 1 month ago

tpkarras commented 1 month ago

Hello.

First time user of AndroidAOP.

I am trying to get AndroidAOP to work but I am unsure of how it works.

I have applied the plugin as specified with it being enabled, build log shows weaving happening.

I have tried \@AndroidAOPMatchClass and \@AndroidAOPReplaceClass to no avail.

I am trying to get it to output a log message when it intercepts the method.

Code is below.

import android.util.Log; import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceClass; import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceMethod; @AndroidAopReplaceClass( "android.app.ActivityThread" ) public class CameraSpoofer { @AndroidAopReplaceMethod( "android.app.ActivityThread currentOpPackageName()" ) public static String currentOpPackageName() { Log.d("Test", "Test"); return "different.package.name"; } @AndroidAopReplaceMethod( "android.app.ActivityThread currentPackageName()" ) public static String currentPackageName() { Log.d("Test2", "Test2"); return "different.package.name"; } }

I am on Windows 11 using Android Studio Jellyfish | 2023.3.1

What am I doing wrong?

FlyJingFish commented 1 month ago
  1. First, you should experiment with the class in your package. If it works, then try to set the class in android.jar in this way.
  2. The class you set is the class in android.jar. The setting method may not appear in your apk, so it may be useless. Click here for detailed explanation