feat: integrate tauri-plugin-ohos-permissions - #62
Conversation
Package Changes Through 045fcc1There are 11 changes which include tauri with minor, @tauri-apps/api with minor, tauri-build with minor, tauri-macos-sign with patch, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-plugin with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Register ohos-permissions plugin in tauri-cli and examples/api: - Add OHOS Plugin.ets template (abilityAccessCtrl for Camera/Microphone) - Register in BUILTIN_PLUGINS and known_plugins - Add dependency + plugin init in examples/api - Add ACL permissions in capabilities/run-app.json - Add 10 auto + 5 manual test cases in plugins.ts - Add manual test buttons in TestRunner.svelte - Include openspec design docs (proposal + design + 6 specs + tasks) - Fix env.sh: junction for DevEco Studio path with spaces
7085404 to
045fcc1
Compare
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#62
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 0 | 2 | 1 | 1 |
🟡 F3 — Plugin.ets: handleRequest 未实现 requestPermissionOnSetting,违反 spec/design/tasks
handleRequest 在权限被拒绝(authResults[0] !== 0)或调用失败时,仅 console.warn/error 后 invoke.resolve(''),没有调用 atManager.requestPermissionOnSetting(this.context, [...]),也没有 tasks.md 3.4 step ① 的“先 check 已授权则直接 resolve”短路。三步流程实际只实现了 step ② 的弹窗部分。
这与三处文档冲突:
- spec
ohos-permissions-camera/spec.md与ohos-permissions-microphone/spec.md的 “永久拒绝后引导设置” Scenario 用 SHALL 措辞要求调用requestPermissionOnSetting design.mdGoals(L584) + R2(L673) 要求 denied 时调用requestPermissionOnSettingtasks.md3.4 标记为[x]已完成,但 step ③ 实际未实现(误标)
建议:在 denial 分支补上 requestPermissionOnSetting 调用以引导用户到系统设置;若该 API 对三方应用确实不可用,应同步更新 spec/design 而非静默省略,并修正 tasks.md 3.4 的状态。
🟡 F4 — doc/manual_tests.md 未更新(新增可操作权限 API + 手动测试)
本 PR 新增了用户可操作的权限 API(check*/request*),并在 TestRunner.svelte / plugins.ts 添加了手动测试按钮(Check All / Request Camera / Request Microphone / Deny→Re-request)。按 tauri 仓规范(H5),新增可操作功能/API 应在 doc/manual_tests.md 归档对应手动用例并更新统计表,但该文件本 PR 未变更。
建议:在 doc/manual_tests.md 追加 OHOS Permissions 手动测试章节(权限 check→request→check 全流程、拒绝后引导设置),并更新末尾统计表。
🔵 F5 — openspec/ohos-permissions-plan.md 散落在 openspec/ 根
该计划文件位于 openspec/ohos-permissions-plan.md,未归档到 openspec/changes/<change-name>/ 下。按 H3 规范,openspec 文件应归档到 openspec/changes/。建议移入 openspec/changes/p1-ohos-permissions/ 或专门的 plans 目录。
ℹ️ F6 — design.md D6 文档过期
D6 称 “default.toml 中 allow 所有 4 个 command”,但实际 default.toml 包含 12 个 command 权限(camera/microphone 真实 + accessibility/full-disk/screen-recording/input-monitoring stub,各 check+request)。建议更新 D6 描述以反映当前命令集。
由 tauri-ohos-pr-babysit 自动巡检生成。F3 的 inline comment 见下方 Plugin.ets 标注。
| if (authResults.length > 0 && authResults[0] === 0) { | ||
| invoke.resolve(''); | ||
| } else { | ||
| console.warn('[OhosPermissionsPlugin] Permission ' + permissionKey + ' denied by user.'); |
There was a problem hiding this comment.
🟡 [F3/spec] denial 分支仅 console.warn + invoke.resolve(''),未调用 atManager.requestPermissionOnSetting(this.context, [ohosPermission]) 引导用户到系统设置。
这与 spec(camera/microphone 的 “永久拒绝后引导设置” Scenario,SHALL 措辞)、design.md(Goals + R2)、tasks.md 3.4(标记 [x] 但 step ③ 未实现)三处冲突。
建议在此分支补上 requestPermissionOnSetting 调用;若该 API 对三方应用不可用,应同步更新 spec/design 并修正 tasks.md 3.4 状态。
Register ohos-permissions plugin in tauri-cli and examples/api: