Skip to content

Commit

Permalink
fix: show avid (yujincheng08#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyHai authored Jan 3, 2025
1 parent 4c328a6 commit e065e7c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/src/main/java/me/iacn/biliroaming/hook/EnvHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.iacn.biliroaming.hook

import android.content.SharedPreferences
import me.iacn.biliroaming.utils.*
import java.lang.reflect.Proxy
import java.util.regex.Pattern

class EnvHook(classLoader: ClassLoader) : BaseHook(classLoader) {
Expand Down Expand Up @@ -40,6 +41,31 @@ class EnvHook(classLoader: ClassLoader) : BaseHook(classLoader) {
}
}

"com.bilibili.lib.blconfig.internal.OverrideConfig".findClassOrNull(mClassLoader)
?.hookBeforeAllConstructors { param ->
val delegate = param.args.getOrNull(0) ?: return@hookBeforeAllConstructors
val realConfig = param.args.getOrNull(1) ?: return@hookBeforeAllConstructors
val delegateClass = delegate.javaClass
param.args[0] = Proxy.newProxyInstance(
delegateClass.classLoader,
delegateClass.interfaces
) { _, m, a ->
val args = a ?: emptyArray()
if (m.name == "getConfig") {
var result: Any? = null
val key = args[0]
for (config in configSet) {
if (sPrefs.getBoolean(config.config, false) && config.key == key) {
result = realConfig.callMethodOrNull("get", *args)
}
}
result ?: m(delegate, *args)
} else {
m(delegate, *args)
}
}
}

// // Disable tinker
// "com.tencent.tinker.loader.app.TinkerApplication".findClass(mClassLoader)?.hookBeforeAllConstructors { param ->
// param.args[0] = 0
Expand Down

0 comments on commit e065e7c

Please sign in to comment.