You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): resolve document providers once per selection - #13147
Resolve each document-provider authority once while validating a native file-picker result. Keep the cache local to one result and still check the content scheme, authority, provider ownership and read permission for every selected URI.
Why it's needed
The follow-up review of #12126 identified repeated provider-resolution Binder calls for documents from the same authority. Before this change, a selection of 100 documents from one provider performs 100 resolutions. The new code performs one resolution while retaining all 100 permission checks. This addresses the nonblocking provider-cache suggestion separately from the already merged file-selection feature. The Phase 1 design also gains synchronized English/Chinese notices linking to the implemented file-selection design, addressing the stale-documentation finding in the same parent review.
Reviewer Test Plan
How to verify
From packages/mobile-shell, run ./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:testDebugUnitTest :app:lintDebug.
With an Android emulator/device attached, run ./gradlew :app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.qwen.mobileshell.FilePickerDeviceTest.
The new same-provider test accepts 100 granted documents twice on the same picker: each result must resolve its provider again and check every URI grant. The per-document-grant test must reject a selection whose second document lacks a grant despite sharing the first document's provider. The mixed-authority test must reject the unsafe result and observe a separate package-manager access for the fixture provider and the settings provider. Existing unsafe-provider, URI, limit, callback and lifecycle tests remain unchanged.
Evidence (Before & After)
The actual production controller was also compiled and executed in a local JVM harness with controlled Android API stubs. Both cache-count assertions fail on upstream 0a5f518b4f73 and pass with this change; all nine behavioral/security controls pass before and after.
Selection
Before: provider resolutions
After: provider resolutions
URI permission checks
100 documents, one authority
100
1
100
100 documents, two authorities
100
2
100
The harness also checks provider ownership/availability changes between requests, denied URI grants, unsafe/unknown/same-UID providers, deduplication and the selection limit. These are controller call-count observations, not Android UI timing measurements. The checked-in Android tests count accesses to the package manager at the controller's provider-resolution boundary and delegate real permission checks to the target context. To verify R1-1, the three actual checked-in test methods were also executed through JUnit on the JVM with controlled Android API stubs: production passes all three; both a one-slot cache without an authority key and a manager-hoisting/no-cache mutation pass the old two tests but fail the new mixed-authority test (expected 2 manager accesses, observed 1). This mutation execution is not Android instrumentation.
Tested on
OS
Status
macOS
Not run
Windows
APK and test APK assembled; 21 JVM unit tests passed; lint: 0 errors, 6 existing dependency-version warnings; local controller harness: 11/11 passed
Linux
Upstream Android CI on previous head 70256adaa9: API 26: 22 passed / 4 expected skips; API 36: 25 passed / 1 expected skip; all 19 file-picker tests passed on both; CI for the updated test head is pending
Environment
Windows, JDK 17, Gradle 8.2.1, Android SDK 34. The instrumentation tests were compiled and packaged, but have not been executed on an Android emulator or physical device locally.
Risk & Scope
Main risk: a cache lasting across requests could hide provider changes; the map is local to one validation invocation and the repeated-selection test pins this lifetime.
Not validated: local Android instrumentation execution, third-party provider behavior or UI latency. Android CI/device execution remains required.
Breaking changes / migration: none. No permission checks or URI restrictions are relaxed.
What this PR does
Resolve each document-provider authority once while validating a native file-picker result. Keep the cache local to one result and still check the content scheme, authority, provider ownership and read permission for every selected URI.
Why it's needed
The follow-up review of #12126 identified repeated provider-resolution Binder calls for documents from the same authority. Before this change, a selection of 100 documents from one provider performs 100 resolutions. The new code performs one resolution while retaining all 100 permission checks. This addresses the nonblocking provider-cache suggestion separately from the already merged file-selection feature. The Phase 1 design also gains synchronized English/Chinese notices linking to the implemented file-selection design, addressing the stale-documentation finding in the same parent review.
Reviewer Test Plan
How to verify
packages/mobile-shell, run./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:testDebugUnitTest :app:lintDebug../gradlew :app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.qwen.mobileshell.FilePickerDeviceTest.Evidence (Before & After)
The actual production controller was also compiled and executed in a local JVM harness with controlled Android API stubs. Both cache-count assertions fail on upstream
0a5f518b4f73and pass with this change; all nine behavioral/security controls pass before and after.The harness also checks provider ownership/availability changes between requests, denied URI grants, unsafe/unknown/same-UID providers, deduplication and the selection limit. These are controller call-count observations, not Android UI timing measurements. The checked-in Android tests count accesses to the package manager at the controller's provider-resolution boundary and delegate real permission checks to the target context. To verify R1-1, the three actual checked-in test methods were also executed through JUnit on the JVM with controlled Android API stubs: production passes all three; both a one-slot cache without an authority key and a manager-hoisting/no-cache mutation pass the old two tests but fail the new mixed-authority test (expected 2 manager accesses, observed 1). This mutation execution is not Android instrumentation.
Tested on
70256adaa9: API 26: 22 passed / 4 expected skips; API 36: 25 passed / 1 expected skip; all 19 file-picker tests passed on both; CI for the updated test head is pendingEnvironment
Windows, JDK 17, Gradle 8.2.1, Android SDK 34. The instrumentation tests were compiled and packaged, but have not been executed on an Android emulator or physical device locally.
Risk & Scope
Linked Issues
Follow-up to #12126, related to #11704 and #13111. Reviewer evidence: #12126 (comment).
中文说明
本 PR 的改动
验证原生文件选择器结果时,每个文档提供程序 authority 只解析一次。缓存仅存在于本次结果处理中;仍对每个选中的 URI 检查 content scheme、authority、提供程序所有者以及读取权限。
为什么需要
#12126 的后续评审指出,同一 authority 下的多个文档会重复触发提供程序解析的 Binder 调用。改动前,同一个提供程序的 100 个文档会触发 100 次解析;改动后只解析一次,同时保留全部 100 次权限检查。本 PR 单独处理这一非阻塞缓存建议,不扩大已合入文件选择功能的范围。Phase 1 设计文档同时添加同步的中英文说明,链接到已实现的文件选择设计,处理同一次原 PR 评审中的文档过时问题。
评审测试计划
如何验证
packages/mobile-shell运行./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:testDebugUnitTest :app:lintDebug。./gradlew :app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.qwen.mobileshell.FilePickerDeviceTest。证据(改动前后)
另用受控 Android API 桩构建本地 JVM harness,编译并运行实际生产控制器。在 upstream
0a5f518b4f73上,两项缓存调用次数断言均失败;改动后均通过。其余九项行为与安全控制在改动前后均通过。Harness 还检查请求之间提供程序所有者或可用性的变化、URI 授权拒绝、危险或未知或同 UID 的提供程序、去重以及数量上限。这些数据是控制器调用次数,不是 Android UI 耗时。提交的 Android 测试统计控制器解析提供程序时对 package manager 的访问,并把实际权限判断委托给目标 context。R1-1 的三个实际测试方法还通过 JUnit 在受控 Android API 桩的 JVM 上执行:生产实现全部通过;无 authority 键的单槽缓存和移出循环但不缓存解析的两种变异均通过旧的两项测试,却在新增混合 authority 测试上失败(应为 2 次访问,实际 1 次)。这一变异验证不是 Android instrumentation。
本地测试环境
70256adaa9的 upstream Android CI:API 26 为 22 通过 / 4 预期跳过;API 36 为 25 通过 / 1 预期跳过;两者均通过全部 19 项 file-picker 测试;新增测试提交的 CI 待运行环境
Windows、JDK 17、Gradle 8.2.1、Android SDK 34。Instrumentation 测试已编译打包,但本地尚未在 Android 模拟器或真机上执行。
风险与范围
关联
#12126 的后续工作,关联 #11704、#13111。评审证据:https://github.com/QwenLM/qwen-code/pull/12126#issuecomment-5848429760。