Skip to content

Fix/android alerts and location - #541

Merged
whes1015 merged 2 commits into
mainfrom
fix/android-alerts-and-location
Aug 18, 2026
Merged

Fix/android alerts and location#541
whes1015 merged 2 commits into
mainfrom
fix/android-alerts-and-location

Conversation

@whes1015

Copy link
Copy Markdown
Member

這個 PR 做了什麼

相關 issue

  • closes #

怎麼驗

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
    —— commit 訊息就是更新日誌,格式見 commit.md
  • 一個 commit 一件事(這條 gate 驗不了,靠自己和 review)
  • mise exec -- flutter analyzemise exec -- flutter test 通過
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
  • 有 UI 變更的話:用的是 AppSpacing / AppRadius / AppMotion
    深色模式看過,文字對比度可接受

Platform: android

Fix(zh-Hant): 修正正式版 Android 上 16 個通知頻道註冊失敗,其中包含所有地震速報頻道
Fix(en-US): fix 16 notification channels failing to register on release Android builds, every earthquake alert channel among them

Every channel names its sound as a runtime string — `resource://raw/eew` — so
nothing in code or XML ever references @raw/*, the shrinker concludes they are
unused, and a release APK ships without them. A release APK's resource table
had no `raw` type at all; the debug one had thirteen entries.

Android then refuses the channel outright, with
`PlatformException(INVALID_ARGUMENTS, Audio media is not valid)`, and the app
records it and carries on. On the device this was found on, that had happened
96 times: 16 of 24 channels rejected, including eew_alert, eew, eq, tsunami and
every evacuation and weather channel.

tool/check/notification_sounds.sh could not have caught it. It reads the source
tree, and the source tree was always correct — the files are lost between the
build and the APK. Verified the other way after the fix: the release table now
carries all ten, and a device install registers 24 of 24 with no error logged.
Platform: android

Fix(zh-Hant): 修正背景定位回報過於頻繁被伺服器擋下,位置一直沒有更新
Fix(en-US): background location reports are no longer rejected by the server for arriving too fast

Four callers fire a report independently — the geofence, the alarm fallback,
and two paths from Dart — and nothing coordinated them, so a crossing that
arrived alongside an alarm sent two reports seconds apart. The server answers
429 and the position never lands, which looks from the outside exactly like
background location having stopped: on the device this was found on,
`last_report_code` was 429 with the geofence armed and a fix in hand.

The window is measured from a new `last_sent_at`, not from `last_report_at`.
The latter is stamped on every outcome, this one included, so gating on it
would let a burst of triggers push the window ahead of itself and starve
reporting completely.

The dropped triggers are counted rather than hidden, and -4 is named on the
diagnostics page: an unexplained negative number beside "Last report" reads as
a fault, and this one is the throttle working.

The swallowed exception now leaves its class name in the breadcrumbs. -1 was
all the app could say for a failure, and it fits a DNS miss, a timeout, a TLS
error and a Doze block equally well — with the name in hand, three failures
after a package replace turned out to be UnknownHostException, a report firing
before the network was up.

Measured on a Pixel 9: 71 triggers dropped, the code moved 429 to 202, and a
report inside forced deep Doze still returned 202.
@github-actions

Copy link
Copy Markdown

OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

@whes1015
whes1015 enabled auto-merge (rebase) August 18, 2026 15:44
@whes1015
whes1015 disabled auto-merge August 18, 2026 15:44
@whes1015
whes1015 merged commit 40ea62d into main Aug 18, 2026
6 checks passed
@whes1015
whes1015 deleted the fix/android-alerts-and-location branch August 18, 2026 15:44
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.

1 participant