Skip to content

Commit

Permalink
Update Hook Method.
Browse files Browse the repository at this point in the history
Update Log Output.
  • Loading branch information
HChenX committed Aug 27, 2023
1 parent e06536f commit e923bec
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 78 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ android {
//noinspection OldTargetApi
targetSdk 33
//noinspection HighAppVersionCode
versionCode 2023082601
versionName "3.4"
versionCode 2023082702
versionName "3.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.release
Expand Down
58 changes: 48 additions & 10 deletions app/src/main/java/Com/HChen/Hook/HookMode/HookLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,78 @@

import android.util.Log;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;

public class HookLog {
String Tag = "[ HChenHook ]: ";
public abstract class HookLog extends XC_MethodHook {
String Tag;
String Tags;

public void setLog(String classLog, String nameLog) {
logSI("Hook Class: " + classLog + " methodName: " + nameLog);
public int smOr() {
return -1;
}

public void setLog(String classLog) {
logSI("Hook Class: " + classLog);
public void setTag() {
if (smOr() == 1) {
Tag = "[ HChenHook ]: SystemHook: ";
} else if (smOr() == 2) {
Tag = "[ HChenHook ]: MiuiHook: ";
} else {
Tag = "[ HChenHook ]: ";
}
}

public void setTags(int smOr) {
if (smOr == 1) {
Tags = "[ HChenHook ]: SystemHook: ";
} else if (smOr == 2) {
Tags = "[ HChenHook ]: MiuiHook: ";
}
}

public HookLog() {
super();
}

public HookLog(int priority) {
super(priority);
}

public void setLog(int smOr, String classLog, String nameLog) {
logSI(smOr, "Hook Class: " + classLog + " methodName: " + nameLog);
}

public void setLog(int smOr, String classLog) {
logSI(smOr, "Hook Class: " + classLog);
}

public void logI(String Log) {
setTag();
XposedBridge.log(Tag + "I: " + Log);
}

public void logW(String Log) {
setTag();
XposedBridge.log(Tag + "Warning by: " + Log);
}

public void logE(String Log) {
setTag();
XposedBridge.log(Tag + "Error by: " + Log);
}

public void logSI(String log) {
Log.i(Tag, "I: " + log);
public void logSI(int smOr, String log) {
setTags(smOr);
Log.i(Tags, "I: " + log);
}

public void logSW(String log) {
public void logSW(int smOr, String log) {
setTags(smOr);
Log.w(Tag, "I: " + log);
}

public void logSE(String log) {
public void logSE(int smOr, String log) {
setTags(smOr);
Log.e(Tag, "I: " + log);
}
}
7 changes: 3 additions & 4 deletions app/src/main/java/Com/HChen/Hook/HookMode/HookMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public Class<?> findClassIfExists(String newClassName, String oldClassName) {
}
}

public static class HookAction extends XC_MethodHook {
HookLog hookLog = new HookLog();
public static class HookAction extends HookLog {

protected void before(MethodHookParam param) throws Throwable {
}
Expand All @@ -74,7 +73,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
try {
before(param);
} catch (Throwable e) {
hookLog.logE("[ HChenHook ]: " + e);
logE("[ HChenHook ]: " + e);
}
}

Expand All @@ -83,7 +82,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
after(param);
} catch (Throwable e) {
hookLog.logE("[ HChenHook ]: " + e);
logE("[ HChenHook ]: " + e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/Com/HChen/Hook/HookMode/HookRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Com.HChen.Hook.SystemService.SystemService;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class HookRun {
public class HookRun {
LoadPackageParam loadPackageParam;

public void HookPackage(LoadPackageParam loadPackageParam) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/Com/HChen/Hook/HookName/SystemName.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public final class SystemName {
public static final String updateMaxCachedProcesses = "updateMaxCachedProcesses";
public static final String updateKillBgRestrictedCachedIdle = "updateKillBgRestrictedCachedIdle";
public static final String updateLowMemStateLSP = "updateLowMemStateLSP";
public static final String setMemFactorOverride = "setMemFactorOverride";
public static final String setOverrideMaxCachedProcesses = "setOverrideMaxCachedProcesses";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
import de.robv.android.xposed.XC_MethodHook;

public class PowerKeeper extends HookMode {
@Override
public int smOr() {
return 2;
}

@Override
public void init() {
hookAllMethods(ProcessManager,
kill,
new HookAction() {
@Override
protected void before(XC_MethodHook.MethodHookParam param) {
setLog(ProcessManager, kill);
setLog(2, ProcessManager, kill);
param.setResult(null);
}
}
Expand All @@ -24,7 +29,7 @@ protected void before(XC_MethodHook.MethodHookParam param) {
new HookAction() {
@Override
protected void after(MethodHookParam param) {
setLog(PressureStateSettings, "PROCESS_CLEANER_ENABLED");
setLog(2, PressureStateSettings, "PROCESS_CLEANER_ENABLED");
setBoolean(param.thisObject, "PROCESS_CLEANER_ENABLED", false);
}
}
Expand Down
Loading

0 comments on commit e923bec

Please sign in to comment.