Skip to content

fix: parse foldable display size from 4607 dump - #4

Open
tonycoder-hub wants to merge 1 commit into
masterfrom
cursor/fix-foldable-display-resolution-273a
Open

fix: parse foldable display size from 4607 dump#4
tonycoder-hub wants to merge 1 commit into
masterfrom
cursor/fix-foldable-display-resolution-273a

Conversation

@tonycoder-hub

Copy link
Copy Markdown
Owner

Fixes codematrixer#17.

HdcWrapper.display_size used the first activeMode: WxH on hidumper -s RenderService -a screen. On foldables that dump lists every panel, and the inner activeMode stays in the text after fold (or when locked). The first match is then (0,0)-adjacent wrong: the stale inner panel, not the live cover.

Conclusion after reading the issue + dumps

  • The five RenderService screenshots are the bug report: lock / unlock / unfold / fold / fold-lock. When folded + unlocked, screen[0] is POWER_STATUS_OFF 2496x2224 and screen[1] is POWER_STATUS_ON 1080x2504. The old regex always takes 2496x2224.
  • Huawei’s later reply is the right primary source: hdc shell hidumper -s 4607 -a "-a" (DisplayManagerService). That dump’s FoldStatus + Bounds<L,T,W,H> (boxed in the screenshot) already track the current fold configuration. PhyBounds is ignored so we do not double-count.
  • 4607 is therefore the first hidumper call. RenderService remains a fallback: pick POWER_STATUS_ON, then SUSPEND (locked single panel). If every physical panel is OFF (locked foldable), do not guess the stale inner mode — return (0,0) and let 4607 win.

No device required. tests/test_display_size.py uses the issue dump text (lock/unlock/fold) plus the 4607 sample. Those tests assert the old activeMode: regex still returns the stale inner size / (0,0), and the new parser returns the live panel.

Open in Web Open in Cursor 

The first activeMode: match on RenderService output is wrong on
foldables: the inner panel stays in the dump after fold. Prefer
DisplayManagerService (hidumper -s 4607) Bounds/FoldStatus, and
fall back to the POWER_STATUS_ON RenderService panel.

Fixes codematrixer#17

Co-authored-by: Tony Jin <407243179@qq.com>
@tonycoder-hub
tonycoder-hub marked this pull request as ready for review August 18, 2026 19:46
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.

鸿蒙设备获取分辨率可能存在误差,未考虑折叠屏的情况

2 participants