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

[BUG] 开关无法实时生效 #9

Closed
inused opened this issue Feb 18, 2021 · 4 comments
Closed

[BUG] 开关无法实时生效 #9

inused opened this issue Feb 18, 2021 · 4 comments

Comments

@inused
Copy link

inused commented Feb 18, 2021

什么情况/What happened?

设置开关无法实时生效

看代码里面的流程是下面这样的

  1. 根据设置项判断是否需要进行hook
  2. 需要hook的话 -> 直接将修改验证结果的代码注入(注入的代码中没有开关状态判断逻辑)
  3. 不需要hook -> 不注入修改结果的代码

这样的话就只能是 Android 进程(不懂Android开发,不知道是不是这玩意)起来也就是开机的时候就已经确定下来了最终会不会修改验证结果,而开机之后已经不会判断开关状态更不会改变注入Android进程中的代码了,也就是说再修改开关状态也是没啥用了。

所以我想判断开关状态的逻辑不应该放在外面而应该放在注入系统进程的代码中(应该是afterHookedMethod()方法中?百度出来的方法名,没开发过xp模块不太懂),这样在安装应用的时候才能实时获取开关状态来决定要不要修改验证结果。

另外看代码中用 XSharedPreferences 来保存/获取配置信息,使用的时候是new出来的,那么这玩意是不是在判断开关状态的时候重新new一个新的才能获取最新数据?

LSPosed及Riru版本/Version of LSPosed及Riru版本 and Riru

LSPosed: 0.5.4.1-5178

Riru: v23.5

核心破解版本/Version of Core Patch?
version: 3.3
Android 11

相关日志/Related Logs

无日志

@inused inused added the bug label Feb 18, 2021
@inused
Copy link
Author

inused commented Feb 18, 2021

修改了下代码测试了一下,将开关状态判断逻辑放在了 afterHookedMethod() 方法中,里面是重新new出来的 XSharedPreferences 获取开关状态,确实可以实时生效,但是安装一次应用会疯狂重复打印一堆日志,这是会重复进行很多次验证吗,那么应该会多消耗一些资源,但是比起功能来说影响不算大,不知道有没有其他更好的方式

@coderstory
Copy link
Contributor

coderstory commented Mar 30, 2021

如果要实时生效必然每次调用前都需要读取一次配置
XSharedPreferences 有reload方法 不需要每次都new 一个

@coderstory
Copy link
Contributor

旧版本都是这么干的 只是新版本 代码全部重写了 没加上去

@coderstory
Copy link
Contributor

预计3.6上线

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants