Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
KyuubiRan committed Oct 31, 2021
1 parent 08210e3 commit 59ab6f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/me/kyuubiran/qqcleaner/HookEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HookEntry : IXposedHookLoadPackage, IXposedHookZygoteInit {
"com.tencent.mm" -> {
EzXHelperInit.initHandleLoadPackage(lpparam)
EzXHelperInit.setLogTag("QQCleaner")
WeChatHookLoader(lpparam)
WeChatHookLoader()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/kyuubiran/qqcleaner/HookLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class HookLoader(lpparam: XC_LoadPackage.LoadPackageParam) {
initItem()
secondInitQQ = true
} catch (thr: Throwable) {
Log.t(thr)
Log.e(thr)
throw thr
}
}
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/me/kyuubiran/qqcleaner/WeChatHookLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.app.Application
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
import com.github.kyuubiran.ezxhelper.utils.Log
import de.robv.android.xposed.callbacks.XC_LoadPackage
import me.kyuubiran.qqcleaner.data.hostInfo
import me.kyuubiran.qqcleaner.data.init
import me.kyuubiran.qqcleaner.hook.ModuleEntryHook
Expand All @@ -16,9 +15,9 @@ private var firstInit = false
var secondInitWeChat = false
private set

class WeChatHookLoader(lpparam: XC_LoadPackage.LoadPackageParam) {
class WeChatHookLoader {
init {
doInit(lpparam.classLoader)
doInit()
}

private fun initItem() {
Expand All @@ -28,7 +27,7 @@ class WeChatHookLoader(lpparam: XC_LoadPackage.LoadPackageParam) {
}

@SuppressLint("DiscouragedPrivateApi")
private fun doInit(rtLoader: ClassLoader) {
private fun doInit() {
if (firstInit) return
try {
Application::class.java.getDeclaredMethod("onCreate")
Expand All @@ -51,7 +50,7 @@ class WeChatHookLoader(lpparam: XC_LoadPackage.LoadPackageParam) {
firstInit = true
} catch (thr: Throwable) {
if (thr.toString().contains("com.google.android.webview")) return
Log.t(thr)
Log.e(thr)
throw thr
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/me/kyuubiran/qqcleaner/utils/HookUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object HookUtil {
internal fun Member.hook(callback: XC_MethodHook) = try {
XposedBridge.hookMethod(this, callback)
} catch (thr: Throwable) {
Log.t(thr)
Log.e(thr)
null
}

Expand All @@ -21,7 +21,7 @@ object HookUtil {
override fun beforeHookedMethod(param: MethodHookParam?) = try {
hooker(param!!)
} catch (thr: Throwable) {
Log.t(thr)
Log.e(thr)
}
})

Expand All @@ -30,7 +30,7 @@ object HookUtil {
override fun afterHookedMethod(param: MethodHookParam?) = try {
hooker(param!!)
} catch (thr: Throwable) {
Log.t(thr)
Log.e(thr)
}
})

Expand Down

0 comments on commit 59ab6f4

Please sign in to comment.