真机验收修复4项:JPush message字段msg_title→title(API error 1009)、铃声audioSession -1→0(error(1,-19)不响铃)、MediaPlayer出错清理置空(二次拉起可重响)、知道了关页时取消备份通知20261122
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.xuanlong.xuanlong_futures
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.NotificationManager
|
||||
import android.content.Intent
|
||||
import android.media.AudioAttributes
|
||||
import android.media.MediaPlayer
|
||||
@@ -58,8 +59,16 @@ class AlarmActivity : Activity() {
|
||||
.setUsage(AudioAttributes.USAGE_ALARM)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.build()
|
||||
player = MediaPlayer.create(this, R.raw.alarm_ring, attrs, -1)?.apply {
|
||||
// audioSessionId=0 新建 session(-1 非法,AudioFlinger 拒绝致 error(1,-19))
|
||||
player = MediaPlayer.create(this, R.raw.alarm_ring, attrs, 0)?.apply {
|
||||
isLooping = true
|
||||
setOnErrorListener { p, _, _ ->
|
||||
// 出错后释放并置空,保证 onNewIntent 二次拉起能重新响铃
|
||||
try { p.stop() } catch (_: IllegalStateException) {}
|
||||
p.release()
|
||||
player = null
|
||||
true
|
||||
}
|
||||
start()
|
||||
}
|
||||
vibrator = getSystemService(Vibrator::class.java).also { v ->
|
||||
@@ -76,6 +85,8 @@ class AlarmActivity : Activity() {
|
||||
player = null
|
||||
vibrator?.cancel()
|
||||
vibrator = null
|
||||
// 清除 AlarmReceiver 的备份全屏通知(id=20261122),否则页面关闭后仍挂在通知栏
|
||||
getSystemService(NotificationManager::class.java).cancel(20261122)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ def _payload(items: list[dict], rids: list[str]) -> dict:
|
||||
return {
|
||||
"platform": "all",
|
||||
"audience": {"registration_id": rids},
|
||||
"message": {"msg_title": "玄龙期货", "msg_content": content, "extras": extras},
|
||||
"message": {"title": "玄龙期货", "msg_content": content, "extras": extras},
|
||||
"options": {"time_to_live": 86400},
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ def test_single_signal_uses_message_with_alarm_extras():
|
||||
p = _payload(items, ["ridA"])
|
||||
assert "notification" not in p # 不再发通知栏
|
||||
msg = p["message"]
|
||||
assert msg["msg_title"] == "玄龙期货"
|
||||
assert msg["title"] == "玄龙期货"
|
||||
assert "【量价背离】FUL9 · 30m · 11-22 10:15" == msg["msg_content"]
|
||||
ex = msg["extras"]
|
||||
assert ex["type"] == "signal_alarm"
|
||||
|
||||
Reference in New Issue
Block a user