fix: prevent delayed accessibility events from overwriting foreground cache - #571
Open
DeanTMaxim wants to merge 1 commit into
Open
fix: prevent delayed accessibility events from overwriting foreground cache#571DeanTMaxim wants to merge 1 commit into
DeanTMaxim wants to merge 1 commit into
Conversation
Prevent delayed window-state events from replacing the foreground package cache unless the active root confirms both the event window and package. Add policy tests for both maintained namespaces.
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.
Summary / 变更概述
Prevent delayed accessibility window-state events from overwriting the cached foreground package/activity when their original window no longer exists.
避免原窗口已经消失的延迟无障碍窗口状态事件覆盖当前前台包名/Activity 缓存。
Closes #570. Related symptom report: #529.
Root cause / 根因
Both
ActivityInfoProviderimplementations used:If
getWindow(event.windowId)returnsnull, Kotlin evaluatesnull != falseastrue. A delayed event from a disappeared SystemUI/launcher/app window could therefore be accepted as if it were focused and replacemLatestPackage/mLatestActivity.两个
ActivityInfoProvider实现都使用了上述判断。当getWindow(event.windowId)返回null时,Kotlin 中null != false的结果为true,所以来自已消失窗口的延迟事件可能被当作聚焦事件接纳,并覆盖mLatestPackage/mLatestActivity。Fix / 修复方式
Apply the following policy consistently to both maintained namespaces:
rootInActiveWindow.在两个维护中的命名空间内统一应用以下策略:
rootInActiveWindow一致时接纳。Changed namespaces / 修改的命名空间:
org.autojs.autojs.core.activitycom.stardust.autojs.core.activityTests / 测试
Added six policy cases for each namespace (12 tests total):
两个命名空间各增加 6 个策略用例,共 12 个测试,覆盖聚焦、未聚焦、活动根窗口 ID 不匹配、活动根包名不匹配、活动根确认以及缺少包名证据。
TDD evidence / TDD 证据:
eventWindowFocused != falsepolicy, all six missing-window regression cases failed across the two namespaces.tests="6",failures="0",errors="0"(12/12 passed).Full verification command / 完整验证命令:
Result / 结果:
Verification note / 验证说明
Current
masterhas unrelated compilation errors introduced with the bottom log sheet (console_debug/console_verboseresource references and obsoleteAutoJs.getInstance()calls). They are already covered by #556. To run the full unit-test task, equivalent corrections were applied locally only, the full task was rerun, and those corrections were then reverted. This PR does not contain the unrelated bottom-sheet changes.当前
master的底部日志面板存在与本修复无关的编译错误(console_debug/console_verbose资源引用以及过时的AutoJs.getInstance()调用),#556 已处理这些问题。为执行完整单元测试,本地仅临时应用了等效修正;测试完成后已恢复。本 PR 不包含这些无关的底部日志面板改动。The original symptom and event/window mismatch were also reproduced on an OPPO Android test device using ADB and accessibility-window inspection. Device identifiers, accounts, and application data are omitted.
原始现象及事件/窗口不匹配也已在一台 OPPO Android 测试机上通过 ADB 和无障碍窗口检查复现;设备标识、账号和应用数据均已省略。