[dev] 模仿qa的修改dpi功能,写了一小段java代码放到自己制作的模块里,但激活后不起作用
- Dominant language
- Java
- Stars
- 5.7k
- Forks
- 416
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 4
Description
### 描述 / Description
代码片段:
```java
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Class CompatibilityInfo = XposedHelpers.findClass("android.content.res.CompatibilityInfo", XposedBridge.BOOTCLASSLOADER);
Class ActivityThread = XposedHelpers.findClass("android.app.ActivityThread", XposedBridge.BOOTCLASSLOADER);
if (Build.VERSION.SDK_INT <= 31) {
XposedHelpers.findAndHookMethod(
ActivityThread,
"handleConfigurationChanged",
Configuration.class,
CompatibilityInfo,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@Override
protected void beforeHookedMethod(MethodHookParam p) throws Throwable {
Configuration config = (Configuration) p.args[0];
if (config != null) {
config.densityDpi=240;
}
}
});
} else {
Class ConfigurationController = XposedHelpers.findClass("android.app.ConfigurationController", XposedBridge.BOOTCLASSLOADER);
XposedHelpers.findAndHookMethod(
ConfigurationController,
"handleConfigurationChanged",
Configuration.class,
CompatibilityInfo,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@Override
protected void beforeHookedMethod(MethodHookParam p) throws Throwable {
Configuration config = (Configuration) p.args[0];
if (config != null) {
config.densityDpi = 240;
}
}
});
}
}
```
LSP 日志里没有任何报错信息,模块正常加载,hook 的软件是自己写的 hello world,但是激活后不起作用,想请教一下这个 dpi 修改功能是怎么起作用的
### 其他要求 / Other Requirements
- [X] 我已经在 [Issue Tracker](https://github.com/cinit/QAuxiliary/issues) 中找过我要提出的问题,没有找到相同问题。重复问题会被关闭。
- [X] 我知晓此 Issue 模板仅限开发者使用,普通用户请使用问题反馈或功能请求模板。 / I know this issue template is for developers only. Regular users should use the bug report or feature request template.
Contributor guide
Research direction
Start by tracing the module's handleLoadPackage entry point and the handleConfigurationChanged hooks shown in the issue, checking the Android SDK branches and the LSP loading logs. Compare the behavior in the self-written Hello World app with the stated goal of changing densityDpi to 240; done means the app visibly uses the changed density and the module still loads without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100