Skip to content

fix(lyrics): issues of custom lyrics and lyrics blur in HyperOS 3 devices - #71

Open
Havenmab wants to merge 2 commits into
Zennmn:mainfrom
Havenmab:fix/lyrics-current-item-field
Open

Havenmab wants to merge 2 commits into
Zennmn:mainfrom
Havenmab:fix/lyrics-current-item-field

Conversation

@Havenmab

@Havenmab Havenmab commented Sep 30, 2026 •

Copy link
Copy Markdown

Update

根据建议,只改混淆名:6.5.2 的 LYRICS_CURRENT_ITEM_FIELD 从 fragment.m 改为 fragment.l
在 6.5.2 6.5.3 测试通过。

症状

设备:Xiaomi 15、Xiaomi Pad 7S Pro 12.5 [Xiaomi HyperOS 3 (Android 16)]
Apple Music 版本:6.5.2 (1586)、6.5.3 (1599)

  • 设置页 →「自定义歌词」→「获取 ID」始终提示 "未获取到当前歌曲信息,请先在 Apple Music 播放一首歌",即使歌曲正在播放。
  • 自定义歌词替换完全不生效,包括手动填写 Apple Music ID 新建的映射。
  • 开启歌词模糊后,第4、5行不会模糊。
  • 两个能力在模块日志里同时报告降级:
current_song_identity: DEGRADED - lyrics-current-item-field was ambiguous (2 candidates):
    com.apple.android.music.player.fragment.e#U:com.apple.android.music.model.BaseContentItem,
    com.apple.android.music.player.fragment.l#c:com.apple.android.music.model.BaseContentItem
    [apple-music-6.5.2-1586]
custom_lyrics:         DEGRADED - <同一句>

一个原因同时解释两个症状:两条链路共用同一个"当前歌词条目"字段 seam。

根因

TargetSymbols.kt 中:

  • LyricsCurrentItemField 使用 EXACT_PREFERRED,先尝试 TargetSymbolId.LYRICS_CURRENT_ITEM_FIELD 钉住的类,再回退到结构候选。
  • 6.5.2 档案把该符号钉在 com.apple.android.music.player.fragment.m,且钉住的名字契约要求字段名为 c。在实测设备上该 pin 未产生任何候选(fragment.m 在解析诊断中一次都没出现),于是回退到结构扫描。
  • 结构扫描在 PlayerLyricsViewFragment 的继承链上找到两个 BaseContentItem 字段:fragment.e#U 与 fragment.l#c。按项目"Ambiguous 不允许取第一个"的约定,解析保持未安装,两项能力一起降级。

修复

不动任何版本档案的 pin,只在结构候选里应用项目已经验证过的字段名契约作为裁决:

  • 抽出 VERIFIED_LYRICS_CURRENT_ITEM_FIELD_NAME = "c",与既有的 isLyricsCurrentItemField 共用同一常量,避免两处漂移;
  • 结构候选先取名字等于该常量的子集,取不到就退回完整候选集(未知宿主仍然 Ambiguous,绝不静默绑定错误字段)。

依据

  • 字段名 c 是既有契约(isLyricsCurrentItemField 中写死并已被 6.5.0–6.5.3 档案依赖);
  • 6.5.1 档案钉的正是 fragment.l;
  • 两个候选中只有 fragment.l#c 满足该契约,fragment.e#U 不满足。

变更

app/src/main/java/dev/amenhancer/module/hook/TargetSymbols.kt              |  25 +++-
app/src/test/java/dev/amenhancer/module/hook/LyricsCurrentItemFieldStructuralTest.kt | 136 ++++
2 files changed, 159 insertions(+), 2 deletions(-)

新增 3 条 JVM 测试:

  • 结构回退在继承歧义中优先选择已验证字段名;
  • 字段被改名时仍然 fail-closed,不绑定错误字段;
  • 唯一候选场景不受影响。

验证

已验证项

项 结果
./gradlew test :app:assembleDebug 构建成功,836 项 / 0 失败(含新增 3 项)
真机(Xiaomi HyperOS 3 / Android 16 / Apple Music 6.5.2 6.5.3) 获取 id、自动替换歌词、歌词模糊均正常

未验证项

在搭载 HyperOS 3 (Android 16) 的 Xiaomi 15、Xiaomi Pad 7S Pro 12.5 上,Apple Music 6.5.2、6.5.3 上验证均通过。但无法保证在其他系统上(如 ColorOS)是否有破坏性影响。

The 6.5.2 profile pinned com.apple.android.music.player.fragment.m, which
declares no matching field on the real APK, so the symbol fell through to the
structural scan and failed closed with two candidates.  Both
current_song_identity and custom_lyrics inherit that failure, which is why the
settings page's "获取 ID" button always claimed no song was playing and custom
lyrics never replaced anything on 6.5.2.

The correct owner is fragment.l: it is where the field named `c` that
isLyricsCurrentItemField already requires lives, and 6.5.1 pins the same owner.
@Havenmab
Havenmab force-pushed the fix/lyrics-current-item-field branch from b0d356e to 39ec393 Compare September 30, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant