Skip to content

fix(location): stop recording a refused GPS fix as a crash - #633

Merged
whes1015 merged 1 commit into
mainfrom
fix/location-refusal
Oct 22, 2026
Merged

whes1015 merged 1 commit into
mainfrom
fix/location-refusal

Conversation

@whes1015

@whes1015 whes1015 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

關掉定位、或拒絕定位權限,不再被記成 Crashlytics 錯誤。定位還是拿不到,呼叫端一樣得到空結果;差在這不再被當成故障。

正式程式碼:

  • isLocationRefusal 認 LocationServiceDisabledException 和 PermissionDeniedException
  • LocationService 的現在位置、上次位置、鄉鎮查詢碰到這兩種就只記警告
  • DeviceLocationReporter 的定位串流一樣。訂閱還是會放下,定位服務回來之後 restart 仍會重開

測試:拒絕的上次位置、現在位置、鄉鎮查詢不會進 crash sink;真正的平台錯誤仍會。串流被關掉不進 sink,換一個別的錯誤仍會,而且 restart 之後還聽得到。

Crashlytics(近 89 天,到 2026-10-20 22:46,UTC+8;重寫版 26w42l / 26w43a):

  • 89f9c2f9… 定位服務關掉,13 次 / 7 人。最新一筆今天 17:07,26w43a
  • f7253cc4… 使用者拒絕定位,1 次 / 1 人,26w42l。訊息就是 Android 的 PERMISSION_DENIED

沒有做:

  • 啟動效能摘要 7277e6d4…(219 次 / 88 人)是每次啟動故意送的非致命,不是這次要拿掉的
  • no such table: fix(18 次 / 14 人)已在 fix(location): record movement history on Android #630 修,最新一筆仍是修之前的 26w42l(426000781),今天 18:49
  • Meshtastic 連線 30 秒逾時、地圖 MissingPluginException 各 1 次,沒有對上能改的程式
  • iOS 近 89 天沒有 issue。重寫版沒有 fatal
  • 還沒在實機把定位關掉看過

相關 issue

開 PR 前搜過 gh issue list --state all --search '定位 權限 OR location permission OR Crashlytics'。沒有對應的 issue。

怎麼驗

本機:

  • tool/dev/analyze.sh 通過
  • tool/check/commits.sh origin/main..HEAD 通過
  • 推送時 pre-push 的 tool/check.sh 通過(完整測試 3628 通過,另有 6 個跳過)。本機是 Darwin,CI 是 Linux
  • tool/dev/test.sh test/core/geo/location_service_test.dart test/core/geo/device_location_reporter_test.dart 通過

實機用 tool/run.sh:

  • 開著 app,到系統設定把定位關掉。日誌應是警告「location stream stopped」或「location is off or denied」,不該再出現 location stream 的錯誤上報
  • 拒絕定位權限後讀上次位置,同樣只剩警告
  • 再把定位打開,前景定位應恢復。這不影響地震推估

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
    —— commit 訊息就是更新日誌,格式見 commit.md
  • 一個 commit 一件事(這條 gate 驗不了,靠自己和 review)
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過
    —— 實際跑的是 tool/dev/analyze.sh 與 pre-push 的 tool/check.sh。沒有直接打 mise exec
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
  • CI 全部通過(gh pr checks:每一項都是 pass 或 skipped)—— 沒過不能合併,
    見 pr.md
    —— build、Android、iOS、code-review、changes、codecov/project、codecov/patch 都是 pass
  • 有 UI 變更的話:用的是 AppSpacing / AppRadius / AppMotion,
    深色模式看過,文字對比度可接受
    —— 沒有改版面

@lowrt lowrt added this to the v26.4 milestone Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.51%. Comparing base (565bad4) to head (e0e22d3).

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Platform: all

Fix(zh-Hant): 關掉定位或拒絕權限不再被記成應用程式錯誤
Fix(en-US): turning location off or denying it is no longer recorded as an app error
@whes1015
whes1015 force-pushed the fix/location-refusal branch from e0e22d3 to 1d6219e Compare October 22, 2026 00:31
@whes1015
whes1015 merged commit ce4b24b into main Oct 22, 2026
3 of 4 checks passed
@whes1015
whes1015 deleted the fix/location-refusal branch October 22, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants