Skip to content

fix(permission): correct foreground and background location flow - #329

Merged
yyy-router merged 2 commits into
1024XEngineer:mainfrom
LUPENGHAN:fix/location-permission-flow-328
Aug 20, 2026
Merged

fix(permission): correct foreground and background location flow#329
yyy-router merged 2 commits into
1024XEngineer:mainfrom
LUPENGHAN:fix/location-permission-flow-328

Conversation

@LUPENGHAN

Copy link
Copy Markdown
Contributor

Closes #328.

摘要

修复定位权限状态误判、权限重复弹窗,以及前台/后台定位权限引导不一致的问题。

背景

真实 Development Build 中动态加载 expo-location 可能失败,导致已授权的定位权限被误判为未授权。同时,语音握手和地理围栏注册会主动申请权限,造成权限提示时机不稳定,用户从系统设置返回后还可能再次看到相同弹窗。

主要改动

  • expo-location 改为静态导入,确保能够正确读取系统权限状态。
  • 将定位权限申请集中到 useReminderPermissionsOnLaunch
  • 区分前台定位权限和后台定位权限的申请流程。
  • 前台提醒使用前台定位权限。
  • 后台提醒和地理围栏使用后台定位权限。
  • 权限申请失败时,根据权限类型跳转到对应的系统设置页面。
  • 从系统设置返回后,如果权限没有变化,则跳过当前权限,避免重复弹窗。
  • ExpoLocationProviderExpoLocationMonitor 只读取权限状态,不再主动申请权限。
  • 语音握手在缺少定位权限时直接忽略可选位置字段,不阻塞连接。

行为变化

场景 预期行为
已授予前台定位权限 不再重复提示前台定位权限
已授予后台定位权限 创建后台地理提醒时不再重复提示
只授予前台权限 前台功能可用,后台功能单独引导后台权限
权限被拒绝 跳转对应设置页或结束当前权限项,不无限弹窗
从设置页返回且权限未改变 不重新打开相同提示
语音握手没有定位权限 保持连接,忽略可选位置数据
地理围栏注册没有定位权限 返回已有位置或空结果,不主动弹系统权限框

验证

  • 定位和权限相关测试:通过
  • 权限能力、定位 Provider、地理围栏 Monitor 专项测试:通过
  • TypeScript typecheck:通过
  • ESLint:通过
  • Prettier:通过
  • git diff --check:通过

范围

本 PR 只调整客户端权限编排和定位适配层,不修改:

  • 后端接口或 WebSocket 协议
  • 数据库结构
  • 地理围栏业务规则
  • 语音识别、TTS 和录音逻辑
  • 日程创建和提醒业务模型

@LUPENGHAN
LUPENGHAN marked this pull request as ready for review August 20, 2026 12:15
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本次审查覆盖了启动权限编排、前后台定位权限读取/申请、Provider 与地理围栏注册的完整变更。发现一个会导致用户重复看到定位系统授权框的回归;其余变更的调用方契约与测试覆盖未发现达到报告阈值的问题。由于当前工作区未安装 jest-expo 依赖,无法执行 Jest 专项测试;已完成固定 SHA diff、调用链和测试代码审查。

Comment thread frontend/src/infrastructure/notifications/NativeDeviceCapability.ts Outdated
…ings

openSettings() called requestForegroundPermissionsAsync/requestBackgroundPermissionsAsync
again after the caller already got a denial from requestPermission(), resurfacing the
same system dialog instead of routing to app settings. It now only reads current status
and falls back to Linking.openSettings() once the system truly won't ask again.

Also adds coverage for the previously-untested onAppActive recovery branches
(permission unchanged after returning from settings, getStatus() rejecting) and the
default expo-location loader path.
@yyy-router
yyy-router merged commit 2ba8452 into 1024XEngineer:main Aug 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(permission): 修复定位权限状态误判与前后台权限引导流程

2 participants