Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show avid #1601

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading