Skip to content

Commit

Permalink
完善日志,增加 throws
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Jun 19, 2024
1 parent 0917a8b commit 59f890c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 28 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencyResolutionManagement {

```groovy
dependencies {
implementation 'com.github.HChenX:HookTool:v.0.9.6.3'
implementation 'com.github.HChenX:HookTool:v.0.9.6.5'
}
```

Expand Down Expand Up @@ -188,7 +188,7 @@ public class MainTest extends BaseHC {

new IAction() {
@Override
public void before(ParamTool param) {
public void before(ParamTool param) throws Throwable {
// hook 方法所属的类
Class<?> c = param.mClass;

Expand Down
19 changes: 2 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id 'maven-publish'
}

def defVersion = 'v.0.9.6.3'
int defVersionCode = 2024061705
def defVersion = 'v.0.9.6.5'
int defVersionCode = 2024061900

group = 'com.github.HChenX'
version = defVersion
Expand All @@ -19,10 +19,6 @@ android {
// noinspection HighAppVersionCode
versionCode defVersionCode
versionName defVersion
// ndk {
// noinspection ChromeOsAbiSupport
// abiFilters 'arm64-v8a', 'armeabi-v7a'
// }
}

buildTypes {
Expand Down Expand Up @@ -58,20 +54,9 @@ tasks.register('androidSourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs
}

// getTasks().withType(JavaCompile) {
// options.compilerArgs += ['-Xplugin:Manifold']
// }

dependencies {
compileOnly libs.xposed
implementation libs.annotation
// implementation libs.dexkit
// implementation libs.jetbrains.annotations
// compileOnly libs.systems.manifold.ext
// implementation libs.annotations
// implementation libs.androidx.annotation.jvm
// implementation libs.jetbrains.annotations
// implementation libs.manifold.ext.rt
}

afterEvaluate {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void beforeHookedMethod(MethodHookParam param) {

new IAction() {
@Override
public void before(ParamTool param) {
public void before(ParamTool param) throws Throwable {
// hook 方法所属的类
Class<?> c = param.mClass;

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/hchen/hooktool/callback/IAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
* Hook 动作接口
*/
public interface IAction {
default void before(ParamTool param) {
default void before(ParamTool param) throws Throwable {
}

default void after(ParamTool param) {
default void after(ParamTool param) throws Throwable {
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/hchen/hooktool/tool/ActionTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ protected Action hookTool(Member member, IAction iAction) {
ParamTool paramTool = new ParamTool(utils);
return new Action(member, utils.getTAG()) {
@Override
protected void before(MethodHookParam param) {
protected void before(MethodHookParam param) throws Throwable {
paramTool.setParam(param);
iAction.before(paramTool);
}

@Override
protected void after(MethodHookParam param) {
protected void after(MethodHookParam param) throws Throwable {
paramTool.setParam(param);
iAction.after(paramTool);
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/hchen/hooktool/tool/ExpandTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.hchen.hooktool.tool;

import static com.hchen.hooktool.log.XposedLog.logD;
import static com.hchen.hooktool.log.XposedLog.logE;
import static com.hchen.hooktool.log.XposedLog.logW;

Expand Down Expand Up @@ -262,6 +263,7 @@ public void hook(Member member, IAction iAction) {
}
try {
XposedBridge.hookMethod(member, utils.getActionTool().hookTool(member, iAction));
logD(utils.getTAG(), "success hook: " + member);
} catch (Throwable e) {
logE(utils.getTAG(), "hook: [" + member + "], failed!", e);
}
Expand All @@ -273,6 +275,7 @@ public void hook(ArrayList<?> members, IAction iAction) {
try {
XposedBridge.hookMethod((Member) o,
utils.getActionTool().hookTool((Member) o, iAction));
logD(utils.getTAG(), "success hook: " + o);
} catch (Throwable e) {
logE(utils.getTAG(), "hook: [" + o + "], failed!", e);
}
Expand All @@ -283,7 +286,7 @@ public void hook(ArrayList<?> members, IAction iAction) {
public IAction returnResult(final Object result) {
return new IAction() {
@Override
public void before(ParamTool param) {
public void before(ParamTool param) throws Throwable {
param.setResult(result);
}
};
Expand All @@ -292,7 +295,7 @@ public void before(ParamTool param) {
public IAction doNothing() {
return new IAction() {
@Override
public void before(ParamTool param) {
public void before(ParamTool param) throws Throwable {
param.setResult(null);
}
};
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/hchen/hooktool/tool/ParamTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class ParamTool extends Arguments {
public Class<?> mClass;
public Member mMember;
public Object[] mParam;

public ParamTool(DataUtils utils) {
super(utils);
Expand All @@ -44,6 +45,7 @@ protected void setParam(XC_MethodHook.MethodHookParam param) {
this.param = param;
mClass = param.method.getDeclaringClass();
mMember = param.method;
mParam = param.args;
}

public <T> T thisObject() {
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[versions]
agp = "8.5.0"
dexkit = "2.0.2"
annotation = "1.8.0"
xposed = "82"

[libraries]
dexkit = { module = "org.luckypray:dexkit", version.ref = "dexkit" }
annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" }
xposed = { group = "de.robv.android.xposed", name = "api", version.ref = "xposed" }

Expand Down

0 comments on commit 59f890c

Please sign in to comment.