实施计划:信号闹钟级强提醒(4任务:后端message/TDD、Android原生闹钟、真机验收、推Gitea)
This commit is contained in:
@@ -0,0 +1,558 @@
|
||||
# 信号推送闹钟级强提醒 实施计划
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 信号推送到达时锁屏直接弹全屏闹钟页,循环铃声+震动直到点击「知道了」。
|
||||
|
||||
**Architecture:** 后端把信号推送从 JPush `notification` 改为 `message`(自定义消息);Android 原生侧新增 `AlarmReceiver`(订阅极光 RECEIVER_MESSAGE 广播)收到后发一条 `setFullScreenIntent` 高优通知 + 前台时直接 startActivity;系统负责锁屏亮屏弹起 `AlarmActivity`(循环 USAGE_ALARM 铃声 + 重复震动)。Flutter 层零改动。
|
||||
|
||||
**Tech Stack:** FastAPI/pytest(后端 payload)、极光 JPush SDK 6.3.1(jpush_flutter 3.6.2)、Android 原生 Kotlin、MediaPlayer/Vibrator。
|
||||
|
||||
**设计文档:** `docs/superpowers/specs/2026-11-22-signal-alarm-push-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- 仓库:`/Users/mac/Documents/codeproject/ai量化/xuanlong-futures`,分支 `main`
|
||||
- 后端 pytest 自动用临时库(conftest 已设 `XL_DB_PATH`),绝不触碰 `server/data/xuanlong.db`
|
||||
- 极光凭证在 `server/.env`(`XL_JPUSH_APP_KEY=ba2236956024b8644a83e8c3`,Master Secret 同文件),端到端测试直发 JPush API
|
||||
- 生产包构建必须带三个 dart-define:`API_BASE_URL=http://42.194.179.190:3003`、`API_FALLBACK_URLS=https://ceryuan.top`、`JPUSH_APP_KEY=ba2236956024b8644a83e8c3`
|
||||
- APK 不入 git(仅本地 `server/data/apk/` + 管理台分发)
|
||||
- Android 包名 `com.xuanlong.xuanlong_futures`,jpush_flutter 3.6.2 / JPush SDK 6.3.1,`CustomMessage.extra` 是 JSON 字符串
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 后端 push.py 改发自定义消息(TDD)
|
||||
|
||||
**Files:**
|
||||
- Modify: `server/app/notify/push.py`(`_payload` 函数,约 64-80 行)
|
||||
- Test: `server/tests/test_push.py`(新建)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: 现有 `_payload(items: list[dict], rids: list[str]) -> dict`(rows 的 key 用 `it.keys()` 判断 kind)
|
||||
- Produces: payload 含 `"message": {"msg_title", "msg_content", "extras": {...}}` 且不含 `"notification"`;extras 固定含 `"type": "signal_alarm"`
|
||||
|
||||
- [ ] **Step 1: 写失败测试**
|
||||
|
||||
新建 `server/tests/test_push.py`:
|
||||
|
||||
```python
|
||||
"""_payload:信号推送改发 JPush 自定义消息(闹钟 payload)。"""
|
||||
from app.notify.push import _payload
|
||||
|
||||
|
||||
def test_single_signal_uses_message_with_alarm_extras():
|
||||
items = [{
|
||||
"id": 1, "user_id": 7, "signal_id": 42, "symbol": "FUL9",
|
||||
"interval": "30m", "divergence_time": "2026-11-22 10:15", "kind": "divergence",
|
||||
}]
|
||||
p = _payload(items, ["ridA"])
|
||||
assert "notification" not in p # 不再发通知栏
|
||||
msg = p["message"]
|
||||
assert msg["msg_title"] == "玄龙期货"
|
||||
assert "【量价背离】FUL9 · 30m · 11-22 10:15" == msg["msg_content"]
|
||||
ex = msg["extras"]
|
||||
assert ex["type"] == "signal_alarm"
|
||||
assert ex["kind"] == "divergence"
|
||||
assert ex["signal_id"] == "42"
|
||||
assert ex["symbol"] == "FUL9"
|
||||
assert ex["interval"] == "30m"
|
||||
assert ex["divergence_time"] == "2026-11-22 10:15"
|
||||
|
||||
|
||||
def test_digest_merges_and_marks_kind_digest():
|
||||
items = [{
|
||||
"id": i, "user_id": 7, "signal_id": 100 + i, "symbol": f"S{i}",
|
||||
"interval": "30m", "divergence_time": "2026-11-22 10:15", "kind": "divergence",
|
||||
} for i in range(5)]
|
||||
p = _payload(items, ["ridA"])
|
||||
ex = p["message"]["extras"]
|
||||
assert ex["kind"] == "digest"
|
||||
assert ex["signal_ids"] == "100,101,102,103,104"
|
||||
assert "本轮新增 5 个信号" in p["message"]["msg_content"]
|
||||
|
||||
|
||||
def test_audience_uses_registration_ids():
|
||||
items = [{"id": 1, "user_id": 7, "signal_id": 42, "symbol": "FUL9",
|
||||
"interval": "30m", "divergence_time": "2026-11-22 10:15", "kind": "bd_resonance"}]
|
||||
p = _payload(items, ["r1", "r2"])
|
||||
assert p["audience"] == {"registration_id": ["r1", "r2"]}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 跑测试确认失败**
|
||||
|
||||
Run: `cd server && .venv/bin/python -m pytest tests/test_push.py -v`
|
||||
Expected: FAIL(`assert "notification" not in p` 失败——现实现发 notification)
|
||||
|
||||
- [ ] **Step 3: 改 `_payload`**
|
||||
|
||||
`server/app/notify/push.py` 中替换 `_payload` 函数体:
|
||||
|
||||
```python
|
||||
def _payload(items: list[dict], rids: list[str]) -> dict:
|
||||
first = items[0]
|
||||
sig_ids = [it["signal_id"] for it in items]
|
||||
row_kind = first["kind"] if "kind" in first.keys() else "divergence"
|
||||
label = _KIND_LABEL.get(row_kind, "量价背离")
|
||||
if len(items) > 3:
|
||||
content = f"本轮新增 {len(items)} 个信号"
|
||||
extras = {"type": "signal_alarm", "kind": "digest",
|
||||
"signal_ids": ",".join(str(s) for s in sig_ids)}
|
||||
else:
|
||||
content = (
|
||||
f"【{label}】{first['symbol']} · {first['interval']} · {first['divergence_time'][5:]}"
|
||||
)
|
||||
extras = {"type": "signal_alarm", "kind": row_kind,
|
||||
"signal_id": str(first["signal_id"]),
|
||||
"symbol": first["symbol"], "interval": first["interval"],
|
||||
"divergence_time": first["divergence_time"]}
|
||||
return {
|
||||
"platform": "all",
|
||||
"audience": {"registration_id": rids},
|
||||
"message": {"msg_title": "玄龙期货", "msg_content": content, "extras": extras},
|
||||
"options": {"time_to_live": 86400},
|
||||
}
|
||||
```
|
||||
|
||||
`push_text`(到期提醒)保持不动。
|
||||
|
||||
- [ ] **Step 4: 跑测试确认通过 + 全量回归不破**
|
||||
|
||||
Run: `cd server && .venv/bin/python -m pytest tests/test_push.py -v && .venv/bin/python -m pytest`
|
||||
Expected: 全部 PASS
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add server/app/notify/push.py server/tests/test_push.py
|
||||
git commit -m "信号推送改发JPush自定义消息(signal_alarm extras):客户端原生闹钟页消费,通知栏不再展示信号;到期提醒push_text不变"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Android 原生闹钟(权限/资源/Receiver/Activity)
|
||||
|
||||
**Files:**
|
||||
- Modify: `app/android/app/src/main/AndroidManifest.xml`
|
||||
- Create: `app/android/app/src/main/kotlin/com/xuanlong/xuanlong_futures/AlarmReceiver.kt`
|
||||
- Create: `app/android/app/src/main/kotlin/com/xuanlong/xuanlong_futures/AlarmActivity.kt`
|
||||
- Create: `app/android/app/src/main/res/layout/activity_alarm.xml`
|
||||
- Create: `app/android/app/src/main/res/raw/alarm_ring.wav`(脚本生成)
|
||||
- Create: `app/android/app/src/main/res/values/alarm_colors.xml`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 的 extras 字段(`type`/`kind`/`symbol`/`interval`/`divergence_time`/`signal_ids`,经 CustomMessage.extra JSON 透传到 intent)
|
||||
- Produces: `AlarmActivity`(launchMode singleTask,extras: kind/symbol/interval/divergence_time/summary/digest)
|
||||
|
||||
- [ ] **Step 1: 生成闹钟铃声 WAV**
|
||||
|
||||
```bash
|
||||
python3 -c "
|
||||
import wave, math, struct
|
||||
sr = 22050
|
||||
samples = []
|
||||
# 4 段 880Hz 短鸣(0.28s) + 段间停顿(0.22s),总长 2s 循环
|
||||
for seg in range(4):
|
||||
for i in range(int(sr*0.28)):
|
||||
t = i/sr
|
||||
v = 0.85*math.sin(2*math.pi*880*t)*(0.6+0.4*math.sin(2*math.pi*8*t))
|
||||
samples.append(v)
|
||||
samples += [0.0]*int(sr*0.22)
|
||||
with open('app/android/app/src/main/res/raw/alarm_ring.wav','wb') as f:
|
||||
w = wave.open(f,'w'); w.setnchannels(1); w.setsampwidth(2); w.setframerate(sr)
|
||||
w.writeframes(b''.join(struct.pack('<h', max(-32767,min(32767,int(s*32767)))) for s in samples))
|
||||
w.close()
|
||||
"
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Manifest 加权限 + 声明组件**
|
||||
|
||||
`app/android/app/src/main/AndroidManifest.xml`:
|
||||
|
||||
`<manifest>` 下新增(与现有 uses-permission 并列):
|
||||
|
||||
```xml
|
||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
```
|
||||
|
||||
`<application>` 内新增:
|
||||
|
||||
```xml
|
||||
<receiver android:name=".AlarmReceiver" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE"/>
|
||||
<category android:name="com.xuanlong.xuanlong_futures"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<activity android:name=".AlarmActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:showWhenLocked="true"
|
||||
android:turnScreenOn="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 布局与颜色**
|
||||
|
||||
`app/android/app/src/main/res/values/alarm_colors.xml`:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="alarm_bg">#1A0F0D</color>
|
||||
<color name="alarm_accent">#C8452E</color>
|
||||
<color name="alarm_text">#F5E9D8</color>
|
||||
</resources>
|
||||
```
|
||||
|
||||
`app/android/app/src/main/res/layout/activity_alarm.xml`:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical" android:gravity="center"
|
||||
android:background="@color/alarm_bg"
|
||||
android:padding="32dp">
|
||||
|
||||
<TextView android:id="@+id/alarm_kind"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:textColor="@color/alarm_accent" android:textSize="40sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView android:id="@+id/alarm_detail"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textColor="@color/alarm_text" android:textSize="24sp"
|
||||
android:gravity="center"/>
|
||||
|
||||
<Button android:id="@+id/alarm_dismiss"
|
||||
android:layout_width="match_parent" android:layout_height="64dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:backgroundTint="@color/alarm_accent"
|
||||
android:text="知道了" android:textSize="22sp" android:textColor="@color/alarm_text"/>
|
||||
</LinearLayout>
|
||||
```
|
||||
|
||||
- [ ] **Step 4: AlarmActivity.kt**
|
||||
|
||||
`app/android/app/src/main/kotlin/com/xuanlong/xuanlong_futures/AlarmActivity.kt`:
|
||||
|
||||
```kotlin
|
||||
package com.xuanlong.xuanlong_futures
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.media.AudioAttributes
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
|
||||
class AlarmActivity : Activity() {
|
||||
private var player: MediaPlayer? = null
|
||||
private var vibrator: Vibrator? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
)
|
||||
setContentView(R.layout.activity_alarm)
|
||||
findViewById<Button>(R.id.alarm_dismiss).setOnClickListener { stopAndFinish() }
|
||||
startRing()
|
||||
render(intent)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent)
|
||||
if (player == null) startRing() // 已停止又被拉起时重新响
|
||||
render(intent)
|
||||
}
|
||||
|
||||
private fun render(intent: Intent?) {
|
||||
val kind = intent?.getStringExtra("kind") ?: return
|
||||
val kindText = when (kind) {
|
||||
"long_ignition" -> "做多起爆点"; "short_ignition" -> "做空起爆点"
|
||||
"bd_resonance" -> "卖出(BD共振)"; "digest" -> "新信号"
|
||||
else -> "量价背离"
|
||||
}
|
||||
val detail = if (kind == "digest") {
|
||||
"${intent.getStringExtra("summary") ?: ""}"
|
||||
} else {
|
||||
"${intent.getStringExtra("symbol")} · ${intent.getStringExtra("interval")} · ${intent.getStringExtra("divergence_time")?.substring(5)}"
|
||||
}
|
||||
findViewById<TextView>(R.id.alarm_kind).text = kindText
|
||||
findViewById<TextView>(R.id.alarm_detail).text = detail
|
||||
}
|
||||
|
||||
private fun startRing() {
|
||||
if (player != null) return
|
||||
val attrs = AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_ALARM)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.build()
|
||||
player = MediaPlayer.create(this, R.raw.alarm_ring, attrs, -1)?.apply {
|
||||
isLooping = true
|
||||
start()
|
||||
}
|
||||
vibrator = getSystemService(Vibrator::class.java).also { v ->
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
v.vibrate(VibrationEffect.createWaveform(longArrayOf(0, 600, 400), 0))
|
||||
} else {
|
||||
@Suppress("DEPRECATION") v.vibrate(longArrayOf(0, 600, 400), 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAndFinish() {
|
||||
player?.run { stop(); release() }
|
||||
player = null
|
||||
vibrator?.cancel()
|
||||
vibrator = null
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
player?.run { stop(); release() }
|
||||
vibrator?.cancel()
|
||||
player = null; vibrator = null
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
(`Intent` 需要 `import android.content.Intent`——写入文件时补上。)
|
||||
|
||||
- [ ] **Step 5: AlarmReceiver.kt**
|
||||
|
||||
`app/android/app/src/main/kotlin/com/xuanlong/xuanlong_futures/AlarmReceiver.kt`:
|
||||
|
||||
```kotlin
|
||||
package com.xuanlong.xuanlong_futures
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.media.AudioAttributes
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Process
|
||||
import android.app.ActivityManager
|
||||
import cn.jpush.android.api.CustomMessage
|
||||
import cn.jpush.android.service.JPushMessageReceiver
|
||||
import org.json.JSONObject
|
||||
|
||||
class AlarmReceiver : JPushMessageReceiver() {
|
||||
override fun onMessage(context: Context, customMessage: CustomMessage?) {
|
||||
val msg = customMessage ?: return
|
||||
val extras = try { JSONObject(msg.extra ?: "{}") } catch (_: Exception) { return }
|
||||
if (extras.optString("type") != "signal_alarm") return
|
||||
|
||||
val intent = Intent(context, AlarmActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra("kind", extras.optString("kind", "divergence"))
|
||||
if (extras.optString("kind") == "digest") {
|
||||
putExtra("summary", "本轮新增 ${extras.optString("signal_ids").split(",").size} 个信号,打开查看")
|
||||
} else {
|
||||
putExtra("symbol", extras.optString("symbol"))
|
||||
putExtra("interval", extras.optString("interval"))
|
||||
putExtra("divergence_time", extras.optString("divergence_time"))
|
||||
}
|
||||
}
|
||||
|
||||
// App 在前台:直接拉起,不经通知
|
||||
if (isAppForeground(context)) {
|
||||
context.startActivity(intent)
|
||||
return
|
||||
}
|
||||
// 后台/杀进程:全屏意图通知(系统有权限则直接弹 Activity,无权限降级 heads-up)
|
||||
notifyFullScreen(context, intent)
|
||||
}
|
||||
|
||||
private fun isAppForeground(context: Context): Boolean {
|
||||
val am = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val process = "${context.packageName}"
|
||||
return am.runningAppProcesses?.any {
|
||||
it.processName == process && it.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
|
||||
} ?: false
|
||||
}
|
||||
|
||||
private fun notifyFullScreen(context: Context, intent: Intent) {
|
||||
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
val pi = PendingIntent.getActivity(
|
||||
context, 20261122, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
val builder: Notification.Builder
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
val channel = NotificationChannel(CHANNEL_ID, "信号强提醒", NotificationManager.IMPORTANCE_HIGH).apply {
|
||||
setSound(
|
||||
Uri.parse("android.resource://${context.packageName}/${R.raw.alarm_ring}"),
|
||||
AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_ALARM)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build()
|
||||
)
|
||||
}
|
||||
nm.createNotificationChannel(channel)
|
||||
builder = Notification.Builder(context, CHANNEL_ID)
|
||||
} else {
|
||||
builder = Notification.Builder(context)
|
||||
}
|
||||
val notification = builder
|
||||
.setContentTitle("玄龙期货")
|
||||
.setContentText(intent.getStringExtra("kind")?.let { labelOf(it) } ?: "新信号")
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setFullScreenIntent(pi, true)
|
||||
.setAutoCancel(true)
|
||||
.build()
|
||||
nm.notify(20261122, notification)
|
||||
}
|
||||
|
||||
private fun labelOf(kind: String) = when (kind) {
|
||||
"long_ignition" -> "做多起爆点"; "short_ignition" -> "做空起爆点"
|
||||
"bd_resonance" -> "卖出(BD共振)"; "digest" -> "新信号"
|
||||
else -> "量价背离"
|
||||
}
|
||||
|
||||
companion object { private const val CHANNEL_ID = "signal_alarm_v1" }
|
||||
}
|
||||
```
|
||||
|
||||
(`Process` import 未用可删。)
|
||||
|
||||
- [ ] **Step 6: 设置页加闹钟权限引导卡(Flutter)**
|
||||
|
||||
Modify: `app/lib/features/settings/settings_page.dart`。在 `build()` 的 `ListView children` 里 `_switchCard(...)` 之后插入:
|
||||
|
||||
```dart
|
||||
const SizedBox(height: 10),
|
||||
_alarmGuideCard(),
|
||||
```
|
||||
|
||||
在类内(如 `_updateCard()` 旁边)新增方法:
|
||||
|
||||
```dart
|
||||
Widget _alarmGuideCard() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: XlColors.surface,
|
||||
borderRadius: BorderRadius.circular(XlRadius.card),
|
||||
border: Border.all(color: XlColors.border),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.alarm, size: 20, color: XlColors.goldLight),
|
||||
const SizedBox(width: 10),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'信号到达将以闹钟方式强提醒(锁屏弹屏+持续响铃)。若锁屏时未弹出,'
|
||||
'请在系统设置→应用→玄龙期货中开启「悬浮通知/允许全屏显示」。',
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: openAppSettings,
|
||||
child: const Text('去设置'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
文件顶部若未引入则加 `import 'package:permission_handler/permission_handler.dart';`(`openAppSettings` 来自该包;`XlColors`/`XlRadius` 已在文件内使用无需新引)。
|
||||
|
||||
- [ ] **Step 7: 构建验证**
|
||||
|
||||
Run: `cd app && flutter analyze && flutter build apk --release --dart-define=API_BASE_URL=http://42.194.179.190:3003 --dart-define=API_FALLBACK_URLS=https://ceryuan.top --dart-define=JPUSH_APP_KEY=ba2236956024b8644a83e8c3`
|
||||
Expected: analyze 无 error,BUILD SUCCESSFUL(Kotlin 编译通过)
|
||||
|
||||
- [ ] **Step 8: Commit**
|
||||
|
||||
```bash
|
||||
git add app/android/app/src/main/ app/lib/features/settings/settings_page.dart
|
||||
git commit -m "Android闹钟级信号提醒:AlarmReceiver(全屏意图通知)+AlarmActivity(锁屏亮屏/USAGE_ALARM循环铃/重复震动/知道了停止);设置页加强提醒引导卡"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: 端到端真机验收(Pixel 6)
|
||||
|
||||
**Files:** 无新增(验证任务)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 的 message extras、Task 2 的 Receiver/Activity、Pixel 6 上已装的 App(RID `1a0018970bfda0bc9ff`,装包时 logcat 记录)
|
||||
|
||||
- [ ] **Step 1: 安装 Task 2 产物到 Pixel 6**
|
||||
|
||||
Run: `adb install -r app/build/app/outputs/flutter-apk/app-release.apk`
|
||||
Expected: Success
|
||||
|
||||
- [ ] **Step 2: 启动 App,取最新 RID**
|
||||
|
||||
```bash
|
||||
adb logcat -c && adb shell monkey -p com.xuanlong.xuanlong_futures -c android.intent.category.LAUNCHER 1
|
||||
sleep 15 && adb logcat -d | grep -E "transmitReceiveRegistrationId" | tail -1
|
||||
```
|
||||
Expected: 输出 RID(记录备用;与旧值一致或新的均可)
|
||||
|
||||
- [ ] **Step 3: 直发 JPush 自定义消息验证(前台场景)**
|
||||
|
||||
用 `server/.env` 的凭证直调 JPush API(App 在前台):
|
||||
|
||||
```bash
|
||||
source <(grep -E '^XL_JPUSH_(APP_KEY|MASTER_SECRET)=' server/.env | sed 's/^/export /')
|
||||
curl -s https://api.jpush.cn/v3/push -u "$XL_JPUSH_APP_KEY:$XL_JPUSH_MASTER_SECRET" \
|
||||
-H 'Content-Type: application/json' -d '{
|
||||
"platform": "all",
|
||||
"audience": {"registration_id": ["<Step2的RID>"]},
|
||||
"message": {"msg_title": "玄龙期货", "msg_content": "【量价背离】FUL9 · 30m · 11-22 10:15",
|
||||
"extras": {"type": "signal_alarm", "kind": "divergence", "signal_id": "0",
|
||||
"symbol": "FUL9", "interval": "30m", "divergence_time": "2026-11-22 10:15"}},
|
||||
"options": {"time_to_live": 3600}}'
|
||||
```
|
||||
Expected: `{"sendno":...,"msg_id":...}`;手机前台弹全屏闹钟页,循环响铃震动
|
||||
|
||||
- [ ] **Step 4: 杀进程+锁屏场景**
|
||||
|
||||
手机灭屏锁屏 → `adb shell am force-stop com.xuanlong.xuanlong_futures` → 重发 Step 3 的 curl。
|
||||
Expected: 亮屏直接弹全屏闹钟页并响铃(若 Android 14 未授全屏意图权限则降级为 heads-up 通知——记录实际表现)
|
||||
|
||||
- [ ] **Step 5: 点击「知道了」**
|
||||
|
||||
Expected: 铃声震动立即停止,页面关闭,回到锁屏/桌面
|
||||
|
||||
- [ ] **Step 6: 记录验收结论并提交**
|
||||
|
||||
三场景结果写入 commit message:
|
||||
|
||||
```bash
|
||||
git commit --allow-empty -m "真机验收:信号闹钟三场景(前台弹出/杀进程锁屏弹出/点击停止)<实际结果>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 收尾——推 Gitea
|
||||
|
||||
- [ ] **Step 1: 推送**
|
||||
|
||||
```bash
|
||||
PW=$(security find-internet-password -s 39.108.95.179 -w)
|
||||
git push "http://chenht:${PW}@39.108.95.179:3000/chenht/xuanlong-future.git" main
|
||||
```
|
||||
Expected: push 成功(本计划产物无 APK,无大文件)
|
||||
|
||||
(生产服务器部署 push.py 改动 + APK 发布到管理台为独立运维步骤,不在本计划内。)
|
||||
Reference in New Issue
Block a user