Skip to content

fix: parse aa dump missions separately and prefer FOREGROUND - #2

Draft
tonycoder-hub wants to merge 1 commit into
masterfrom
cursor/fix-current-app-mission-parse-9371
Draft

fix: parse aa dump missions separately and prefer FOREGROUND#2
tonycoder-hub wants to merge 1 commit into
masterfrom
cursor/fix-current-app-mission-parse-9371

Conversation

@tonycoder-hub

@tonycoder-hub tonycoder-hub commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Intended as an upstream PR against codematrixer/hmdriver2 master (fixes codematrixer#52 and codematrixer#42 there). The cloud token cannot open that PR; from a fork with write access run:

gh pr create --repo codematrixer/hmdriver2 --head tonycoder-hub:cursor/fix-current-app-mission-parse-9371 --base master

Problem

current_app() parsed hdc shell aa dump -l with:

re.findall(r'Mission ID #[\s\S]*?isKeepAlive: false\s*}', output)

The trailing } belongs to current mission lists:{ ... }, not to a single mission. findall therefore returned one match covering the whole dump. The first bundle name / main name in that match was used — typically a BACKGROUND app — even when a later mission was FOREGROUND.

Changes

  • Drop the trailing } so each mission is one regex match.
  • Extract _parse_current_app() and prefer missions with state #FOREGROUND / app state #FOREGROUND.
  • Add device-free unit tests using the dump from current_app()结果不对 codematrixer/hmdriver2#52 (photos BACKGROUND + yang FOREGROUND). current_app() returns yang, not photos.

No device is required to run:

pytest tests/test_current_app.py
Open in Web Open in Cursor 

current_app() included the dump's closing '}' in the mission regex, so
findall swallowed the whole list as one match and returned the first
bundle name (often BACKGROUND). Drop the trailing '}' so each mission
is one match, and return the FOREGROUND app when several exist.

Fixes codematrixer#52
Fixes codematrixer#42

Co-authored-by: Tony Jin <407243179@qq.com>
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.

current_app()结果不对

2 participants