Skip to content

[Bug]: FCM 背景推播的一般通知(地震報告/震度速報/強震監視器)走鬧鐘音量 #660

Open

Description

@whes1015

平台:Android(iOS 另見文末)

版本:26w43d(回報者),main 分支目前仍相同

裝置:多台 Android 裝置(回報者:新北板橋、新北汐止)

發生了什麼

地震報告、震度速報、強震監視器這幾種一般通知(目錄裡沒有標 DefaultRingtoneType.Alarm 的頻道),實際是從鬧鐘音量串流播放,而不是通知音量。所以手機通知音量開大、鬧鐘音量很小時聽不到聲音;反過來,開了勿擾也可能被這些一般通知吵到。

預期:只有標了 DefaultRingtoneType.Alarm 的重大警報(緊急地震速報、地震速報重大、山區暴雨重大等)才走鬧鐘音量,其餘走通知音量。
實際:FCM 背景推播進來的地震報告、震度速報、強震監視器也一起走鬧鐘音量。

重現步驟

  1. 安裝 DPIP,讓 app 在背景被系統殺掉(或直接從背景狀態收推播)
  2. 把「鬧鐘」音量調大、把「通知」音量調到很小或靜音
  3. 等一次地震報告/震度速報的推播
  4. 聲音照樣很大聲 → 走的是鬧鐘音量

(在前景由 app 自己 render 的通知不受影響,Dart 端目錄設定是對的;錯的是 FCM notification block 那條路。)

根因

FCM 背景推播帶 notification block 時由 SDK 自己 render,只用 android_channel_id 這個明文頻道 id 去查頻道;awesome_notifications 的頻道 id 是 hash 過的,所以另外 mirror 了一份明文頻道(PlainChannels)。問題在這個 mirror:

  1. lib/core/notifications/plain_channels.dart 的 _payload() 只送 id/name/description/importance/group/sound/vibrationPattern/ledColor,沒有送 defaultRingtoneType。
  2. android/app/src/main/kotlin/com/exptech/dpip/PlainChannelsChannel.kt 的 ensure() 只要頻道有音檔,就寫死:
    AudioAttributes.Builder()
        .setUsage(AudioAttributes.USAGE_ALARM)
        .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
    不管目錄裡那一條有沒有標 Alarm。
  3. 受影響的頻道(notification_channels.dart 裡沒有 defaultRingtoneType: DefaultRingtoneType.Alarm):
    • int_report-general-v2(震度速報(一般))
    • eq-v2(強震監視器(一般))
    • report-general-v2(地震報告(一般))
    • 其他非重大的一般頻道同理(thunderstorm-general-v2、weather_minor-general-v2、evacuation_minor-general-v2 等)
  4. Android 的 channel 一旦建立,音量類型就凍結,ensure() 也是 create-if-missing only(刻意保留使用者在系統設定調過的值),所以已經裝過的手機不會因為 app 更新而自己好。

建議修法

  1. PlainChannels._payload() 把 channel.defaultRingtoneType 一起傳過去(awesome 的 DefaultRingtoneType 有 index 可以直接對應常數)。
  2. PlainChannelsChannel.ensure() 依傳進來的類型決定 usage:Alarm → USAGE_ALARM,其他或未指定 → USAGE_NOTIFICATION。
  3. 因為既有頻道不能改行為,受影響的明文頻道要換 id 重建(或在 RetiredChannels 移除舊的、由目錄重新建立),不然舊安裝永遠是鬧鐘音量。

iOS

PlainChannels.ensure() 在非 Android 直接 return,notification extension 也不動 aps;int_report-*、report-* 沒開 criticalAlerts。有回報者覺得 iOS 音量也不對,但不是這段 Kotlin 造成,需要另外確認(critical/時間敏感層級),這張 issue 只處理 Android。

來源

Discord 討論串 ET-2026-0203「DPIP - 通知音效播放頻道錯誤」(ExpTech Studio 伺服器)。

Activity

  1. self-assigned this
    on Nov 9, 2026
  2. added
    confirmedThe reported issue has been reproduced and confirmed.
    androidIssues or pull requests related to the Android platform.
    on Nov 9, 2026
  3. added theissue type on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

androidIssues or pull requests related to the Android platform.confirmedThe reported issue has been reproduced and confirmed.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions