Repository navigation
fix: resolve app_current() from visible tasks instead of window focus - #1207
Open
codeskyblue-agent wants to merge 1 commit into
Open
codeskyblue-agent wants to merge 1 commit into
codeskyblue-agent wants to merge 1 commit into
Conversation
app_current() delegated to adbutils, which reads mCurrentFocus from dumpsys window windows first. Floating windows, dialogs and secondary displays can hold that focus; on Android 13+ the fallback to dumpsys activity top returns the last ACTIVITY, which is often a background app (WhatsApp/Telegram) that is still alive. Parse dumpsys activity activities instead: take the primary display, skip tasks that are explicitly not visible, read topResumedActivity/ mResumedActivity from the first visible task and its app ProcessRecord for the pid. Keep the adbutils call as a fallback for keyguard, screen off or unusual vendor output so DeviceError semantics do not change.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1207 +/- ##
==========================================
+ Coverage 45.26% 45.88% +0.62%
==========================================
Files 29 29
Lines 4158 4204 +46
Branches 812 828 +16
==========================================
+ Hits 1882 1929 +47
+ Misses 2164 2160 -4
- Partials 112 115 +3 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is by an automated agent, not a human.
变更
app_current() previously delegated to adbutils, which reads window focus first and, on Android 13+, falls back to the last ACTIVITY in
dumpsys activity top; floating windows, secondary displays and still-alive background apps could therefore be reported as current. It now parsesdumpsys activity activities, prefers the primary display, skips tasks marked visible=false, reads topResumedActivity/mResumedActivity from the first visible task and extracts the matching app ProcessRecord pid. The adbutils path remains as a fallback for keyguard, screen-off or unusual vendor output, so DeviceError semantics are unchanged. app_wait(front=True) and wait_activity() benefit without API changes.改动
Closes #1085
提交
检查
✅ 检查通过(2 项)
功能验证
UI 验证
未涉及 UI 改动,无截图。