Skip to content

Commit

Permalink
1、修改所有的链接
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Sep 30, 2024
1 parent b4646eb commit dc31365
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 61 deletions.
2 changes: 1 addition & 1 deletion docs/About_obfuscation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This resource library comes with [obfuscation rules](https://github.com/FlyJingF

Some friends will find that before obfuscation, the line number after the error can locate the error position, but after obfuscation, the original line number cannot be mapped out through the `ProGuard` tool, but it can be mapped out before using this library. That's right! Let's talk about the solution below.

- 1. First, you need to confirm whether your class is a class that has been processed by AOP (you can check the cut point [cutInfo.json](https://github.com/FlyJingFish/AndroidAOP?tab=readme-ov-file#%E5%9B%9B%E5%9C%A8-app-%E7%9A%84buildgradle%E6%B7%BB%E5%8A%A0-androidaopconfig-%E9%85%8D%E7%BD%AE%E9%A1%B9%E6%AD%A4%E6%AD%A5%E4%B8%BA%E5%8F%AF%E9%80%89%E9%85%8D%E7%BD%AE%E9%A1%B9)), if yes, follow the next step to continue trying<br>
- 1. First, you need to confirm whether your class is a class that has been processed by AOP (you can check the cut point [cutInfo.json](/AndroidAOP/getting_started/#4-add-the-androidaopconfig-configuration-item-in-apps-buildgradle-this-step-is-an-optional-configuration-item)), if yes, follow the next step to continue trying<br>
- 2. You just need to invalidate AndroidAOP and then generate an obfuscated package again, that is, generate a mapping file that does not contain AOP again. Configure it as follows under the application module<br>

```gradle
Expand Down
2 changes: 1 addition & 1 deletion docs/AndroidAopCollectMethod.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class MyApp extends Application {

- For those who are interested in implementing Router by themselves, this aspect can help you find what you want

- Adapting routing library [such as this ARouter adapts AGP8 Example](https://github.com/FlyJingFish/AndroidAOP/wiki/%E5%88%87%E9%9D%A2%E5%90%AF%E7%A4%BA#5%E4%B8%89%E6%96%B9%E8%B7%AF%E7%94%B1%E5%BA%93%E6%B2%A1%E6%9C%89%E9%80%82%E9%85%8D-agp8-%E4%B8%8B%E9%9D%A2%E4%BB%A5-arouter-%E4%B8%BA%E4%BE%8B%E6%95%99%E4%BD%A0%E5%A6%82%E4%BD%95%E5%88%A9%E7%94%A8-androidaop-%E8%A7%A3%E5%86%B3%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98)
- Adapting routing library [such as this ARouter adapts AGP8 Example](/AndroidAOP/Implications/#5-is-the-third-party-routing-library-not-compatible-with-agp8-here-is-an-example-of-arouter-to-teach-you-how-to-use-androidaop-to-solve-this-problem)

- Another new way to use singletons that are both thread-safe and lazy-loaded!
```java
Expand Down
43 changes: 31 additions & 12 deletions docs/AndroidAopMatchClassMethod.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Brief description

This aspect is used to match a class and its corresponding method. This aspect focuses on the execution of the method (Method Execution). Please note the difference between it and [@AndroidAopReplaceClass](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopReplaceClass).
This aspect is used to match a class and its corresponding method. This aspect focuses on the execution of the method (Method Execution). Please note the difference between it and [@AndroidAopReplaceClass](/AndroidAOP/AndroidAopReplaceClass).

```kotlin
@AndroidAopMatchClassMethod(
Expand Down Expand Up @@ -35,7 +35,7 @@ This aspect is used to match a class and its corresponding method. This aspect f

!!! note
In addition, not all classes can be hooked in<br> <li>```type``` Type is ```SELF``` When ```targetClassName``` is set, the class must be the code in the installation package.
For example: if this class (such as Toast) is in **android.jar**, it will not work. If you have such a requirement, you should use [@AndroidAopReplaceClass](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopReplaceClass)</li><br> <li>```type``` When the type is not ```SELF```, this aspect needs to have a matching method to work. If the subclass does not override the matching method, the subclass will not be matched. Use overrideMethod to ignore this restriction</li> <br> <li><strong>When you modify the configuration of this aspect, in most cases you should clean the project and continue development</strong></li>
For example: if this class (such as Toast) is in **android.jar**, it will not work. If you have such a requirement, you should use [@AndroidAopReplaceClass](/AndroidAOP/AndroidAopReplaceClass)</li><br> <li>```type``` When the type is not ```SELF```, this aspect needs to have a matching method to work. If the subclass does not override the matching method, the subclass will not be matched. Use overrideMethod to ignore this restriction</li> <br> <li><strong>When you modify the configuration of this aspect, in most cases you should clean the project and continue development</strong></li>

## Create an aspect processing class

Expand All @@ -48,18 +48,18 @@ interface MatchClassMethod {
```

!!! note
If the point function is suspend [Click here to view](https://github.com/FlyJingFish/AndroidAOP/wiki/Suspend-%E5%88%87%E7%82%B9%E5%87%BD%E6%95%B0)
If the point function is suspend [Click here to view](/AndroidAOP/AOP_Helper/)

- [ProceedJoinPoint Introduction](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint)
- [Introduction to invoke return value](https://github.com/FlyJingFish/AndroidAOP/wiki/%E5%88%87%E7%82%B9%E6%96%B9%E6%B3%95%E8%BF%94%E5%9B%9E%E5%80%BC)
- [Life Cycle](https://github.com/FlyJingFish/AndroidAOP/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#6%E5%8C%B9%E9%85%8D%E5%88%87%E9%9D%A2%E5%92%8C%E6%B3%A8%E8%A7%A3% E5%88%87%E9%9D%A2%E7%9A%84%E5%88%87%E9%9D%A2%E5%A4%84%E7%90%86%E7%B1%BB%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%98%AF% E6%80%8E%E6%A0%B7%E7%9A%84) ## Matching rules
- [ProceedJoinPoint Introduction](/AndroidAOP/ProceedJoinPoint/)
- [Introduction to invoke return value](https://flyjingfish.github.io/AndroidAOP/Pointcut_return/)
- [Life Cycle](/AndroidAOP/FAQ/#6-what-is-the-life-cycle-of-the-aspect-processing-class-of-the-matching-aspect-and-the-annotation-aspect) ## Matching rules

You can see that in the following examples, some of the method names are set with only the method name, while others also have the return value type and parameter type. The following is an introduction

### Fuzzy matching

- 1. When targetClassName ends with `.*` and has other characters, and `type = MatchType.SELF`, it matches all classes under the package, including subpackages [as shown in Example 9 below](#%E4%BE%8B%E4%B9%9D)
- 2. When methodName has only one method name `*`, it matches all methods in the class [as shown in Example 8 below](#%E4%BE%8B%E5%85%AB)
- 1. When targetClassName ends with `.*` and has other characters, and `type = MatchType.SELF`, it matches all classes under the package, including subpackages [as shown in Example 9 below](#example-9)
- 2. When methodName has only one method name `*`, it matches all methods in the class [as shown in Example 8 below](#example-8)
- 3. When methodName only writes the method name but does not write the return type and parameter type, it is also a fuzzy match, which will add all methods with the same name in the target class to the cut point

!!! note
Expand All @@ -83,7 +83,7 @@ Matching formula: **Return value type method name (parameter type, parameter typ
- Different from targetClassName, if the method parameter and return value type are inner classes, they need to be replaced with `$` instead of `.`

!!! note
[AOP Code Generation Assistant](https://github.com/FlyJingFish/AndroidAOP/wiki/AOP-%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90%E5%8A%A9%E6%89%8B), which can help you generate code with one click
[AOP Code Generation Assistant](/AndroidAOP/AOP_Helper/), which can help you generate code with one click

Below is a comparison table of Kotlin and Java with different types. If it is Kotlin code, please check the corresponding code

Expand Down Expand Up @@ -348,9 +348,9 @@ class MatchTestBean : MatchClassMethod {

If the cut point method is ```suspend``` What about modified functions?

- You can directly use [Fuzzy Matching](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod#%E6%A8%A1%E7%B3%8A%E5%8C%B9%E9%85%8D)
- You can directly use [Fuzzy Matching](#fuzzy-matching)

- If you want to use [Exact Matching](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod#%E7%B2%BE%E5%87%86%E5%8C%B9%E9%85%8D), the writing is as follows. For specific rules, see [Exact Matching](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod#%E7%B2%BE%E5%87%86%E5%8C%B9%E9%85%8D)
- If you want to use [Exact Matching](#precise-matching), the writing is as follows. For specific rules, see [Exact Matching](#precise-matching)

```kotlin
package -
Expand All @@ -372,7 +372,7 @@ class MainActivity : BaseActivity2() {
}
```

The exact match is written as follows. Regardless of the return value type of the matching function, write ```suspend```. For details, see the [Exact Matching Part](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod#%E7%B2%BE%E5%87%86%E5%8C%B9%E9%85%8D)
The exact match is written as follows. Regardless of the return value type of the matching function, write ```suspend```. For details, see the [Exact Matching Part](#precise-matching)

```kotlin
@AndroidAopMatchClassMethod(
Expand All @@ -397,6 +397,25 @@ class MatchAllMethod : MatchClassMethod {
```
Write only one method name and fill in * to match all methods

#### Example 8

Want to match all methods of a class

```kotlin
@AndroidAopMatchClassMethod(
targetClassName = "com.flyjingfish.androidaop.SecondActivity",
methodName = ["*"],
type = MatchType.SELF
)
class MatchAllMethod : MatchClassMethod {
override fun invoke(joinPoint: ProceedJoinPoint, methodName: String): Any? {
Log.e("MatchMainAllMethod", "AllMethod======$methodName");
return joinPoint.proceed()
}
}
```
Write only one method name and fill in * to match all methods

#### Example 9

Want to match all methods of all classes in a package
Expand Down
8 changes: 4 additions & 4 deletions docs/AndroidAopPointCut.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ interface BasePointCut<T : Annotation> {
```

!!! note
If the point cutting function is suspend [Click here to view](https://github.com/FlyJingFish/AndroidAOP/wiki/Suspend-%E5%88%87%E7%82%B9%E5%87%BD%E6%95%B0)
If the point cutting function is suspend [Click here to view](/AndroidAOP/Suspend_cut/)

- [Introduction to ProceedJoinPoint](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint)
- [Introduction to invoke return value](https://github.com/FlyJingFish/AndroidAOP/wiki/%E5%88%87%E7%82%B9%E6%96%B9%E6%B3%95%E8%BF%94%E5%9B%9E%E5%80%BC)
- [Life Cycle](https://github.com/FlyJingFish/AndroidAOP/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#6%E5%8C%B9%E9%85%8D%E5%88%87%E9%9D%A2%E5%92%8C%E6%B3%A8%E8%A7%A3%E 5%88%87%E9%9D%A2%E7%9A%84%E5%88%87%E9%9D%A2%E5%A4%84%E7%90%86%E7%B1%BB%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%98%AF %E6%80%8E%E6%A0%B7%E7%9A%84) ### For example
- [Introduction to ProceedJoinPoint](/AndroidAOP/ProceedJoinPoint/)
- [Introduction to invoke return value](https://flyjingfish.github.io/AndroidAOP/Pointcut_return/)
- [Life Cycle](https://flyjingfish.github.io/AndroidAOP/FAQ/#6-what-is-the-life-cycle-of-the-aspect-processing-class-of-the-matching-aspect-and-the-annotation-aspect) ### For example

CustomInterceptCut inherits from BasePointCut. You can see that there is a generic on BasePointCut. This generic is the @CustomIntercept annotation above. The two are related to each other.
```kotlin
Expand Down
16 changes: 8 additions & 8 deletions docs/AndroidAopReplaceClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ This function belongs to the advanced function, special attention should be paid

This aspect is used to replace the method call in the code, and needs to be used in conjunction with @AndroidAopReplaceMethod. When the replaced method is called, it will enter the method annotated with @AndroidAopReplaceMethod

- _Note that this method is essentially different from the other two. The first two focus on the execution of the method, and automatically retain the method that can execute the original logic (i.e. [ProceedJoinPoint](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint));_
- _Note that this method is essentially different from the other two. The first two focus on the execution of the method, and automatically retain the method that can execute the original logic (i.e. [ProceedJoinPoint](https://flyjingfish.github.io/AndroidAOP/ProceedJoinPoint/));_
- _This focuses on the method call, which replaces all the calling places with the static methods of the class you set, and does not automatically retain the method that executes the original logic_
- **_The advantage of this method is that it can "equivalently" monitor the call of certain system methods (code in android.jar), and the first two do not have this feature, so if it is not based on this requirement, it is recommended to use [@AndroidAopMatchClassMethod](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod)_**
- **_The advantage of this method is that it can "equivalently" monitor the call of certain system methods (code in android.jar), and the first two do not have this feature, so if it is not based on this requirement, it is recommended to use [@AndroidAopMatchClassMethod](https://flyjingfish.github.io/AndroidAOP/AndroidAopMatchClassMethod/)_**

!!! note
<li>To sum up, this function can be said to be a supplement to [@AndroidAopMatchClassMethod](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod) (the code in android.jar cannot be woven into AOP code). The reason why [ProceedJoinPoint](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint) is not used is that this method may be restricted by different versions of Android. It can neither use reflection to call the original method nor weave in AOP code, so it cannot be encapsulated with [ProceedJoinPoint](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint). If you really want to use it, it is recommended to use [MatchClassMethodProxy](#4androidaopmatchclassmethod-%E7%9A%84%E4%BB%A3%E7%90%86%E7%94%A8%E6%B3%95) </li><br> <li><strong>After you modify the configuration of this aspect, you should clean the project before continuing development</strong></li>
<li>To sum up, this function can be said to be a supplement to [@AndroidAopMatchClassMethod](https://flyjingfish.github.io/AndroidAOP/AndroidAopMatchClassMethod/) (the code in android.jar cannot be woven into AOP code). The reason why [ProceedJoinPoint](https://flyjingfish.github.io/AndroidAOP/ProceedJoinPoint/) is not used is that this method may be restricted by different versions of Android. It can neither use reflection to call the original method nor weave in AOP code, so it cannot be encapsulated with [ProceedJoinPoint](https://github.com/FlyJingFish/AndroidAOP/wiki/ProceedJoinPoint). If you really want to use it, it is recommended to use [MatchClassMethodProxy](#4androidaopmatchclassmethod-%E7%9A%84%E4%BB%A3%E7%90%86%E7%94%A8%E6%B3%95) </li><br> <li><strong>After you modify the configuration of this aspect, you should clean the project before continuing development</strong></li>

## 1. Description

⚠️⚠️⚠️ Note: The defined replacement class should be placed within the scan rules you set [here include exclude Rules](https://github.com/FlyJingFish/AndroidAOP?tab=readme-ov-file#%E5%9B%9B%E5%9C%A8-app-%E7%9A%84buildgradle%E6%B7%BB%E5%8A%A0-androidaopconfig-%E9%85%8D%E7%BD%AE%E9%A1%B9%E6%AD%A4%E6%AD%A5%E4%B8%BA%E5%8F%AF%E9%80%89%E9%85%8D%E7%BD%AE%E9%A1%B9), it will not work if written outside the scope
⚠️⚠️⚠️ Note: The defined replacement class should be placed within the scan rules you set [here include exclude Rules](https://flyjingfish.github.io/AndroidAOP/getting_started/#4-add-the-androidaopconfig-configuration-item-in-apps-buildgradle-this-step-is-an-optional-configuration-item), it will not work if written outside the scope

### @AndroidAopReplaceClass

Expand Down Expand Up @@ -72,7 +72,7 @@ For example, this method changes `new Thread()` to `new MyThread()`

- The annotated method must be public and static, but the method name can be defined arbitrarily

- The annotated method is the replacement method; the parameter is the method to be replaced, which must include the return type and parameter type. The matching rules are as follows [matching rules](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopReplaceClass#%E4%B8%89-androidaopreplacemethod-%E5%8C%B9%E9%85%8D%E8%A7%84%E5%88%99)
- The annotated method is the replacement method; the parameter is the method to be replaced, which must include the return type and parameter type. The matching rules are as follows [matching rules](https://flyjingfish.github.io/AndroidAOP/AndroidAopReplaceClass/#2-matching-rules)

- If the replaced method is a static method of the class, the parameter type, order and number of the replacement method you define should be consistent

Expand All @@ -94,7 +94,7 @@ For specific writing requirements, please refer to the usage method below

You can see that the return value type and parameter type are written in the example below. The following is an introduction

**The difference from [@AndroidAopMatchClassMethod](https://github.com/FlyJingFish/AndroidAOP/wiki/@AndroidAopMatchClassMethod#%E5%8C%B9%E9%85%8D%E8%A7%84%E5%88%99) is that this must be an exact match, and the writing is as follows:**
**The difference from [@AndroidAopMatchClassMethod](https://flyjingfish.github.io/AndroidAOP/AndroidAopMatchClassMethod/) is that this must be an exact match, and the writing is as follows:**

Matching writing formula: **Return value type method name (parameter type, parameter type...)**

Expand All @@ -108,7 +108,7 @@ Matching writing formula: **Return value type method name (parameter type, param
- Different from the replacement class name filled in, if the method parameter and return value type are inner classes, they need to be replaced with `$` instead of `.`

!!! note
[AOP Code Generation Assistant](https://github.com/FlyJingFish/AndroidAOP/wiki/AOP-%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90%E5%8A%A9%E6%89%8B), can help you generate code with one click
[AOP Code Generation Assistant](https://flyjingfish.github.io/AndroidAOP/AOP_Helper/), can help you generate code with one click

Below is a table showing different types of Kotlin vs. Java. If it is Kotlin code, please check the corresponding code

Expand Down Expand Up @@ -317,4 +317,4 @@ class ReplaceToastProxy : MatchClassMethodProxy() {
So you can For some system methods, `ProceedJoinPoint` is used to control the method call. The key is to use `@ProxyMethod` to mark the method, so that the information returned by `ProceedJoinPoint` is the method information of the replaced class>

!!! note
[AOP code generation assistant](https://github.com/FlyJingFish/AndroidAOP/wiki/AOP-%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88% 90%E5%8A%A9%E6%89%8B), which can help you generate proxy usage code with one click
[AOP code generation assistant](https://flyjingfish.github.io/AndroidAOP/AOP_Helper/), which can help you generate proxy usage code with one click
Loading

0 comments on commit dc31365

Please sign in to comment.