Repository navigation
feat(mobile): support scoped native document selection (Phase 2) - #12126
Conversation
Native file selection — E2E verificationTested commit:
Baseline: the parent APK's actual running WebChromeClient declined single/multiple chooser requests ( Actual UI acceptance: a user-activation touch into an HTML input opened DocumentsUI. Selecting one synthetic text file delivered its exact name and bytes to JavaScript Committed regression coverage: open intent permissions/MIME hints, unsupported modes and stale documents, cancellation with an outstanding OS result, restored in-flight ownership, exactly-once callbacks, unsafe/ungranted URI rejection, document changes and missing picker handler, plus existing encrypted-storage/profile-isolation device tests. The final API 35 run used a normally built test APK containing only the 12 committed tests, without the local acceptance harness. Limits: the UI fixture used synthetic files and localhost, not a real daemon or TLS endpoint. Physical devices, all third-party providers, actual process death/rotation, camera, microphone and downloads were not verified here. Recreation/orphan-result behavior has controller coverage. This report describes local results; it does not claim that pending upstream CI has run. Earlier acceptance-harness selector mistakes were corrected and retained in local logs; the final three UI cases above passed without product changes. The full local plan, commands, raw outputs and screenshots are preserved under 中文测试摘要验证提交为 另有 3 个真实 HTML / DocumentsUI 验收用例全部通过:单选读取准确文件内容、多选读取两个文件内容、取消后输入为空且重新选择成功。每个用例均确认任意 file/content 访问仍禁用。基线仅直接验证真实 WebChromeClient 拒绝请求,没有声称完成 HTML 界面基线;全局 CLI 无法运行原生 APK,因而使用独立的 Android 测试工具。 测试仅使用模拟器、本地页面和合成文件。未验证真机、实际 daemon/TLS、所有第三方提供方或实际进程死亡/旋转;重建时孤立结果有控制器测试覆盖。相机、麦克风、下载不在本 PR 范围。上游 CI 状态不能由这些本地结果替代。测试工具的选择器错误已修正并保留原始日志;最终三个界面用例未修改产品代码即通过。原始证据保存在上述忽略目录中,不进入产品 diff。 |
|
Guard integration verification for Merged the verified #12121 profile-initialization guard
Debug APK SHA256: These are local results. This remains a dependent draft; maintainer review/workflow authorization, real devices/daemon TLS and combined microphone/picker lifetime acceptance remain outstanding. 中文验收已推送 这些是本地结果,仍为依赖草稿;维护者评审/工作流授权、真机/daemon TLS 及麦克风与选择器共同生命周期验收尚待完成。 |
cb4ac40 to
f01990a
Compare
|
Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. 中文请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。 |
|
September 18 post-merge rebase verification: #11722 has merged. I removed its already-merged history and rebased this slice onto Fresh checks on this exact head:
Modern runs required profile isolation. The legacy provider cannot establish supported browser-profile operation: unsupported profile/clear cases are skips, not passes; it also cannot exercise the intermediate provider with profile support but no completed clear. Earlier screenshots and extra interactive/adversarial scenarios remain prior evidence for identical code, not fresh runs. Combined-feature and physical-device acceptance are not claimed. The shared JavaScript check and its two reproduced upstream-baseline limitations are detailed in the September 18 report on #12130; this native slice does not change those JavaScript sources. A successful full repository build is not claimed. This one-time rebase was needed to remove the merged scaffold history and resolve the resulting conflicts. I have noted the force-push reminder; further review fixes will be additive commits. Please review the focused slice when convenient; I am available to address feedback. 中文:#11722 已合并,本切片已变基并重新验证;实现文件与之前发布的版本逐字节相同。Android 构建和 lint 通过,JVM 21 项通过;API36 为 14 通过/1 跳过,API26 为 11 通过/4 跳过,跳过项未计入通过。合并顺序仍依赖 #12121,其他功能切片未组合验收。完整 JS 构建/集成类型检查仍有在上游基线复现的问题,详见 #12130 的本次说明;不会声称全部检查通过。已记录避免 force-push 的提醒,后续评审修改将追加提交。请维护者评审,我会继续处理反馈。 |
Maintainer verification: real Web Shell + daemon on Android (head
|
| # | Scenario | Result |
|---|---|---|
| Build | assembleDebug/assembleRelease, androidTest APK, testDebugUnitTest, lintDebug |
Pass. 21 JVM tests pass. Lint: 0 errors, 6 GradleDependency warnings (same as the author reports) |
| Suite | Committed instrumentation suite, API 36 | 14 pass, 1 assumption skip. FilePickerDeviceTest 8/8 |
| Suite | Committed instrumentation suite, API 26 / WebView 58 | 11 pass, 4 assumption skips. FilePickerDeviceTest 8/8 |
| A | Parent APK: + → Attach files | No picker opens and the page only gets a cancel event. The baseline reproduces |
| S1 | PR APK: Attach files, pick 1 file | OPEN_DOCUMENT + OPENABLE, typ=*/*, flg=0x1. The page's File SHA-256 matches the host fixture (4f8f8de7…, UTF-8 intact), and the content appears in the model's main-turn request |
| S2 | Pick 2 files at once | Both names and byte contents arrive (3b68b43d…, 288d9141…), and both reach the model request |
| S3 | Upload to workspace: 256 KiB random .bin |
The file on disk in the daemon workspace has the identical SHA-256 (4a14c13a…) |
| S4 | Back out of the picker, then reopen | The page gets a native cancel event (the H5's focus and query restore depends on it). Reopening and picking works |
| S5 | Photos (image/*) |
typ=image/*. The PNG arrives with a matching hash |
| S6 | Extension archive input (.zip,.tar.gz,application/zip,application/gzip) |
Only .zip and .tar.gz are selectable, everything else is greyed out. The .tar.gz arrives as application/gzip with matching bytes |
| S7 | Page reloads while the picker is open, then pick a file | The new document gets nothing: no change event and no attachment. The next picker works |
| S8 | Activity recreated (cmd uimode night yes) while the picker is open, then pick a file |
The app lands on Connections. After reconnecting there is no stale attachment, and the next picker works |
| S9 | Select 100 files | All 100 upload |
| S10 | Select 101 files | Nothing uploads and no message is shown (see F1) |
| Perms | aapt2 dump permissions, parent vs PR |
Identical: INTERNET only. No storage, media or camera permission |
Findings (non-blocking)
F1: selecting more than 100 files discards the whole selection with no feedback (panels G–I).
- What happens: if the result has more than 100 items,
validateResultreturnsnull(clip.itemCount > 100). In the real app, selecting 101 files in "Upload to workspace" uploads nothing, and the page sees onlycancel. - What the page does elsewhere: the PR says the cap matches the H5 batch limit, but the H5 behaves differently.
useFileUploadtakes the first 100 files and shows "N more files were not added (limit per batch)". I confirmed this in desktop Chromium against the same daemon: 101 files → 100 uploaded plus that notice. - Candidate fix (diff): show a toast with the rejection, 5 lines plus one string. Tested with the same 101 selection: the toast appears ("Select up to 100 files at a time. Nothing was added."), and the committed picker tests still pass 8/8.
- Caveat: the app has no notification permission (
POST_NOTIFICATION: ignore), so Android suppresses the toast if the result arrives while the app is not in the foreground. I saw that happen once in a disordered run. - Alternative: pass the selection through and let the H5 apply its own limit, which would match desktop.
F2: "Take photo" opens an image document picker, not the camera (panel J). #12252 (merged 09-20, after this PR's base) added Photos and Take photo to the mobile + menu. Take photo sets accept=image/* and capture=environment. With this PR, that item opens "Images in Downloads" in DocumentsUI, even though a camera app is installed (com.android.camera2/.CaptureActivity resolves). The PR explicitly leaves capture out of scope, so this is not a defect in this PR. But once it merges, the shell shows a Take photo item that cannot take a photo. Suggested follow-up: hide or relabel the item when running inside the Android shell, or implement capture.
F3: the committed tests never exercise the accepting path. I ran 12 mutants of NativeFilePicker.kt against the committed FilePickerDeviceTest on API 36.
- Killed (5): removing
checkUriPermission, releasing the in-flight slot on cancel, ignoring the in-flight flag inopen, forcingEXTRA_ALLOW_MULTIPLEto false, and ignoring the restored flag. - Survived (7):
validateResultalways returnsnull, meaning the feature would never deliver a file.- The own-UID check is dropped.
- The single-selection cardinality check is dropped.
- The 100-item cap is dropped.
isCurrent()is no longer checked on the result.- The
contentscheme check is dropped. - The grant-flag check is dropped.
- Why they survive: no committed test supplies a valid, granted URI, so every rejection case is already caught by an earlier guard. The only evidence for the positive path is the author's uncommitted DocumentsUI harness and this run.
- What I tried: an instrumentation-side provider can't produce a real grant, because test code runs under the app's UID;
checkUriPermissionstayedDENIED. - Suggestion: commit the UiAutomator DocumentsUI harness, or make the resolve/grant check injectable so that a positive case can be tested.
Observations (no action needed)
onPageStarted→cancel()is defense in depth on WebView 133. I rebuilt the APK with that line removed and reloaded the page while the picker was open. The lateRESULT_OKstill reached the stale callback (dumpsys activity permissionsshows the grant toMainActivity), and Chromium discarded it; the new document received nothing. Chromium also allows only one chooser at a time: a second user-gestureclick()on another file input while the picker was open produced neither a second picker nor acancelevent. If it had reachedonShowFileChooser, the native in-flight guard would have cancelled it and the page would have seencancel. Keeping both native guards is reasonable.- The OS grant includes write access. DocumentsUI grants
mode=0x3(read and write) withpersistable=0x3. The app never persists it (persisted=0x0) and only reads. "No persistent grant" holds; "read-only" describes how the app uses the grant, not the grant itself. - Not covered:
- Process death while the picker is open.
am killcannot kill the app while DocumentsUI is on top of it, andkill -9sends the task home, so the restored-flag path is covered only by the controller test (that mutant is killed). - Physical devices, third-party document providers, and TLS.
- A second device on an RK3588 host:
redroid:16didn't boot there (netdaborts inlibnetd_updatable_init).
- Process death while the picker is open.
- CI and precheck:
- CI is green on this head, including Android Mobile Shell (build/lint, API 26 and API 36).
- The precheck's
prompt_injection:print_secretsflag is a false positive: the matches are the design docs' credential-handling wording. - This PR stacks on feat(mobile): add encrypted, isolated connection profiles (Phase 2) #12121, which is still open at
a765ac1ecf. The feature commitf01990a750itself touches only 7 files, so re-sync after feat(mobile): add encrypted, isolated connection profiles (Phase 2) #12121 settles.
中文说明
维护者验证:Android 上的真实 Web Shell + daemon(head a0b589b9d2)
结论:本切片没有阻塞问题,按 PR 所述在 #12121 之后合并。 原生选择器端到端可用。我在 PR APK 里点击 Web Shell 现有的文件输入,在系统 DocumentsUI 中选文件,字节原样到达页面、真实 qwen serve 工作区和模型请求。取消、迟到结果和 Activity 重建的行为都与描述一致。下面有三个非阻塞的后续项,其中一项附 5 行候选补丁。
验证内容
- 被测代码: head
a0b589b9d2,以及 GitHub merge refc532d25250(head + main0adae3c254),两者的packages/mobile-shell完全相同。“修复前”一臂使用 feat(mobile): add encrypted, isolated connection profiles (Phase 2) #12121 heada765ac1ecf构建的父版本 APK。 - 主机与设备: macOS arm64,JDK 17、Gradle 8.2.1、SDK 34。模拟器为 API 36
google_apisarm64(WebView 133.0.6943.137,Google DocumentsUI)和 API 26(WebView 58)。 - daemon 与模型: 用 merge ref 构建的打包
dist/cli.js serve --require-auth。bearer token 通过应用自己的配置编辑器录入,设备经adb reverse访问 daemon。模型是脚本化的 OpenAI 兼容服务,记录每个请求体。 - 驱动方式: WebView 内用真实
adb input点击,DocumentsUI 用 uiautomator 操作,页面状态通过 CDP 读取。页面上挂了捕获阶段探针,记录每个<input type=file>的change/cancel事件,以及每个文件的名称、大小、类型和 SHA-256。
| # | 场景 | 结果 |
|---|---|---|
| 构建 | debug/release、androidTest APK、单元测试、lint | 通过。21 个 JVM 测试全部通过;lint 0 错误、6 条 GradleDependency 警告(与作者报告一致) |
| 套件 | 已提交的 instrumentation 套件,API 36 | 14 通过、1 个 assumption 跳过;FilePickerDeviceTest 8/8 |
| 套件 | 已提交的 instrumentation 套件,API 26 / WebView 58 | 11 通过、4 个 assumption 跳过;FilePickerDeviceTest 8/8 |
| A | 父版本 APK:+ → Attach files | 不打开选择器,页面只收到 cancel。基线复现 |
| S1 | PR APK:Attach files,选 1 个文件 | OPEN_DOCUMENT + OPENABLE、typ=*/*、flg=0x1。页面 File 的 SHA-256 与宿主夹具一致(4f8f8de7…,UTF-8 完好),内容出现在模型主轮次请求中 |
| S2 | 一次选 2 个文件 | 两个文件的名称和字节都正确到达(3b68b43d…、288d9141…),都进入模型请求 |
| S3 | Upload to workspace:256 KiB 随机 .bin |
daemon 工作区中落盘文件的 SHA-256 完全一致(4a14c13a…) |
| S4 | 在选择器中按返回,然后重开 | 页面收到原生 cancel 事件(H5 恢复焦点和 @ 查询依赖它)。重开后能正常选择 |
| S5 | Photos(image/*) |
typ=image/*,PNG 到达且哈希一致 |
| S6 | 扩展归档输入(.zip,.tar.gz,application/zip,application/gzip) |
只有 .zip、.tar.gz 可选,其余置灰。.tar.gz 以 application/gzip 到达,字节一致 |
| S7 | 选择器打开期间页面重载,然后选文件 | 新文档什么都没收到:没有 change 事件,也没有附件。之后选择器正常 |
| S8 | 选择器打开期间 Activity 重建(cmd uimode night yes),然后选文件 |
应用回到连接列表。重连后没有残留附件,之后选择器正常 |
| S9 | 选 100 个文件 | 100 个全部上传 |
| S10 | 选 101 个文件 | 一个都没上传,也没有任何提示(见 F1) |
| 权限 | aapt2 dump permissions,父版本对比 PR |
完全相同,只有 INTERNET;没有存储、媒体或相机权限 |
发现(均非阻塞)
F1:选择超过 100 个文件时,整批被丢弃且没有任何反馈(图 G–I)。
- 现象: 结果超过 100 项时,
validateResult返回null(clip.itemCount > 100)。在真实应用里,“Upload to workspace”选 101 个文件后一个都不上传,页面只收到cancel。 - H5 的行为: PR 说这个上限与 H5 批次上限一致,但 H5 的做法不同:
useFileUpload收下前 100 个,并提示“N more files were not added (limit per batch)”。我在桌面 Chromium 上连同一 daemon 验证过:101 个文件 → 上传 100 个并出现该提示。 - 候选修复(见上方 diff 链接): 拒绝时弹出 Toast,5 行代码加 1 条字符串。用同样的 101 个文件实测,Toast 正常出现(“Select up to 100 files at a time. Nothing was added.”),已提交的选择器测试仍为 8/8。
- 注意: 应用没有通知权限(
POST_NOTIFICATION: ignore),结果送达时如果应用不在前台,Toast 会被系统压掉。我在一次状态混乱的运行里见到过。 - 另一种做法: 把选择原样交给 H5,由它施加自己的上限,与桌面行为一致。
F2:“Take photo”打开的是图片文档选择器,而不是相机(图 J)。 #12252(9 月 20 日合入,晚于本 PR 的基点)在移动端 + 菜单加了 Photos 和 Take photo。Take photo 设置了 accept=image/* 和 capture=environment。在本 PR 下,这一项打开的是 DocumentsUI 的“Images in Downloads”,尽管设备上装了相机应用(com.android.camera2/.CaptureActivity 可以解析)。PR 明确把拍照排除在范围外,所以这不是本 PR 的缺陷;但合入后,壳里会出现一个无法拍照的“Take photo”菜单项。建议后续:在 Android 壳内隐藏或改名这一项,或者实现拍照。
F3:已提交的测试从未覆盖“接受”路径。 我对 NativeFilePicker.kt 做了 12 个变异,在 API 36 上跑已提交的 FilePickerDeviceTest。
- 被杀死(5 个): 删掉
checkUriPermission、取消时释放在途占位、open忽略在途标志、EXTRA_ALLOW_MULTIPLE强制为 false、忽略恢复的标志。 - 存活(7 个):
validateResult恒返回null,即功能永远不会交付任何文件。- 删掉本应用 UID 检查。
- 删掉单选数量检查。
- 删掉 100 项上限。
- 结果处理时不再检查
isCurrent()。 - 删掉
contentscheme 检查。 - 删掉授权标志检查。
- 存活原因: 没有任何已提交测试提供合法且已授权的 URI,所以每条拒绝用例都被更早的守卫挡住。“接受”路径的证据只有作者未提交的 DocumentsUI 工具和本次验证。
- 我的尝试: 在 instrumentation 侧用 provider 无法造出真实授权,因为测试代码以应用的 UID 运行,
checkUriPermission一直是DENIED。 - 建议: 把 UiAutomator 驱动 DocumentsUI 的测试提交进来,或者把 provider 解析/授权检查改成可注入,以便测试正向用例。
观察(无需处理)
- 在 WebView 133 上,
onPageStarted→cancel()属于纵深防御。 我去掉这一行重新构建 APK,在选择器打开时重载页面。迟到的RESULT_OK仍然送到了旧回调(dumpsys activity permissions显示授权给了MainActivity),但被 Chromium 丢弃,新文档什么都没收到。Chromium 也只允许同时存在一个选择器:选择器打开时,对另一个文件输入发起带用户手势的click(),既没有出现第二个选择器,也没有触发cancel事件。如果它到达了onShowFileChooser,原生在途守卫会取消它,页面就会收到cancel。保留两道原生守卫是合理的。 - 系统授权包含写权限。 DocumentsUI 授予的是
mode=0x3(读和写)、persistable=0x3。应用从未将其持久化(persisted=0x0),也只做读取。“不持久授权”成立;“只读”指应用的使用方式,而不是授权本身。 - 未覆盖:
- 选择器打开期间进程被杀。DocumentsUI 在上层时
am kill杀不掉应用,kill -9又会把任务退回桌面,所以恢复标志的路径只由控制器测试覆盖(对应变异体已被杀死)。 - 真机、第三方文档提供方和 TLS。
- 在 RK3588 主机上用第二台设备:
redroid:16在那台机器上起不来(netd在libnetd_updatable_init中 abort)。
- 选择器打开期间进程被杀。DocumentsUI 在上层时
- CI 与 precheck:
- 本 head 的 CI 全绿,包括 Android Mobile Shell(构建/lint、API 26、API 36)。
- precheck 的
prompt_injection:print_secrets标记是误报:命中的是设计文档中关于凭据处理的措辞。 - 本 PR 叠在 feat(mobile): add encrypted, isolated connection profiles (Phase 2) #12121 之上,后者仍处于 open 状态(
a765ac1ecf)。功能提交f01990a750本身只改了 7 个文件,feat(mobile): add encrypted, isolated connection profiles (Phase 2) #12121 定稿后需要重新同步。
|
@qwen-code /resolve |
|
Qwen Code did not run conflict resolution for this request. PR #12126 comes from the fork |
|
Merge conflicts with This PR conflicts with Since "Allow edits from maintainers" is not enabled on this PR, I could not push the resolution directly. Instead I merged current To update this PR, run on your local branch: git checkout feat/android-phase2-file-picker
git pull --ff-only https://github.com/QwenLM/qwen-code.git merge-fix/pr-12126
git push origin feat/android-phase2-file-pickerResolution approach: kept Alternatively, enable "Allow edits from maintainers" and I will push the merge directly. 与 此 PR 与 由于此 PR 未开启 "Allow edits from maintainers",我无法直接推送解决结果,改为将当前 请在本地分支执行: git checkout feat/android-phase2-file-picker
git pull --ff-only https://github.com/QwenLM/qwen-code.git merge-fix/pr-12126
git push origin feat/android-phase2-file-picker解决方式:保留 或者开启 "Allow edits from maintainers",我可以直接推送合并结果。 |
Head branch was pushed to by a user without write access
|
The current Ubuntu |
|
Please rebase — this PR carries ~130 commits that are already merged into The Files tab shows 1,231 files, +147,111/−51,284, but the actual feature delta is only 7 files, +355/−1. Verified locally against the current head ( Same root cause as #12130: the branch merged Please rebase onto current |
a4c94bb to
41cbe43
Compare
|
I’ve rebased this PR onto the current |
|
@qwen-code /triage |
|
Updated in 2138ad9. The accepting path is now committed: a test-APK provider issues real per-URI read grants, and tests verify accepted single/multiple callbacks and read the selected synthetic bytes. Stale-document rejection now uses an otherwise accepted result. Single-MIME intent type, ordering/deduplication, cardinality, same-UID/missing grant/mixed unsafe rejection and inclusive100/exclusive101 limits are pinned. The fixture revokes grants and cleans its synthetic files. Local Windows/JDK17 validation: debug, release and instrumentation APKs build; 21 JVM tests and Android lint pass. The 17 picker device tests compile but were not executed on a local emulator; current-head API26/36 CI is running. The PR body now reflects the already-merged #12121 and separates historical screenshots from new evidence. Full Activity wiring/recreation and real-daemon/physical-device acceptance remain separate from the controller fixture. 中文:提交新增真实测试 APK 提供程序、逐 URI 授权及成功读取字节的断言,补齐单选/多选、迟到结果、MIME、授权和数量边界。debug/release/测试 APK 构建、21 项 JVM 测试及 lint 通过;17 项文件选择设备测试仅完成编译,等待当前提交 API26/36 CI。描述已修正基础 PR 状态和历史证据归属,完整 Activity 接线及真实 daemon/真机验收仍另行验证。 Rebased onto main 中文:已变基到 main The first hosted run exposed a separate test-process dependency failure: a Kotlin provider could not load kotlin.jvm.internal.Intrinsics from the target app. The fixture provider is now Java with no Kotlin runtime references (verified in the compiled test APK DEX). The corrected instrumentation APK builds; fresh API26/36 runs must validate the full provider path. 中文:首次托管运行发现独立测试进程无法加载目标应用中的 Kotlin runtime。夹具提供程序已改为不依赖 Kotlin runtime 的 Java,并验证测试 APK DEX 中无相关引用。修正后的测试 APK 编译通过,完整提供程序路径等待新的 API26/36 运行。 The next API26 run exercised all 24 instrumentation tests: one assertion failed because instrumentation.context.applicationInfo reported UID 0, although PackageManager correctly resolved the fixture provider UID. The test now obtains provider-owner ApplicationInfo from PackageManager through a test-only ContextWrapper; URI resolution and read grants remain real. The same URI is first accepted by the target context, then rejected by the matching-UID context, preserving the guard regression. The updated test APK builds. Fresh API26/36 CI is required on this final head. 中文:后续 API26 运行执行全部24项设备测试,其中一项断言因 instrumentation context 的 ApplicationInfo 错报 UID0 失败。现在通过 PackageManager 获取提供程序所有者信息,仅在测试 ContextWrapper 中使用;URI 解析和授权保持真实。同一 URI 先由目标 context 接受,再由相同 UID context 拒绝,保留回归保护。新的测试 APK 构建通过,最终提交等待 API26/36 CI。 |



What this PR does
Enables Android system document selection for existing Web Shell single/multiple file inputs. Only readable, granted content URIs from external providers are returned; cancellation and stale results cannot transfer files to a replacement document. The file-selection slice introduces no production storage permission or persistent grant.
Current head:
2138ad957aee4939412f2100b99b7a09581ebbc7. #11722 and #12121 are already merged. This branch was rebased ontomainat9e60263fdeff; the diff contains this feature and its review fixes. It remains an independent Phase 2 slice, awaiting current-head CI and maintainer approval.Why it's needed
The development shell declines file-chooser callbacks, preventing existing attachment and workspace upload flows from selecting Android documents. H5 retains capability checks, upload destinations and payload limits.
Reviewer Test Plan
How to verify
From
packages/mobile-shell, rungradlew.bat --no-daemon assembleDebug assembleRelease assembleDebugAndroidTest testDebugUnitTest lintDebugwith JDK 17.Run
FilePickerDeviceTestusingconnectedDebugAndroidTeston API 26 and 36. The 17 cases include single/multiple successful selection with real URI grants and byte reads, MIME hints, deduplication, single cardinality, missing/ineffective grants, same-UID rejection, unsafe mixed selections, inclusive 100/exclusive 101 limits, cancellation and stale results. Then exercise actual HTML inputs and DocumentsUI. Explicitly recreate the Activity to test in-flight ownership; rotation alone is insufficient because configuration changes are handled in place.Evidence (Before & After)
The earlier controller suite could pass if every selection was rejected. This revision commits a provider in the separate test APK, protected by a test-only permission, and checks accepted URIs and their actual bytes. The stale-result test now has an accepted positive control. Both APKs compile; the new device cases have not been run locally.
Earlier screenshots below are historical feature evidence from prior commits, not a rerun on this revision.
The first hosted run exposed a separate test-process dependency failure: a Kotlin provider could not load kotlin.jvm.internal.Intrinsics from the target app. The fixture provider is now Java with no Kotlin runtime references (verified in the compiled test APK DEX). The corrected instrumentation APK builds; fresh API26/36 runs must validate the full provider path.
The next API26 run exercised all 24 instrumentation tests: one assertion failed because instrumentation.context.applicationInfo reported UID 0, although PackageManager correctly resolved the fixture provider UID. The test now obtains provider-owner ApplicationInfo from PackageManager through a test-only ContextWrapper; URI resolution and read grants remain real. The same URI is first accepted by the target context, then rejected by the matching-UID context, preserving the guard regression. The updated test APK builds. Fresh API26/36 CI is required on this final head.
Tested on
September 26, Windows: debug/release/test APK compilation, 21 JVM tests and Android lint passed. The native package is excluded from npm workspaces and this revision changes no TypeScript production code. Current-head API 26/36 device checks are delegated to upstream CI; no fresh local emulator, physical-device, macOS or Linux run is claimed.
Environment
Windows, JDK 17, Gradle 8.2.1, compile SDK 34.
Risk & Scope
The native batch cap is 100. No camera capture, directory selection, save operation or downloads are added. Explicit user selection and URI grants remain the iframe security boundary. Physical devices, actual daemon uploads/TLS and all document providers are not validated by controller tests.
Design: English / 简体中文.
Linked Issues
Refs #11704, #11722, #12121.
中文说明
本 PR 的改动
使现有 Web Shell 单选/多选文件输入能够使用 Android 系统文档选择器。仅返回来自外部提供程序、可读取且已获授权的 content URI;取消和迟到结果不能把文件交给替代文档。本文件选择切片不新增产品存储权限或持久授权。
当前提交:
2138ad957aee4939412f2100b99b7a09581ebbc7。#11722 和 #12121 已合并。本分支已变基到main的9e60263fdeff;差异仅包含本功能及评审修复。本 PR 仍是独立 Phase 2 切片,等待当前提交 CI 和维护者批准。为什么需要
开发外壳拒绝文件选择回调,导致已有附件和工作区上传流程无法选择 Android 文档。H5 继续负责能力检查、上传目标及大小限制。
审阅者测试计划
验证方法
在
packages/mobile-shell使用 JDK 17 运行gradlew.bat --no-daemon assembleDebug assembleRelease assembleDebugAndroidTest testDebugUnitTest lintDebug。在 API 26 和 36 上通过
connectedDebugAndroidTest运行FilePickerDeviceTest。17 个用例涵盖真实 URI 授权和字节读取的单选/多选成功路径、MIME 提示、去重、单选数量、缺少/无效授权、同 UID 拒绝、混合不安全选择、100/101 边界、取消及迟到结果。随后验证真实 HTML 输入和 DocumentsUI。验证在途归属时明确重建 Activity;它自行处理配置变化,仅旋转屏幕不足以测试重建。前后证据
旧控制器测试即使拒绝全部选择也可能通过。本次提交独立测试 APK 中的提供程序,以仅测试使用的权限保护,并检查成功返回的 URI 及实际字节。迟到结果测试现在具有成功接受的阳性对照。应用及测试 APK 均已编译;新增设备用例尚未在本地设备运行。
上方截图是先前提交的历史功能证据,不代表本次提交已重新运行。
首次托管运行发现独立测试进程无法加载目标应用中的 Kotlin runtime。夹具提供程序已改为不依赖 Kotlin runtime 的 Java,并验证测试 APK DEX 中无相关引用。修正后的测试 APK 编译通过,完整提供程序路径等待新的 API26/36 运行。
后续 API26 运行执行全部24项设备测试,其中一项断言因 instrumentation context 的 ApplicationInfo 错报 UID0 失败。现在通过 PackageManager 获取提供程序所有者信息,仅在测试 ContextWrapper 中使用;URI 解析和授权保持真实。同一 URI 先由目标 context 接受,再由相同 UID context 拒绝,保留回归保护。新的测试 APK 构建通过,最终提交等待 API26/36 CI。
测试平台
9 月 26 日 Windows:debug/release/测试 APK 编译、21 项 JVM 测试和 Android lint 通过。原生包不属于 npm 工作区,本次不修改 TypeScript 产品代码。当前提交的 API 26/36 设备检查由上游 CI 执行;不声称重新在本地模拟器、真机、macOS 或 Linux 运行。
环境
Windows, JDK 17, Gradle 8.2.1, compile SDK 34.
风险与范围
原生批次上限为 100。不新增相机拍摄、目录选择、保存或下载。明确的用户选择和 URI 授权仍是 iframe 安全边界。控制器测试不能证明真机、实际 daemon 上传/TLS 或所有文档提供程序已通过验收。
Design: English / 简体中文.
关联事项
Refs #11704, #11722, #12121.