feat:m1测试通过
This commit is contained in:
@@ -150,6 +150,11 @@ class MainActivity : ComponentActivity() {
|
||||
val accepted = com.haorui.app.automation.HaoRuiAccessibilityService.instance?.verifyAccountSandbox() == true
|
||||
com.haorui.app.automation.RunLogger.i("UI", "账号只读核验受理=$accepted")
|
||||
}
|
||||
"testDraft", "testDraftInvalid" -> if (applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE != 0) {
|
||||
val accepted = com.haorui.app.automation.HaoRuiAccessibilityService.instance?.startDraftSandbox(
|
||||
intent.getStringExtra("fixturePath").orEmpty(), intent.getStringExtra("cmd") == "testDraftInvalid") == true
|
||||
com.haorui.app.automation.RunLogger.i("UI", "自有素材草稿回归受理=$accepted")
|
||||
}
|
||||
// ── 装机调试命令(adb 触发,验证 F1/F2 用)─────────
|
||||
"testCredit" -> {
|
||||
val svc = com.haorui.app.automation.HaoRuiAccessibilityService.instance
|
||||
|
||||
@@ -412,6 +412,9 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
||||
// 装机调试(不动前台):信用分读取 / 互动沙盒
|
||||
addAction("com.haorui.app.ACTION_TEST_CREDIT")
|
||||
addAction("com.haorui.app.ACTION_TEST_INTERACT")
|
||||
// 自有素材草稿回归(debug APK):vivo 真机 activity intent 投递不稳,广播为可靠入口
|
||||
addAction("com.haorui.app.ACTION_TEST_DRAFT")
|
||||
addAction("com.haorui.app.ACTION_TEST_DRAFT_INVALID")
|
||||
// 回归测试:发布模式切换(草稿/正式)
|
||||
addAction("com.haorui.app.ACTION_SET_DRAFT")
|
||||
addAction("com.haorui.app.ACTION_SET_PUBLISH")
|
||||
@@ -613,6 +616,13 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
||||
RunLogger.i(TAG, "ACTION_TEST_INTERACT 启动结果=$ok")
|
||||
}
|
||||
}
|
||||
// 自有素材草稿回归(debug APK;等价于 cmd=testDraft / testDraftInvalid,走广播不受 intent 投递丢包影响)
|
||||
"com.haorui.app.ACTION_TEST_DRAFT",
|
||||
"com.haorui.app.ACTION_TEST_DRAFT_INVALID" -> {
|
||||
val path = intent.getStringExtra("fixturePath").orEmpty()
|
||||
val accepted = startDraftSandbox(path, intent.action == "com.haorui.app.ACTION_TEST_DRAFT_INVALID")
|
||||
RunLogger.i(TAG, "自有素材草稿回归受理=$accepted(广播 ${intent.action})")
|
||||
}
|
||||
// 回归测试发布模式切换(草稿/正式;autoPublish 无 UI 开关,走广播)
|
||||
"com.haorui.app.ACTION_SET_DRAFT" -> setAutoPublish(false)
|
||||
"com.haorui.app.ACTION_SET_PUBLISH" -> setAutoPublish(true)
|
||||
@@ -622,6 +632,10 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
||||
|
||||
fun startAutomation() {
|
||||
if (!checkVersionGate()) return
|
||||
if (runCatching { videoDownloader.hasPendingDrafts() }.getOrDefault(true)) {
|
||||
TaskStatusBus.status("存在待核对草稿,素材已保留;请先核对草稿结果")
|
||||
return
|
||||
}
|
||||
// ⚠️ P5-1 挂载点①:信用分门控(credit.gateEnabled)——
|
||||
// fail-open:识别失败不拦截只告警,防 OCR 不稳掐死全天任务。
|
||||
val cfg = latestConfig
|
||||
@@ -682,6 +696,19 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
||||
|
||||
fun isRunning(): Boolean = scheduler.isRunning
|
||||
|
||||
/** 仅调试 APK 的自有固定素材草稿回归,不启用采集、互动或正式发布。 */
|
||||
fun startDraftSandbox(path: String, invalidDeclaration: Boolean = false): Boolean = synchronized(stepLifecycleLock) {
|
||||
if (applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE == 0 ||
|
||||
!::scheduler.isInitialized || scheduler.isRunning || publisher.isWorking || interactor.isWorking ||
|
||||
frontGuard.creditNavigating || !foregroundCoordinator.isIdle() || latestConfig.toutiao.autoPublish ||
|
||||
latestConfig.crossPlatform.enabled || java.io.File(path).name != "haorui-draft-regression.mp4" ||
|
||||
!videoDownloader.isOwnedMedia(path) || runCatching { videoDownloader.hasPendingDrafts() }.getOrDefault(true)) return@synchronized false
|
||||
val accepted = publisher.submit("浩瑞草稿回归 ${java.util.UUID.randomUUID().toString().take(8)}", path,
|
||||
autoPublish = false, declaration = if (invalidDeclaration) "内容为原创" else "内容无需标注")
|
||||
if (accepted) scheduler.startLaneOnly(LaneScheduler.Lane.PUBLISH)
|
||||
accepted
|
||||
}
|
||||
|
||||
/** 新来源仅可在旧流程的完整安全边界入场,不在详情、编辑或回执中途切换。 */
|
||||
fun tryEnterSourceForeground(sourceId: String): ForegroundCoordinator.Ticket? {
|
||||
if (currentCrossRunGeneration() == null) return null
|
||||
|
||||
@@ -17,6 +17,7 @@ import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import com.haorui.app.automation.selection.DraftReceiptPolicy
|
||||
|
||||
/**
|
||||
* 视频发布状态机。
|
||||
@@ -43,6 +44,15 @@ class PublishMachine(
|
||||
/** 运行期注入真实配置(服务层配置流调用) */
|
||||
fun updateConfig(cfg: ToutiaoConfig) {
|
||||
this.toutiaoConfig = cfg
|
||||
if (phase == Phase.PAUSED && draftAttemptId == null && declaration != cfg.workDeclaration &&
|
||||
cfg.workDeclaration in com.haorui.app.data.model.AppConfig.DECLARATIONS) {
|
||||
declaration = cfg.workDeclaration
|
||||
declarationOpened = false
|
||||
declarationSelected = false
|
||||
declarationVerified = false
|
||||
declarationOptionRetry = 0
|
||||
go(Phase.PREPARE)
|
||||
}
|
||||
}
|
||||
|
||||
enum class Phase {
|
||||
@@ -64,6 +74,8 @@ class PublishMachine(
|
||||
DONE,
|
||||
/** 失败清理 */
|
||||
FAILED,
|
||||
/** 保留任务和素材,等待核对或修正不支持的声明。 */
|
||||
PAUSED,
|
||||
}
|
||||
|
||||
// ── 任务数据 ──────────────────────────────────────────────
|
||||
@@ -89,6 +101,10 @@ class PublishMachine(
|
||||
|
||||
/** 声明选项查找重试(对照原 500ms 轮询直到选项出现) */
|
||||
private var declarationOptionRetry = 0
|
||||
private var declarationOpened = false
|
||||
private var declarationSelected = false
|
||||
private var declarationVerified = false
|
||||
private var draftAttemptId: String? = null
|
||||
|
||||
/**
|
||||
* 提交一个发布任务。
|
||||
@@ -123,6 +139,10 @@ class PublishMachine(
|
||||
this.nullRootStreak = 0
|
||||
this.titleFocused = false
|
||||
this.declarationOptionRetry = 0
|
||||
this.declarationOpened = false
|
||||
this.declarationSelected = false
|
||||
this.declarationVerified = false
|
||||
this.draftAttemptId = null
|
||||
go(Phase.PREPARE)
|
||||
log("提交发布任务:${title.take(24)}…")
|
||||
return true
|
||||
@@ -193,9 +213,14 @@ class PublishMachine(
|
||||
Phase.WAIT_RECEIPT -> doWaitReceipt()
|
||||
Phase.DONE -> doDone()
|
||||
Phase.FAILED -> doFailed()
|
||||
Phase.PAUSED -> Unit
|
||||
}
|
||||
} catch (cancelled: kotlinx.coroutines.CancellationException) {
|
||||
withContext(NonCancellable) { runCatching { sharedSession?.markUnknown("发布步骤已取消,等待作品核对") } }
|
||||
if (draftAttemptId != null) {
|
||||
go(Phase.PAUSED)
|
||||
TaskStatusBus.status("草稿提交已中断,结果待核对,素材已保留")
|
||||
}
|
||||
throw cancelled
|
||||
} finally {
|
||||
busy.set(false)
|
||||
@@ -206,6 +231,10 @@ class PublishMachine(
|
||||
|
||||
private suspend fun doPrepare() {
|
||||
if (pauseForSharedAccount()) return
|
||||
if (declaration !in com.haorui.app.data.model.AppConfig.DECLARATIONS) {
|
||||
pauseForReview("作品声明「$declaration」不受当前版本支持,请在采集设置重新选择")
|
||||
return
|
||||
}
|
||||
if (title.isBlank() || mediaUri.isBlank()) {
|
||||
log("标题或素材为空,任务作废")
|
||||
go(Phase.FAILED)
|
||||
@@ -367,6 +396,8 @@ class PublishMachine(
|
||||
|
||||
val ok = svc.gestures.setText(titleBox, title)
|
||||
runCatching { titleBox.recycle() }
|
||||
|
||||
|
||||
if (!ok) {
|
||||
log("标题写入失败,重试 $titleRetry/3")
|
||||
titleRetry++
|
||||
@@ -488,124 +519,196 @@ class PublishMachine(
|
||||
log("退出子页面达最大层数,可能未回到发布页")
|
||||
}
|
||||
|
||||
/** 作品声明 */
|
||||
/** 只打开一次声明弹层;选项消失且编辑器回读一致后才能提交。 */
|
||||
private suspend fun doSetDeclaration() {
|
||||
if (!declarationOpened && dismissKeyboardIfVisible()) return
|
||||
val root = rootOrNull() ?: return
|
||||
val decl = NodeLocator.byText(root, ToutiaoSelectors.TXT_DECLARATION)
|
||||
if (decl == null) {
|
||||
// 对照原 C1:「未找到作品声明入口;未发布」—— 不带声明发布会合规风险
|
||||
log("未找到作品声明入口;未发布(对照原 C1)")
|
||||
TaskStatusBus.status("未找到作品声明入口;未发布")
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
svc.gestures.tapNode(decl)
|
||||
runCatching { decl.recycle() }
|
||||
TaskStatusBus.status("已打开作品声明,准备选择:$declaration")
|
||||
delay(700)
|
||||
|
||||
// 对照原:轮询等声明选项出现(u1(f0)),未出现 500ms 重试
|
||||
val opt = NodeLocator.byText(svc.root(), declaration)
|
||||
if (opt == null) {
|
||||
declarationOptionRetry++
|
||||
if (declarationOptionRetry < DECLARATION_OPTION_RETRY_LIMIT) {
|
||||
log("作品声明选项未出现,等待 $declarationOptionRetry/$DECLARATION_OPTION_RETRY_LIMIT")
|
||||
delay(500)
|
||||
try {
|
||||
if (declarationOpened && !declarationSheetOpen(root) && declarationReadback(root) == declaration) {
|
||||
declarationVerified = true
|
||||
log("作品声明回读通过:$declaration")
|
||||
go(Phase.CONFIRM)
|
||||
return
|
||||
}
|
||||
log("未找到作品声明选项「$declaration」(对照原等待超时仍进入下一步,由回读兜底)")
|
||||
declarationOptionRetry = 0
|
||||
go(Phase.CONFIRM)
|
||||
if (!declarationOpened) {
|
||||
val entry = NodeLocator.byText(root, ToutiaoSelectors.TXT_DECLARATION)
|
||||
if (entry == null) { pauseForReview("未找到作品声明入口,任务已暂停"); return }
|
||||
val opened = try { svc.gestures.tapNodeOnce(entry) } finally { entry.recycle() }
|
||||
if (!opened) { pauseForReview("作品声明入口点击结果不明,任务已暂停"); return }
|
||||
declarationOpened = true
|
||||
delay(500)
|
||||
}
|
||||
} finally { root.recycle() }
|
||||
val sheet = rootOrNull() ?: return
|
||||
val options = sheet.findAccessibilityNodeInfosByViewId("${com.haorui.app.automation.Targets.TOUTIAO_PKG}:id/fci").orEmpty()
|
||||
try {
|
||||
val option = options.firstOrNull { it.isVisibleToUser && it.text?.toString() == declaration }
|
||||
if (option != null && svc.gestures.tapNodeOnce(option)) declarationSelected = true
|
||||
if (++declarationOptionRetry >= DECLARATION_OPTION_RETRY_LIMIT) {
|
||||
pauseForReview("作品声明未能完成回读,任务已暂停,素材保留")
|
||||
}
|
||||
} finally { options.forEach { it.recycle() }; sheet.recycle() }
|
||||
}
|
||||
|
||||
private fun declarationReadback(root: AccessibilityNodeInfo): String? {
|
||||
val node = NodeLocator.byId(root, "${com.haorui.app.automation.Targets.TOUTIAO_PKG}:id/jm2")
|
||||
val summary = try { node?.text?.toString() } finally { node?.recycle() }
|
||||
return DraftReceiptPolicy.declarationReadback(declaration, declarationSelected, declarationSheetOpen(root), summary)
|
||||
}
|
||||
|
||||
private suspend fun dismissKeyboardIfVisible(): Boolean {
|
||||
if (svc.currentPackage() != com.haorui.app.automation.Targets.TOUTIAO_PKG) return false
|
||||
val visible = svc.windows.any { window ->
|
||||
window.type == android.view.accessibility.AccessibilityWindowInfo.TYPE_INPUT_METHOD &&
|
||||
!android.graphics.Rect().also(window::getBoundsInScreen).isEmpty
|
||||
}
|
||||
if (!visible) return false
|
||||
svc.gestures.back()
|
||||
delay(300)
|
||||
log("已收起标题输入键盘,等待编辑器布局稳定")
|
||||
return true
|
||||
}
|
||||
|
||||
private fun declarationSheetOpen(root: AccessibilityNodeInfo): Boolean {
|
||||
val nodes = root.findAccessibilityNodeInfosByViewId("${com.haorui.app.automation.Targets.TOUTIAO_PKG}:id/fci").orEmpty()
|
||||
return try { nodes.any { it.isVisibleToUser && it.text?.toString() == "取消" } } finally { nodes.forEach { it.recycle() } }
|
||||
}
|
||||
|
||||
private fun pauseForReview(reason: String) {
|
||||
log(reason)
|
||||
TaskStatusBus.status(reason)
|
||||
go(Phase.PAUSED)
|
||||
svc.stopAutomation()
|
||||
}
|
||||
|
||||
private fun draftEditorMatches(root: AccessibilityNodeInfo): Boolean {
|
||||
if (root.packageName?.toString() != com.haorui.app.automation.Targets.TOUTIAO_PKG || declarationSheetOpen(root)) return false
|
||||
val node = NodeLocator.byId(root, ToutiaoSelectors.ID_PUB_TITLE) ?: return false
|
||||
val matches = try { node.text?.toString() == title } finally { node.recycle() }
|
||||
return matches && declarationReadback(root) == declaration
|
||||
}
|
||||
|
||||
private suspend fun draftReceiptLines(): List<String> {
|
||||
com.haorui.app.overlay.MonitorOverlay.setHidden(true)
|
||||
return try {
|
||||
delay(200)
|
||||
val bitmap = com.haorui.app.ocr.ScreenCapturer(svc).capture() ?: return emptyList()
|
||||
try {
|
||||
val lines = com.haorui.app.ocr.OcrProcessor.recognize(bitmap).flatMap { it.lines }.filter { line ->
|
||||
val box = line.boundingBox
|
||||
box != null && box.centerY() > bitmap.height * 0.35 && box.centerY() < bitmap.height * 0.85 &&
|
||||
box.centerX() > bitmap.width * 0.2 && box.centerX() < bitmap.width * 0.8
|
||||
}.map { it.text }
|
||||
kotlinx.coroutines.currentCoroutineContext().ensureActive()
|
||||
lines.filter { it.contains("保存") && it.contains("草稿") }.forEach { log("草稿回执候选:${it.take(40)}") }
|
||||
lines
|
||||
} finally { bitmap.recycle() }
|
||||
} finally { com.haorui.app.overlay.MonitorOverlay.setHidden(false) }
|
||||
}
|
||||
|
||||
private suspend fun dispatchDraft() {
|
||||
if (draftAttemptId != null) { pauseForReview("草稿已有提交意图,禁止重复点击,等待核对"); return }
|
||||
if (DraftReceiptPolicy.hasSuccess(draftReceiptLines())) {
|
||||
if (++confirmRetry > CONFIRM_MAX_RETRY) pauseForReview("旧草稿提示尚未消失,未发送新草稿")
|
||||
return
|
||||
}
|
||||
declarationOptionRetry = 0
|
||||
val tapped = svc.gestures.tapNode(opt)
|
||||
runCatching { opt.recycle() }
|
||||
if (tapped) {
|
||||
TaskStatusBus.status("已选择作品声明:$declaration;等待回读")
|
||||
log("作品声明已设为「$declaration」")
|
||||
} else {
|
||||
log("作品声明选项 tap 失败,重试一次")
|
||||
val opt2 = NodeLocator.byText(svc.root(), declaration)
|
||||
if (opt2 != null) {
|
||||
svc.gestures.tapNode(opt2)
|
||||
runCatching { opt2.recycle() }
|
||||
TaskStatusBus.status("已选择作品声明:$declaration;等待回读")
|
||||
}
|
||||
}
|
||||
go(Phase.CONFIRM)
|
||||
val fresh = rootOrNull() ?: return
|
||||
try {
|
||||
if (!declarationVerified || !draftEditorMatches(fresh)) { pauseForReview("草稿标题或声明已变化,未发送"); return }
|
||||
val button = NodeLocator.byId(fresh, ToutiaoSelectors.ID_PUB_DRAFT) ?: return
|
||||
try {
|
||||
val id = try { videoDownloader?.beginDraft(mediaUri, title, declaration) }
|
||||
catch (failure: Exception) { log("草稿意图保存失败:${failure.javaClass.simpleName}"); null }
|
||||
if (id == null) { pauseForReview("草稿意图无法保存,未点击存草稿"); return }
|
||||
draftAttemptId = id
|
||||
receiptWaitStartMs = SystemClock.elapsedRealtime()
|
||||
kotlinx.coroutines.currentCoroutineContext().ensureActive()
|
||||
if (!svc.gestures.tapNodeOnce(button)) { pauseForReview("草稿点击结果不明,素材保留,等待核对"); return }
|
||||
go(Phase.WAIT_RECEIPT)
|
||||
TaskStatusBus.status("草稿动作已发送,等待当前编辑器的保存成功提示")
|
||||
} finally { button.recycle() }
|
||||
} finally { fresh.recycle() }
|
||||
}
|
||||
|
||||
/** 点发布 / 存草稿 */
|
||||
private suspend fun doConfirm() {
|
||||
if (pauseForSharedAccount()) return
|
||||
if (dismissKeyboardIfVisible()) return
|
||||
val root = rootOrNull() ?: return
|
||||
eligibilityCheck?.invoke()?.let { reason ->
|
||||
log("点击发布前筛选拒绝:$reason")
|
||||
TaskStatusBus.status("发布前复查跳过:$reason")
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
|
||||
// 兜底:若此刻不在发布页(可能被子页面/异步跳转带走),先退回
|
||||
val titleBox = NodeLocator.byId(root, ToutiaoSelectors.ID_PUB_TITLE)
|
||||
if (titleBox == null) {
|
||||
log("当前不在发布页,尝试退回")
|
||||
ensureBackToPublisher()
|
||||
return
|
||||
}
|
||||
runCatching { titleBox.recycle() }
|
||||
|
||||
val btnId = if (autoPublish) ToutiaoSelectors.ID_PUB_PUBLISH else ToutiaoSelectors.ID_PUB_DRAFT
|
||||
val btn = NodeLocator.byId(root, btnId)
|
||||
?: NodeLocator.byText(root, if (autoPublish) "发布" else "存草稿")
|
||||
|
||||
if (btn == null) {
|
||||
confirmRetry++
|
||||
// 需要真实结构才能校正选择器
|
||||
if (confirmRetry == 1) {
|
||||
log("CONFIRM 节点树诊断 →\n${NodeLocator.dumpTree(root, maxDepth = 12, maxNodes = 150)}")
|
||||
}
|
||||
// ⚠️ 加重试上限:原先无限 delay(800) 重试,真机实测空转 24 次,
|
||||
// 既不放弃也不上报,白白占住状态机。
|
||||
if (confirmRetry > CONFIRM_MAX_RETRY) {
|
||||
log("未找到${if (autoPublish) "发布" else "存草稿"}按钮,重试 $confirmRetry 次后放弃")
|
||||
try {
|
||||
eligibilityCheck?.invoke()?.let { reason ->
|
||||
log("点击发布前筛选拒绝:$reason")
|
||||
TaskStatusBus.status("发布前复查跳过:$reason")
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
log("未找到${if (autoPublish) "发布" else "存草稿"}按钮,重试 $confirmRetry/$CONFIRM_MAX_RETRY")
|
||||
delay(800)
|
||||
return
|
||||
}
|
||||
val context = sharedSession
|
||||
val tapped = if (context != null) {
|
||||
val titleNode = NodeLocator.byId(root, ToutiaoSelectors.ID_PUB_TITLE)
|
||||
val exactTitle = titleNode?.text?.toString() == title
|
||||
titleNode?.recycle()
|
||||
context.dispatch(payloadFingerprint(), { exactTitle && svc.currentCrossRunGeneration() == context.generation }) {
|
||||
svc.gestures.tapNodeOnce(btn)
|
||||
|
||||
// 兜底:若此刻不在发布页(可能被子页面/异步跳转带走),先退回
|
||||
val titleBox = NodeLocator.byId(root, ToutiaoSelectors.ID_PUB_TITLE)
|
||||
if (titleBox == null) {
|
||||
log("当前不在发布页,尝试退回")
|
||||
ensureBackToPublisher()
|
||||
return
|
||||
}
|
||||
} else svc.gestures.tapNode(btn)
|
||||
runCatching { btn.recycle() }
|
||||
if (context != null && !tapped) {
|
||||
TaskStatusBus.status(context.reason)
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
// ⚠️ 二轮审计:tap 失败不能进 WAIT_RECEIPT 干等 30 分钟超时
|
||||
if (!tapped) {
|
||||
log("发布按钮 tap 失败,重试")
|
||||
confirmRetry++
|
||||
if (confirmRetry > CONFIRM_MAX_RETRY) {
|
||||
go(Phase.FAILED)
|
||||
} else {
|
||||
runCatching { titleBox.recycle() }
|
||||
|
||||
if (!declarationVerified || declarationSheetOpen(root) || declarationReadback(root) != declaration) {
|
||||
pauseForReview("作品声明未通过回读,未发送提交动作")
|
||||
return
|
||||
}
|
||||
if (!autoPublish) { dispatchDraft(); return }
|
||||
|
||||
val btnId = if (autoPublish) ToutiaoSelectors.ID_PUB_PUBLISH else ToutiaoSelectors.ID_PUB_DRAFT
|
||||
val btn = NodeLocator.byId(root, btnId)
|
||||
?: NodeLocator.byText(root, if (autoPublish) "发布" else "存草稿")
|
||||
|
||||
if (btn == null) {
|
||||
confirmRetry++
|
||||
// 需要真实结构才能校正选择器
|
||||
if (confirmRetry == 1) {
|
||||
log("CONFIRM 节点树诊断 →\n${NodeLocator.dumpTree(root, maxDepth = 12, maxNodes = 150)}")
|
||||
}
|
||||
// ⚠️ 加重试上限:原先无限 delay(800) 重试,真机实测空转 24 次,
|
||||
// 既不放弃也不上报,白白占住状态机。
|
||||
if (confirmRetry > CONFIRM_MAX_RETRY) {
|
||||
log("未找到${if (autoPublish) "发布" else "存草稿"}按钮,重试 $confirmRetry 次后放弃")
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
log("未找到${if (autoPublish) "发布" else "存草稿"}按钮,重试 $confirmRetry/$CONFIRM_MAX_RETRY")
|
||||
delay(800)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
receiptWaitStartMs = SystemClock.elapsedRealtime()
|
||||
TaskStatusBus.status("发布动作已发送,等待头条成功回执;确认后才删除素材")
|
||||
go(Phase.WAIT_RECEIPT)
|
||||
val context = sharedSession
|
||||
val tapped = if (context != null) {
|
||||
val titleNode = NodeLocator.byId(root, ToutiaoSelectors.ID_PUB_TITLE)
|
||||
val exactTitle = titleNode?.text?.toString() == title
|
||||
titleNode?.recycle()
|
||||
context.dispatch(payloadFingerprint(), { exactTitle && svc.currentCrossRunGeneration() == context.generation }) {
|
||||
svc.gestures.tapNodeOnce(btn)
|
||||
}
|
||||
} else svc.gestures.tapNode(btn)
|
||||
runCatching { btn.recycle() }
|
||||
if (context != null && !tapped) {
|
||||
TaskStatusBus.status(context.reason)
|
||||
go(Phase.FAILED)
|
||||
return
|
||||
}
|
||||
// ⚠️ 二轮审计:tap 失败不能进 WAIT_RECEIPT 干等 30 分钟超时
|
||||
if (!tapped) {
|
||||
log("发布按钮 tap 失败,重试")
|
||||
confirmRetry++
|
||||
if (confirmRetry > CONFIRM_MAX_RETRY) {
|
||||
go(Phase.FAILED)
|
||||
} else {
|
||||
delay(800)
|
||||
}
|
||||
return
|
||||
}
|
||||
receiptWaitStartMs = SystemClock.elapsedRealtime()
|
||||
TaskStatusBus.status("发布动作已发送,等待头条成功回执;确认后才删除素材")
|
||||
go(Phase.WAIT_RECEIPT)
|
||||
} finally { root.recycle() }
|
||||
}
|
||||
|
||||
private fun pauseForSharedAccount(): Boolean {
|
||||
@@ -617,6 +720,25 @@ class PublishMachine(
|
||||
|
||||
/** 等回执(发布成功 / 发布失败 / 已发布)—— 未确认回执不计数 */
|
||||
private suspend fun doWaitReceipt() {
|
||||
if (!autoPublish) {
|
||||
val root = rootOrNull() ?: return
|
||||
val matches = try { draftEditorMatches(root) } finally { root.recycle() }
|
||||
val lines = if (matches) draftReceiptLines() else emptyList()
|
||||
val fresh = rootOrNull() ?: return
|
||||
val confirmed = try {
|
||||
val titleNode = NodeLocator.byId(fresh, ToutiaoSelectors.ID_PUB_TITLE)
|
||||
val actualTitle = try { titleNode?.text?.toString() } finally { titleNode?.recycle() }
|
||||
matches && draftEditorMatches(fresh) && DraftReceiptPolicy.confirms(title, actualTitle,
|
||||
declaration, declarationReadback(fresh), lines, SystemClock.elapsedRealtime() - receiptWaitStartMs)
|
||||
} finally { fresh.recycle() }
|
||||
if (confirmed) {
|
||||
log("当前标题和声明匹配,收到明确的保存草稿成功提示")
|
||||
go(Phase.DONE)
|
||||
} else if (SystemClock.elapsedRealtime() - receiptWaitStartMs > DRAFT_RECEIPT_TIMEOUT_MS) {
|
||||
pauseForReview("草稿未收到明确保存回执,结果待核对,素材已保留")
|
||||
}
|
||||
return
|
||||
}
|
||||
sharedSession?.let { context ->
|
||||
// M6 作品核对器尚未接通。共享尝试不能进入旧的分享面板/超时成功判定。
|
||||
context.markUnknown("发布动作已派发,等待明确作品回执")
|
||||
@@ -634,7 +756,6 @@ class PublishMachine(
|
||||
// 「发布成功」单条即成功;
|
||||
// 「已发布」必须**同时**看到标题节点(防 feed 里"已发布"字样误判)。
|
||||
val publishOk = NodeLocator.byTextContains(root, ToutiaoSelectors.TXT_PUBLISH_OK)
|
||||
?: if (!autoPublish) NodeLocator.byTextContains(root, "草稿") else null
|
||||
// 兜底:发布成功后头条会自动弹「分享至」面板(引导分享),可作成功信号
|
||||
?: NodeLocator.byTextContains(root, ToutiaoSelectors.TXT_SHARE_TO)
|
||||
if (publishOk != null) {
|
||||
@@ -664,13 +785,6 @@ class PublishMachine(
|
||||
}
|
||||
|
||||
val waited = SystemClock.elapsedRealtime() - receiptWaitStartMs
|
||||
// ⚠️ 草稿模式:存草稿通常**没有成功提示**,不宜按 30 分钟等回执。
|
||||
// 短时间内没检测到失败提示即视为成功,避免状态机长期卡死。
|
||||
if (!autoPublish && waited > DRAFT_RECEIPT_TIMEOUT_MS) {
|
||||
log("草稿模式:${waited / 1000}s 未见失败提示,视为保存成功")
|
||||
go(Phase.DONE)
|
||||
return
|
||||
}
|
||||
|
||||
// 超时判定(原 publish_timeout 默认 30 分钟)
|
||||
if (waited > RECEIPT_TIMEOUT_MS) {
|
||||
@@ -706,6 +820,10 @@ class PublishMachine(
|
||||
svc.stopAutomation()
|
||||
return
|
||||
}
|
||||
if (!autoPublish && (draftAttemptId == null || videoDownloader?.confirmDraft(draftAttemptId!!) != true)) {
|
||||
pauseForReview("草稿回执日志未能确认,素材继续保留")
|
||||
return
|
||||
}
|
||||
// 对照原 m2():BACK 退出发布页 → 删除本地素材 → 进度计数 → 启动休息
|
||||
log("收到成功回执,开始收尾(删素材 + 计数 + 休息)")
|
||||
svc.gestures.back() // performGlobalAction(BACK) 退出发布页
|
||||
@@ -721,13 +839,15 @@ class PublishMachine(
|
||||
}
|
||||
quotaManager?.recordPublish()
|
||||
// 对照原 m2() 的两行输出:过程日志 + 监控窗"进度 X/Y"
|
||||
log("发布成功;" + (if (deleted) "本地素材已删除" else "本地素材记录已清理"))
|
||||
TaskStatusBus.status("发布成功,已清理本地素材;进度 ${quotaManager?.dailyProgress ?: "0/0"}")
|
||||
val outcome = if (autoPublish) "发布成功" else "草稿保存已确认"
|
||||
log("$outcome;" + (if (deleted) "本地素材已删除" else "本地素材记录已清理"))
|
||||
TaskStatusBus.status("$outcome,已清理本地素材;处理进度 ${quotaManager?.dailyProgress ?: "0/0"}")
|
||||
// 启动休息倒计时 + 休息浏览(对照原 X2("发布完成"))
|
||||
restBrowse?.startRest("发布完成")
|
||||
restBrowse?.startRest(if (autoPublish) "发布完成" else "草稿已保存")
|
||||
title = ""
|
||||
mediaUri = ""
|
||||
eligibilityCheck = null
|
||||
draftAttemptId = null
|
||||
reset()
|
||||
}
|
||||
|
||||
@@ -802,7 +922,7 @@ class PublishMachine(
|
||||
/** 发布页自动重开上限(对照原 f1289n0 ≤2) */
|
||||
private const val PUBLISH_REOPEN_LIMIT = 2
|
||||
|
||||
/** 草稿模式回执等待上限:存草稿通常无成功提示,短等即判成功 */
|
||||
/** 草稿回执等待上限:超时进入待核对,不能视为保存成功 */
|
||||
private const val DRAFT_RECEIPT_TIMEOUT_MS = 8L * 1000L
|
||||
|
||||
/** 声明选项等待重试上限(对照原 500ms 轮询) */
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.haorui.app.automation.selection
|
||||
|
||||
/** 已观察到的 18.3.0 草稿回执;“存草稿”按钮、分享弹层和超时都不是成功。 */
|
||||
object DraftReceiptPolicy {
|
||||
const val SUCCESS = "保存草稿成功"
|
||||
private const val MARKERS = "✓✔√☑✅○〇◎●0oOQC©"
|
||||
private val cleanReceipt = Regex("[$MARKERS]?保存草稿成功[!!。]?")
|
||||
|
||||
/**
|
||||
* 真机实测:回执是“⊙ 图标 + 保存草稿成功”胶囊,OCR 会把它与同屏位置卡片文本合并成一行,
|
||||
* 且 ⊙ 图标被误读为 0/O/。 等非汉字字符(“0保存草稿成功”“宁兴·城O保存草稿成功鄞州万达广场小”
|
||||
* “城市广场。保存草稿成功达广场IMAX店”)。判定:
|
||||
* 1. 整行即回执签名(含空格与图标误读容错);
|
||||
* 2. 或行内“保存草稿成功”紧邻的前一字符不是汉字——否定句(“未能…”“出现…后返回”)以汉字承接,仍被拒绝。
|
||||
*/
|
||||
fun hasSuccess(lines: List<String>): Boolean = lines.any { raw ->
|
||||
val line = raw.filterNot(Char::isWhitespace)
|
||||
if (cleanReceipt.matches(line)) return@any true
|
||||
val index = line.indexOf(SUCCESS)
|
||||
index > 0 && line[index - 1].code !in 0x4E00..0x9FFF
|
||||
}
|
||||
|
||||
fun declarationReadback(expected: String, selected: Boolean, sheetOpen: Boolean, summary: String?): String? {
|
||||
if (!selected || sheetOpen) return null
|
||||
return summary?.takeIf { it.isNotBlank() } ?: expected.takeIf { it == "内容无需标注" }
|
||||
}
|
||||
|
||||
fun confirms(expectedTitle: String, actualTitle: String?, expectedDeclaration: String, actualDeclaration: String?,
|
||||
receiptLines: List<String>, elapsedMs: Long): Boolean =
|
||||
expectedTitle.isNotBlank() && actualTitle == expectedTitle && actualDeclaration == expectedDeclaration &&
|
||||
elapsedMs in 0..8_000 && hasSuccess(receiptLines)
|
||||
}
|
||||
@@ -179,6 +179,7 @@ object CreditGateRunner {
|
||||
service: HaoRuiAccessibilityService,
|
||||
region: Rect?,
|
||||
): Int? {
|
||||
if (!service.checkVersionGate()) return null
|
||||
val ticket = service.tryEnterCreditForeground() ?: return null
|
||||
service.frontGuard.creditNavigating = true
|
||||
try {
|
||||
@@ -186,7 +187,8 @@ object CreditGateRunner {
|
||||
if (!service.foregroundCoordinator.isCurrent(ticket)) return@withOverlayHidden null
|
||||
val capturer = ScreenCapturer(service)
|
||||
// 快路径:当前屏已是信用分页(重复检查/误入时省导航)
|
||||
var score = CreditScoreReader.readFromScreen(capturer, region)
|
||||
var score = if (service.currentPackage() == Targets.TOUTIAO_PKG) CreditScoreReader.readFromScreen(capturer, region) else null
|
||||
if (!service.foregroundCoordinator.isCurrent(ticket)) return@withOverlayHidden null
|
||||
if (score == null) {
|
||||
RunLogger.i(TAG, "当前屏未识别到信用分,导航至信用分页(我的→创作中心→全部服务→处罚中心)")
|
||||
if (navigateToCreditPage(service, ticket)) {
|
||||
@@ -195,7 +197,7 @@ object CreditGateRunner {
|
||||
RunLogger.w(TAG, "信用分页导航失败(页面改版或定位失败),按 fail-open 放行")
|
||||
}
|
||||
}
|
||||
score
|
||||
if (service.foregroundCoordinator.isCurrent(ticket) && service.currentPackage() == Targets.TOUTIAO_PKG) score else null
|
||||
}
|
||||
} finally {
|
||||
service.frontGuard.creditNavigating = false
|
||||
@@ -255,9 +257,11 @@ object CreditGateRunner {
|
||||
}
|
||||
// ① 树定位(原生页有 text/desc 节点)
|
||||
val root = service.root()
|
||||
val node = root?.let {
|
||||
NodeLocator.byText(it, label) ?: NodeLocator.byTextContains(it, label)
|
||||
}
|
||||
val node = try {
|
||||
root?.takeIf { it.packageName?.toString() == Targets.TOUTIAO_PKG }?.let {
|
||||
NodeLocator.byText(it, label) ?: NodeLocator.byTextContains(it, label)
|
||||
}
|
||||
} finally { root?.recycle() }
|
||||
if (node != null) {
|
||||
if (!service.foregroundCoordinator.isCurrent(ticket)) {
|
||||
node.recycle()
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.haorui.app.ocr
|
||||
|
||||
/** 18.3.0 处罚中心的信用分卡片;仅接收已核对页面和列位置中的完整分数字样。 */
|
||||
object CreditScoreParser {
|
||||
data class Area(val left: Int, val top: Int, val right: Int, val bottom: Int) {
|
||||
val centerX get() = left / 2.0 + right / 2.0
|
||||
val centerY get() = top / 2.0 + bottom / 2.0
|
||||
fun valid(width: Int, height: Int) = left >= 0 && top >= 0 && right > left && bottom > top && right <= width && bottom <= height
|
||||
fun contains(other: Area) = other.left >= left && other.top >= top && other.right <= right && other.bottom <= bottom
|
||||
}
|
||||
data class Line(val text: String, val bounds: Area)
|
||||
|
||||
private val labelPattern = Regex("信用(?:分|评分)(?:[::]?([0-9Oo]{1,3})分?)?")
|
||||
private val valuePattern = Regex("([0-9Oo]{1,3})分?")
|
||||
|
||||
fun extract(lines: List<Line>, width: Int, height: Int, scoreRegion: Area? = null): Int? {
|
||||
if (width <= 0 || height <= 0 || scoreRegion != null && !scoreRegion.valid(width, height)) return null
|
||||
val visible = lines.filter { it.bounds.valid(width, height) }.map { it.copy(text = normalize(it.text)) }
|
||||
val title = visible.singleOrNull { it.text == "账号处罚中心" && it.bounds.centerY < height * 0.15 } ?: return null
|
||||
val label = visible.singleOrNull {
|
||||
labelPattern.matches(it.text) && it.bounds.top > title.bounds.bottom && it.bounds.bottom < height * 0.45
|
||||
} ?: return null
|
||||
val status = visible.singleOrNull {
|
||||
it.text == "账号状态" && it.bounds.left > label.bounds.right &&
|
||||
kotlin.math.abs(it.bounds.centerY - label.bounds.centerY) < height * 0.035
|
||||
} ?: return null
|
||||
|
||||
val candidates = visible.filter { line ->
|
||||
line.bounds.centerX >= label.bounds.left - width * 0.03 && line.bounds.right < status.bounds.left &&
|
||||
line.bounds.centerY >= label.bounds.centerY && line.bounds.bottom <= label.bounds.bottom + height * 0.06 &&
|
||||
(scoreRegion == null || scoreRegion.contains(line.bounds))
|
||||
}
|
||||
val values = mutableSetOf<Int>()
|
||||
for (line in candidates) {
|
||||
val match = if (line == label) labelPattern.matchEntire(line.text) else valuePattern.matchEntire(line.text)
|
||||
val raw = match?.groupValues?.get(1)?.takeIf { it.isNotEmpty() } ?: continue
|
||||
val value = raw.replace('O', '0').replace('o', '0').toIntOrNull() ?: return null
|
||||
if (value !in 0..100) return null
|
||||
values += value
|
||||
}
|
||||
return values.singleOrNull()
|
||||
}
|
||||
|
||||
private fun normalize(text: String): String = buildString {
|
||||
for (char in text) {
|
||||
if (char.isWhitespace() || Character.isSpaceChar(char)) continue
|
||||
append(if (char in '0'..'9') (char.code - 0xFEE0).toChar() else char)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +1,31 @@
|
||||
package com.haorui.app.ocr
|
||||
|
||||
import android.graphics.Rect
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import com.haorui.app.automation.RunLogger
|
||||
|
||||
/**
|
||||
* 信用分 OCR 文本解析。约束分数范围与匹配上下文,避免把播放时长等无关数字当作信用分。
|
||||
*/
|
||||
/** 读取完整页面的 OCR 行与位置;限定信用分卡片,不记录账户页面全文。 */
|
||||
object CreditScoreReader {
|
||||
|
||||
private const val TAG = "HaoRui-Credit"
|
||||
|
||||
/**
|
||||
* 严格正则(对照原 `CreditScoreParser.f308a` + **matches() 整串语义**):
|
||||
* 整个字符串必须是 `信用分 100` / `100分` / `100` 形,不能从长文里 find。
|
||||
* ⚠️ 2026-10-31 长测实测:原 find() + 「前缀/后缀都可选」会把 **时钟「11:59」**
|
||||
* 的 11 当成信用分,误判 BLOCKED 锁死当天任务。对齐原 matches()。
|
||||
*/
|
||||
private val SCORE_WHOLE = Regex(
|
||||
"""(?:(?:信\s*用\s*分(?:\s*数)?|信\s*用\s*评\s*分)\s*[::]?\s*)?([0-9]{1,3})\s*分?""",
|
||||
)
|
||||
|
||||
/** 宽松正则(对照原 `CreditScoreParser.b`):**必须带「分」**,且处理 O/o 混淆 */
|
||||
private val LOOSE_PATTERN = Regex("""(?<![0-9Oo])([0-9Oo]{1,3})\s*分(?![0-9])""")
|
||||
|
||||
/** 信用分有效范围 */
|
||||
const val MIN_CREDIT = 0
|
||||
const val MAX_CREDIT = 100
|
||||
|
||||
/**
|
||||
* 归一化 OCR 文本(对照原 `CreditScoreParser.extractScoreText` + `b()`):
|
||||
* 全角数字/冒号转半角、去空白、O/o→0。
|
||||
*/
|
||||
private fun normalize(raw: String): String {
|
||||
val sb = StringBuilder(raw.length)
|
||||
var lastWasSpace = false
|
||||
for (ch in raw) {
|
||||
if (Character.isWhitespace(ch) || Character.isSpaceChar(ch)) {
|
||||
if (sb.isNotEmpty()) lastWasSpace = true
|
||||
continue
|
||||
}
|
||||
if (lastWasSpace && sb.isNotEmpty()) sb.append(' ')
|
||||
lastWasSpace = false
|
||||
// 全角数字 0-9 → 半角
|
||||
val c = if (ch in '0'..'9') (ch.code - 0xFEE0).toChar() else ch
|
||||
// 全角冒号/斜杠 → 半角(时长解析用)
|
||||
val c2 = when (c) {
|
||||
':' -> ':'
|
||||
'/' -> '/'
|
||||
else -> c
|
||||
}
|
||||
sb.append(c2)
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 OCR 文本提取信用分(对照原 `CreditScoreParser.parseScore` / `parseScoreLoose`)。
|
||||
*
|
||||
* 否决链(任一命中返回 null):
|
||||
* 1. 含「扣分/已扣/处罚」
|
||||
* 2. 含负分 `…-N 分…`
|
||||
* 3. 含加分 `…+N 分…`
|
||||
* 4. 多个**不同**数值冲突
|
||||
* 5. 超出 0~100
|
||||
*
|
||||
* 匹配语义(⚠️ 2026-10-31 长测实测必须收紧):
|
||||
* - 严格通道:**整行** matches(原 f308a + matches()),不能从长文 find
|
||||
* - 宽松通道:**必须带「分」**(原 b),否则「11:59」的 11 会误命中
|
||||
*
|
||||
* @param ocrText OCR 识别出的全文
|
||||
* @return 信用分(0~100),未识别/被否决返回 null
|
||||
*/
|
||||
fun extractCreditScore(ocrText: String): Int? {
|
||||
val text = normalize(ocrText)
|
||||
if (text.isEmpty()) return null
|
||||
|
||||
// ── 否决:扣分/处罚/加减分(对照原 parseScore 顶部 if)──
|
||||
val flat = text.replace(" ", "")
|
||||
if (flat.contains("扣分") || flat.contains("已扣") || flat.contains("处罚")) {
|
||||
RunLogger.w(TAG, "OCR 含扣分/处罚字样,否决信用分识别")
|
||||
return null
|
||||
}
|
||||
if (Regex("""[+\+]\s*[0-9Oo]{1,3}\s*分?""").containsMatchIn(flat) ||
|
||||
Regex("""[\--−–—]\s*[0-9Oo]{1,3}\s*分?""").containsMatchIn(flat)
|
||||
) {
|
||||
RunLogger.w(TAG, "OCR 含加减分字样,否决信用分识别")
|
||||
return null
|
||||
}
|
||||
|
||||
// ── 宽松通道:必须带「分」的 token(对照原 parseScoreLoose)──
|
||||
val found = LinkedHashSet<Int>()
|
||||
for (m in LOOSE_PATTERN.findAll(text)) {
|
||||
val v = m.groupValues[1].replace('O', '0').replace('o', '0').toIntOrNull()
|
||||
?: continue
|
||||
if (v in MIN_CREDIT..MAX_CREDIT) found.add(v)
|
||||
}
|
||||
if (found.size > 1) {
|
||||
RunLogger.w(TAG, "OCR 多值冲突 $found,否决信用分识别")
|
||||
return null
|
||||
}
|
||||
if (found.size == 1) {
|
||||
val score = found.first()
|
||||
RunLogger.i(TAG, "识别到信用分: $score(宽松通道)")
|
||||
return score
|
||||
}
|
||||
|
||||
// ── 严格通道:整行 matches(原 f308a + matcher.matches())──
|
||||
// 只在**单行本身就是分数形**时才认,绝不从长文里抠数字
|
||||
for (rawLine in text.split('\n', '|')) {
|
||||
val line = rawLine.trim()
|
||||
if (line.isEmpty()) continue
|
||||
val m = SCORE_WHOLE.matchEntire(line) ?: continue
|
||||
val v = m.groupValues[1].toIntOrNull() ?: continue
|
||||
if (v in MIN_CREDIT..MAX_CREDIT) {
|
||||
RunLogger.i(TAG, "识别到信用分: $v(严格整行)")
|
||||
return v
|
||||
}
|
||||
}
|
||||
RunLogger.w(TAG, "未能从 OCR 文本识别信用分")
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 从截图识别信用分。
|
||||
* @param capturer 截图器
|
||||
* @param region 信用分所在区域(屏幕坐标,null = 全屏搜索)
|
||||
* @return 信用分
|
||||
*/
|
||||
suspend fun readFromScreen(capturer: ScreenCapturer, region: Rect? = null): Int? {
|
||||
val text = capturer.captureAndRecognize(region)
|
||||
// 观测点(装机实测):区分「截屏失败(空文本)」与「截到但正则不中」两种死因
|
||||
if (text.isBlank()) {
|
||||
RunLogger.w(TAG, "OCR 文本为空(截屏失败或无文字内容)")
|
||||
} else {
|
||||
// 校准用:打全文(换行压平),真机正则校准需看完整识别结果
|
||||
RunLogger.i(TAG, "OCR 全文(${text.length} 字)=${text.replace('\n', '|')}")
|
||||
}
|
||||
return extractCreditScore(text)
|
||||
val bitmap = capturer.capture() ?: return null
|
||||
return try {
|
||||
val lines = OcrProcessor.recognize(bitmap).flatMap { block ->
|
||||
block.lines.mapNotNull { line ->
|
||||
val box = line.boundingBox ?: return@mapNotNull null
|
||||
CreditScoreParser.Line(line.text, CreditScoreParser.Area(box.left, box.top, box.right, box.bottom))
|
||||
}
|
||||
}
|
||||
kotlinx.coroutines.currentCoroutineContext().ensureActive()
|
||||
val area = region?.let { CreditScoreParser.Area(it.left, it.top, it.right, it.bottom) }
|
||||
val score = CreditScoreParser.extract(lines, bitmap.width, bitmap.height, area)
|
||||
if (score == null) RunLogger.w(TAG, "未能核对处罚中心信用分卡片(OCR 行数=${lines.size})")
|
||||
else RunLogger.i(TAG, "已核对处罚中心信用分:$score")
|
||||
score
|
||||
} finally { bitmap.recycle() }
|
||||
}
|
||||
}
|
||||
|
||||
object EarningsReader {
|
||||
|
||||
private const val TAG = "HaoRui-Earnings"
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.haorui.app.pipeline
|
||||
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.UUID
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
/** 草稿点击前落盘;未得到当前编辑器的明确回执前,缓存清理和失败分支不得删除素材。 */
|
||||
class PendingDraftStore(private val directory: File) {
|
||||
@Serializable
|
||||
data class Attempt(val id: String, val mediaPath: String, val title: String, val declaration: String, val createdAtMs: Long)
|
||||
|
||||
@Synchronized fun begin(mediaPath: String, title: String, declaration: String): Attempt {
|
||||
require(title.isNotBlank() && declaration.isNotBlank())
|
||||
val path = File(mediaPath).canonicalPath
|
||||
require(File(path).isFile)
|
||||
check(attempts().none { it.mediaPath == path }) { "该素材已有待核对草稿" }
|
||||
check(directory.isDirectory || directory.mkdirs())
|
||||
val attempt = Attempt(UUID.randomUUID().toString(), path, title, declaration, System.currentTimeMillis())
|
||||
val temporary = File(directory, "${attempt.id}.tmp")
|
||||
try {
|
||||
FileOutputStream(temporary).use { output ->
|
||||
output.write(Json.encodeToString(attempt).toByteArray(Charsets.UTF_8))
|
||||
output.fd.sync()
|
||||
}
|
||||
check(temporary.renameTo(File(directory, "${attempt.id}.json"))) { "草稿日志保存失败" }
|
||||
} finally { temporary.delete() }
|
||||
return attempt
|
||||
}
|
||||
|
||||
@Synchronized fun attempts(): List<Attempt> {
|
||||
if (!directory.exists()) return emptyList()
|
||||
val files = checkNotNull(directory.listFiles()) { "草稿日志不可读" }
|
||||
return files.filter { it.extension == "json" }.map { file ->
|
||||
Json.decodeFromString<Attempt>(file.readText()).also { check(file.name == "${it.id}.json") }
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized fun protectedPaths(): Set<String> = attempts().map { it.mediaPath }.toSet()
|
||||
|
||||
@Synchronized fun confirm(id: String): Boolean {
|
||||
val attempt = attempts().singleOrNull { it.id == id } ?: return false
|
||||
return File(directory, "${attempt.id}.json").delete()
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,21 @@ class VideoDownloader(private val context: Context) {
|
||||
/** 视频存储目录 */
|
||||
private val videoDir: File = File(context.getExternalFilesDir("videos") ?: context.filesDir, "videos").apply { mkdirs() }
|
||||
|
||||
private val pendingDrafts = PendingDraftStore(File(context.filesDir, "pending-drafts"))
|
||||
|
||||
fun beginDraft(path: String, title: String, declaration: String): String {
|
||||
check(File(path).canonicalFile.parentFile == videoDir.canonicalFile) { "草稿素材不在下载目录" }
|
||||
return pendingDrafts.begin(path, title, declaration).id
|
||||
}
|
||||
|
||||
fun confirmDraft(id: String): Boolean = pendingDrafts.confirm(id)
|
||||
|
||||
fun hasPendingDrafts(): Boolean = pendingDrafts.attempts().isNotEmpty()
|
||||
|
||||
fun isOwnedMedia(path: String): Boolean = runCatching {
|
||||
File(path).isFile && File(path).canonicalFile.parentFile == videoDir.canonicalFile
|
||||
}.getOrDefault(false)
|
||||
|
||||
/**
|
||||
* 已下载内容的 SHA-256 集合(内容级去重)。
|
||||
* ⚠️ 并发安全:管线多协程可能并行下载/查重(第一性审计)→ 线程安全 Set。
|
||||
@@ -304,11 +319,12 @@ class VideoDownloader(private val context: Context) {
|
||||
*/
|
||||
@Synchronized
|
||||
fun clearDownloadCache(exclude: Set<String> = emptySet()): Int {
|
||||
val protected = try { exclude + pendingDrafts.protectedPaths() } catch (_: Exception) { return 0 }
|
||||
var n = 0
|
||||
val cutoff = System.currentTimeMillis() - 24 * 60 * 60 * 1000L
|
||||
videoDir.listFiles()?.forEach { f ->
|
||||
if (f.isFile && (f.name.endsWith(".mp4") || f.name.endsWith(".tmp")) &&
|
||||
f.lastModified() < cutoff && f.absolutePath !in exclude
|
||||
f.lastModified() < cutoff && f.canonicalPath !in protected && f.absolutePath !in protected
|
||||
) {
|
||||
if (f.delete()) n++
|
||||
}
|
||||
@@ -371,6 +387,7 @@ class VideoDownloader(private val context: Context) {
|
||||
fun deleteVideo(filePath: String): Boolean {
|
||||
return try {
|
||||
val f = File(filePath)
|
||||
if (f.canonicalPath in pendingDrafts.protectedPaths()) return false
|
||||
if (f.exists()) f.delete() else false
|
||||
} catch (_: Exception) {
|
||||
false
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.haorui.app.automation.selection
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class DraftReceiptPolicyTest {
|
||||
private fun confirms(lines: List<String>, actualTitle: String? = "测试视频", actualDeclaration: String? = "内容无需标注",
|
||||
elapsed: Long = 1500) =
|
||||
DraftReceiptPolicy.confirms("测试视频", actualTitle, "内容无需标注", actualDeclaration, lines, elapsed)
|
||||
|
||||
@Test fun acceptsTheObservedReceiptForTheCurrentTitleAndDeclaration() {
|
||||
assertTrue(confirms(listOf("保存草稿成功")))
|
||||
}
|
||||
|
||||
@Test fun buttonsSharePanelsAndTimeoutAreNeverReceipts() {
|
||||
listOf("存草稿", "草稿", "发布成功", "分享至", "未能保存草稿成功", "保存草稿失败")
|
||||
.forEach { assertFalse(it, confirms(listOf(it))) }
|
||||
assertFalse(confirms(emptyList(), elapsed = 8000))
|
||||
}
|
||||
|
||||
@Test fun rejectsOtherEditorsDeclarationsAndStaleCallbacks() {
|
||||
assertFalse(confirms(listOf("保存草稿成功"), actualTitle = "另一个标题"))
|
||||
assertFalse(confirms(listOf("保存草稿成功"), actualTitle = null))
|
||||
assertFalse(confirms(listOf("保存草稿成功"), actualDeclaration = "内容为转载"))
|
||||
assertFalse(confirms(listOf("保存草稿成功"), elapsed = -1))
|
||||
assertFalse(confirms(listOf("保存草稿成功"), elapsed = 8001))
|
||||
}
|
||||
|
||||
@Test fun acceptsOcrSpacingWithoutAcceptingAQuotedLongSentence() {
|
||||
assertTrue(confirms(listOf("保存 草稿 成功")))
|
||||
assertTrue(confirms(listOf("✓ 保存草稿成功")))
|
||||
assertTrue(confirms(listOf("O 保存草稿成功")))
|
||||
assertTrue(confirms(listOf("0保存草稿成功")))
|
||||
assertFalse(confirms(listOf("出现保存草稿成功后返回")))
|
||||
assertFalse(confirms(listOf("保存草稿成功后返回")))
|
||||
}
|
||||
|
||||
@Test fun acceptsReceiptMergedWithNeighbouringPageTextWhenNotChinesePreceded() {
|
||||
// 2026-11-14 真机实测三种行合并形态:⊙ 图标被 OCR 误读为 0 / O / 。,均为非汉字承接。
|
||||
assertTrue(confirms(listOf("0保存草稿成功")))
|
||||
assertTrue(confirms(listOf("宁兴·城O保存草稿成功鄞州万达广场小")))
|
||||
assertTrue(confirms(listOf("城市广场。保存草稿成功达广场IMAX店")))
|
||||
// 短语由汉字承接(否定句或纯噪声),不能当回执。
|
||||
assertFalse(confirms(listOf("宁兴·城保存草稿成功鄞州万达广场小")))
|
||||
assertFalse(confirms(listOf("宁兴·城能保存草稿成功鄞州万达广场小")))
|
||||
assertFalse(confirms(listOf("未能保存草稿成功")))
|
||||
}
|
||||
|
||||
@Test fun emptyDeclarationSummaryOnlyConfirmsAnExplicitNoAnnotationChoice() {
|
||||
assertEquals("内容无需标注", DraftReceiptPolicy.declarationReadback("内容无需标注", true, false, null))
|
||||
assertNull(DraftReceiptPolicy.declarationReadback("内容无需标注", false, false, null))
|
||||
assertNull(DraftReceiptPolicy.declarationReadback("内容无需标注", true, true, null))
|
||||
assertNull(DraftReceiptPolicy.declarationReadback("内容为转载", true, false, null))
|
||||
assertEquals("内容为转载", DraftReceiptPolicy.declarationReadback("内容为转载", true, false, "内容为转载"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.haorui.app.ocr
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class CreditScoreParserTest {
|
||||
private fun line(text: String, left: Int, top: Int, right: Int, bottom: Int) =
|
||||
CreditScoreParser.Line(text, CreditScoreParser.Area(left, top, right, bottom))
|
||||
private fun page(score: String = "100分") = listOf(
|
||||
line("账号处罚中心", 350, 146, 726, 204),
|
||||
line("测试账户", 185, 343, 830, 390),
|
||||
line("信用分", 65, 470, 180, 510),
|
||||
line("账号状态", 540, 470, 700, 510),
|
||||
line(score, 125, 547, 260, 595),
|
||||
line("正常", 600, 547, 700, 595),
|
||||
line("处罚记录", 75, 850, 315, 900),
|
||||
)
|
||||
private fun read(lines: List<CreditScoreParser.Line>) = CreditScoreParser.extract(lines, 1080, 2408)
|
||||
|
||||
@Test fun readsTheActualPenaltyPageDespiteItsTitleAndHistoryLabels() {
|
||||
assertEquals(100, read(page()))
|
||||
assertEquals(80, read(page("80分") + line("已扣20分", 80, 1000, 340, 1060)))
|
||||
}
|
||||
|
||||
@Test fun preservesLowScoresAndExactGateBoundaries() {
|
||||
listOf(0, 1, 59, 60, 99, 100).forEach { assertEquals(it, read(page("${it}分"))) }
|
||||
}
|
||||
|
||||
@Test fun requiresTheObservedPageAndBothCardLabels() {
|
||||
listOf("账号处罚中心", "信用分", "账号状态").forEach { missing ->
|
||||
assertNull(missing, read(page().filterNot { it.text == missing }))
|
||||
}
|
||||
assertNull(read(page().map { if (it.text == "账号处罚中心") it.copy(text = "视频详情") else it }))
|
||||
assertNull(read(page() + line("信用分", 65, 540, 180, 580)))
|
||||
}
|
||||
|
||||
@Test fun ignoresClockVideoDurationAndNumbersOutsideTheCreditColumn() {
|
||||
val noisy = page() + listOf(
|
||||
line("09:42", 45, 45, 180, 100),
|
||||
line("00:20/01:00", 50, 650, 360, 700),
|
||||
line("80分", 600, 547, 740, 595),
|
||||
line("20分", 125, 1050, 260, 1100),
|
||||
)
|
||||
assertEquals(100, read(noisy))
|
||||
assertNull(read(noisy.filterNot { it.text == "100分" }))
|
||||
}
|
||||
|
||||
@Test fun neverTreatsDeductionsOrLongSentencesAsTheCurrentScore() {
|
||||
listOf("已扣20分", "扣分20", "-20分", "+20分", "信用分扣除20分", "视频播放100分钟", "09:42")
|
||||
.forEach { assertNull(it, read(page(it))) }
|
||||
}
|
||||
|
||||
@Test fun rejectsConflictingOrOutOfRangeValuesInTheCard() {
|
||||
assertNull(read(page() + line("80分", 125, 602, 260, 645)))
|
||||
listOf("101分", "999分").forEach { assertNull(read(page(it))) }
|
||||
assertNull(read(page() + line("101分", 125, 602, 260, 645)))
|
||||
}
|
||||
|
||||
@Test fun handlesOcrDigitVariantsAndAnInlineLabelWithoutReadingOtherColumns() {
|
||||
listOf("100 分", "1OO分", "1oo 分", "100").forEach { assertEquals(it, 100, read(page(it))) }
|
||||
val inline = page().filterNot { it.text == "信用分" || it.text == "100分" } +
|
||||
line("信用分:80分", 65, 470, 300, 510)
|
||||
assertEquals(80, read(inline))
|
||||
}
|
||||
|
||||
@Test fun scalesWithScreenSizeAndDoesNotDependOnOcrReadingOrder() {
|
||||
listOf(0.5, 1.0, 2.0).forEach { scale ->
|
||||
val scaled = page().reversed().map { line ->
|
||||
val b = line.bounds
|
||||
line.copy(bounds = CreditScoreParser.Area((b.left * scale).toInt(), (b.top * scale).toInt(),
|
||||
(b.right * scale).toInt(), (b.bottom * scale).toInt()))
|
||||
}
|
||||
assertEquals(100, CreditScoreParser.extract(scaled, (1080 * scale).toInt(), (2408 * scale).toInt()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun rejectsMissingOrInvalidScoreGeometry() {
|
||||
val missing = page().filterNot { it.text == "100分" }
|
||||
listOf(CreditScoreParser.Area(0, 0, 0, 0), CreditScoreParser.Area(-10, 547, 260, 595),
|
||||
CreditScoreParser.Area(125, 547, 1260, 595), CreditScoreParser.Area(125, 1000, 260, 1050))
|
||||
.forEach { assertNull(read(missing + CreditScoreParser.Line("100分", it))) }
|
||||
assertNull(CreditScoreParser.extract(page(), 0, 2408))
|
||||
}
|
||||
|
||||
@Test fun optionalRegionRestrictsTheScoreWhileKeepingFullPageValidation() {
|
||||
assertEquals(100, CreditScoreParser.extract(page(), 1080, 2408, CreditScoreParser.Area(70, 520, 450, 650)))
|
||||
assertNull(CreditScoreParser.extract(page(), 1080, 2408, CreditScoreParser.Area(550, 520, 950, 650)))
|
||||
assertNull(CreditScoreParser.extract(page(), 1080, 2408, CreditScoreParser.Area(-1, 520, 450, 650)))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.haorui.app.pipeline
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class PendingDraftStoreTest {
|
||||
@get:Rule val temporary = TemporaryFolder()
|
||||
private fun media() = temporary.newFile("测试素材.mp4").apply { writeText("owned test fixture") }
|
||||
|
||||
@Test fun committedIntentSurvivesReopeningWithoutReleasingMedia() {
|
||||
val file = media()
|
||||
val directory = File(temporary.root, "pending")
|
||||
val attempt = PendingDraftStore(directory).begin(file.path, "当前标题", "内容无需标注")
|
||||
val reopened = PendingDraftStore(directory)
|
||||
assertEquals(setOf(file.canonicalPath), reopened.protectedPaths())
|
||||
assertEquals(attempt, reopened.attempts().single())
|
||||
assertTrue(file.exists())
|
||||
}
|
||||
|
||||
@Test fun refusesASecondIntentForTheSameUnconfirmedFile() {
|
||||
val file = media()
|
||||
val store = PendingDraftStore(temporary.newFolder("pending"))
|
||||
store.begin(file.path, "标题一", "内容无需标注")
|
||||
assertThrows(IllegalStateException::class.java) { store.begin(file.path, "标题二", "内容无需标注") }
|
||||
assertEquals(1, store.attempts().size)
|
||||
}
|
||||
|
||||
@Test fun onlyTheExactConfirmedAttemptReleasesItsProtection() {
|
||||
val file = media()
|
||||
val store = PendingDraftStore(temporary.newFolder("pending"))
|
||||
val attempt = store.begin(file.path, "当前标题", "内容无需标注")
|
||||
assertFalse(store.confirm("unknown-attempt"))
|
||||
assertEquals(setOf(file.canonicalPath), store.protectedPaths())
|
||||
assertTrue(store.confirm(attempt.id))
|
||||
assertTrue(store.protectedPaths().isEmpty())
|
||||
assertTrue(file.exists())
|
||||
}
|
||||
|
||||
@Test fun refusesDispatchWhenTheJournalCannotBeWritten() {
|
||||
val file = media()
|
||||
val unusableDirectory = temporary.newFile("not-a-directory")
|
||||
assertThrows(IllegalStateException::class.java) {
|
||||
PendingDraftStore(unusableDirectory).begin(file.path, "当前标题", "内容无需标注")
|
||||
}
|
||||
assertTrue(file.exists())
|
||||
}
|
||||
|
||||
@Test fun corruptJournalFailsClosedInsteadOfReturningAnEmptyProtectionSet() {
|
||||
val directory = temporary.newFolder("pending")
|
||||
File(directory, "broken.json").writeText("partial journal")
|
||||
assertThrows(Exception::class.java) { PendingDraftStore(directory).protectedPaths() }
|
||||
}
|
||||
}
|
||||
+18
-4
@@ -7,11 +7,13 @@
|
||||
| 日期或范围 | 结果 |
|
||||
|---|---|
|
||||
| 2026-10-29、10-30 原视频链路 | 留存记录显示真机跑通过采集、解析、下载、草稿/发布与互斥;不等于新功能已验收 |
|
||||
| 2026-11-14 JVM | 88 项全通过,新增旧提交会话 10 项、账号策略 3 项、剪贴板请求 3 项、独占票据 1 项;原视频筛选 16 项仍通过 |
|
||||
| 2026-11-14 JVM | 107 项全通过;本轮在前轮 88 项基础上新增信用分 10 项、草稿回执 4 项、草稿意图持久化 5 项。原视频筛选 16 项仍通过 |
|
||||
| 2026-11-14 M1 真机 SQLite | 19 项通过,新增意图/点击许可提交后丢失返回值的真实库取消测试;使用隔离库,未知额度与媒体跨重启保留 |
|
||||
| 2026-11-13 M1 基础 UI | 五 tab、空任务、18 分类、作品形式独立保存、跨页不覆盖、旋转及进程重启保留配置通过 |
|
||||
| 2026-11-14 账号核验 UI | 真机两次自身名片解码、返回复查、首页导航、按钮触发及成功状态回读通过;中途停止显示取消并保持浩瑞前台,残留分享弹层后直接重试再次通过。记录 `.tmp/account-ui/` |
|
||||
| 截至 2026-11-14 作者往返与热度优选真机 | 用户已开启浩瑞无障碍;原视频真实采集、指标、作者往返与草稿整链路本轮仍未执行 |
|
||||
| 2026-11-14 信用分与启动停止 | 修复整页“处罚”关键词误拒绝后,实际读到 100 分;启动时两次一致,检查途中停止后未拉起调度器。保留旧 UNREADABLE 兼容语义,不计为 M6 完整账号健康通过 |
|
||||
| 2026-11-14 作者往返与热度优选 | 点赞 0 候选拒绝、作者主页粉丝读取与返回、合格链接、5 条优选及优胜者解析/模型改写/下载已有真机记录;粉丝/时间门槛单独收紧待补 |
|
||||
| 2026-11-14 旧草稿 | 旧代码在声明弹层未关闭时将 8 秒超时误报为成功,不计验收通过。手动选择实际选项后观察到明确“保存草稿成功”。新增声明与回执保护代码已构建,因 ADB 掉线尚未装机复测,草稿箱回读和待核对处置仍待补 |
|
||||
| 纯手机四来源、图文发布、跨平台视频 | 配置与本地框架已接入,实际采集及新发布器待实现,未执行真实来源或发布测试 |
|
||||
|
||||
## 一 设备准备
|
||||
@@ -44,6 +46,18 @@ $adbPath = 'D:\env\android-sdk\platform-tools\adb.exe'
|
||||
& $adbPath shell am broadcast -a com.haorui.app.ACTION_TEST_CREDIT
|
||||
```
|
||||
|
||||
自有素材草稿回归走广播(debug APK;activity intent 在 vivo 真机投递不可靠,勿用 am start 传 cmd):
|
||||
|
||||
```powershell
|
||||
# 只接受下载目录中的 haorui-draft-regression.mp4(scripts/create-draft-fixture.ps1 生成后 push);
|
||||
# 强制草稿与单车道,不启动采集、互动或正式发布;成功路径会删除本地夹具并自动核销待核对记录。
|
||||
& $adbPath shell am broadcast -a com.haorui.app.ACTION_TEST_DRAFT --es fixturePath /storage/emulated/0/Android/data/com.haorui.app/files/videos/videos/haorui-draft-regression.mp4
|
||||
# 不支持声明(如“内容为原创”)应在 PREPARE 暂停并保留素材,不写待核对
|
||||
& $adbPath shell am broadcast -a com.haorui.app.ACTION_TEST_DRAFT_INVALID --es fixturePath /storage/emulated/0/Android/data/com.haorui.app/files/videos/videos/haorui-draft-regression.mp4
|
||||
```
|
||||
|
||||
⚠️ 点击红线(2026-11-14 事故):PAUSED/中断会把头条发布编辑器留在前台,右下红色「发布」按钮恰在常用导航坐标 (972,2159)。任何 `input tap` 前必须先 `uiautomator dump`/screencap 核对当前界面,用节点 bounds 求中心;测试收尾先 `input keyevent KEYCODE_HOME` 离开编辑器再导航。误发布过的测试内容立即从作品管理删除。
|
||||
|
||||
仅在需要专项互动测试时发送 ACTION_TEST_INTERACT,它会执行实际互动,不属于只读探测。正式模式使用 ACTION_SET_PUBLISH,不能在普通回归步骤中默认执行。
|
||||
|
||||
vivo 重装后若节点根持续为空,先在系统设置关闭再开启浩瑞无障碍。不要用 force-stop 作为恢复办法;ADB 重置所有无障碍服务会影响其他应用,不作为默认操作。
|
||||
@@ -95,9 +109,9 @@ powershell -File scripts\regress-stats.ps1 .tmp\regression.txt
|
||||
|
||||
## 五 记录格式
|
||||
|
||||
本轮记录(2026-11-14):`561baee` 之上的未提交工作树;vivo V1981A / Android 12,头条 18.3.0。应用及测试 APK 已安装;运行隔离库与账号读取验收。用户已手动开启浩瑞无障碍,instrumentation 后仅重绑该已启用服务,原打卡助手服务保持原值。旧视频草稿、新模块关闭,没有启动真实采集、互动或发布,没有执行手动清空缓存/去重。跨日首启曾触发旧信用分检查并读取失败,该旧门控不计为新增健康检查通过。
|
||||
本轮记录(2026-11-14):基线 main `db850a7`,本轮改动未提交;vivo V1981A / Android 12,头条 18.3.0。信用分修复 APK 已安装并验证,新增草稿保护 APK 因 ADB 掉线待安装。前轮 19 项隔离 SQLite 和账号读取记录保留,本轮未改库模式。浩瑞及原打卡助手的启用状态保留,未授予新无障碍权限。旧视频保持草稿,新模块关闭;本轮执行真实候选采集、一次模型标题改写及下载,没有执行互动或公开发布,没有手动清空缓存/去重。
|
||||
|
||||
结果:JVM `88 / 0 失败 / 0 错误`,SQLite `19 / 0 失败`。全套构建日志 `.tmp/account-qr-build.log`,最终导航修复、APK 离线构建与 JVM 复查 `.tmp/account-navigation-build.log`,SQLite `.tmp/account-session-sqlite.log`。新增覆盖预占提交后取消、点击许可提交后取消、旧回调不归还后续前台、重复派发只点一次、同名不同账号与不合格 URL 拒绝。最终账号运行日志 `.tmp/budget-evidence/account-final-runtime.log` 记录 09:28:55 停止、09:29:18 重试核验通过;取消及成功回读截图在 `.tmp/account-ui/`,发布计数为 0。前轮基础 UI 在 `.tmp/continuation-ui/`。旧流程指标/作者往返与整机停止、不同账号及页面样本、混合正式发布/M6 强回执和所有新来源端到端仍未验收。
|
||||
结果:JVM `107 / 0 失败 / 0 错误`;前轮 SQLite `19 / 0 失败`。本轮构建日志 `.tmp/m0-regression/credit-fix-build.log`、`draft-fix-build.log`,最终复查 `.tmp/m0-regression/draft-final-build.log`;M0 实际运行日志、声明弹层误报证据和手动保存的明确提示均在 `.tmp/m0-regression/`。旧处理计数出现 1,不能将此解释为公开发布 1 条。新草稿路径需使用自有素材验证明确回执、停止和待核对保护;未知结果不得重新点击或删除 `files/pending-drafts/` 对应素材。旧草稿箱持久化核对、粉丝/时间阈值、恢复链、不同账号、M6 强回执及所有新来源端到端仍未验收。前轮账号与基础 UI 记录分别位于 `.tmp/account-ui/`、`.tmp/continuation-ui/`。
|
||||
|
||||
仅保留最近一轮有效结果:日期、提交版本/工作树、设备与 App 版本、运行模式、用例结果、日志位置、失败原因及未验收项。历史逐秒日志不追加到文档。
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# 浩瑞开发计划
|
||||
|
||||
更新:2026-11-14。基线:main 的 561baee;M1 与接续开发仍位于未提交工作树。本文维护实施顺序、交付物与验收门槛;详细规则见[纯手机设计](跨平台自动发布设计.md),实际完成情况见[开发进度](开发进度.md)。
|
||||
更新:2026-11-14。当前基线:main 的 db850a7,前轮 M1 已由用户提交;本轮信用分与草稿修复位于未提交工作树。本文维护实施顺序、交付物与验收门槛;详细规则见[纯手机设计](跨平台自动发布设计.md),实际完成情况见[开发进度](开发进度.md)。
|
||||
|
||||
## 目标与当前起点
|
||||
|
||||
@@ -70,6 +70,6 @@ M4 与 M5 在 M1~M3 通过后可分别推进,最终在 M6 联合验收。微
|
||||
|
||||
## 下一步执行
|
||||
|
||||
1. 补 M0 的旧采集、指标、作者往返与停止恢复草稿回归,记录无障碍启用状态和首批来源版本。
|
||||
1. 继续 M0 草稿修复版真机验收:信用分、指标拒绝、作者往返及优选后的解析/改写/下载已有本轮记录;旧草稿超时误报成功已修复但尚未装机复测。先验证声明回读、明确草稿回执和未知素材保护,再补粉丝/时间阈值与恢复链。当前 ADB 连接断开。
|
||||
2. 完成 M1 的不同账号/异常页面、旧流程草稿、在途服务重连与前台切换验收。本轮单账号名片读取、首页导航、中途停止和带残留弹层重试已通过。复用已有账号读取器、LegacyPublishSession 和共享事务,不重复搭计数器;提交前后实际账号、成品关联与强回执由 M6 完成,混合正式入口继续暂停。88 项 JVM、19 项隔离 SQLite 回归不能替代剩余整机验收。
|
||||
3. 通过上述门槛后推进 M2 知乎详情、真实时间、原链接及返回路径,再做小红书;来源保持独立能力门控。实际完成情况持续写入开发进度,不提前把设计或模拟状态写成已实现。
|
||||
|
||||
+17
-10
@@ -1,6 +1,6 @@
|
||||
# 项目状态与开发入口
|
||||
|
||||
更新:2026-11-14。本轮接入 M1 账号读取器、只读核验入口及旧发布器共享提交会话,88 项 JVM、19 项隔离 SQLite 测试通过。API 30+ 自身名片二维码读取、首页导航、中途停止及残留弹层后的重试已通过真机验证。M1 尚未整体验收,M0 旧流程待回归,M2 目前仅取证;混合正式发布继续等待 M6 的健康与作品回执核对。
|
||||
更新:2026-11-14。本轮继续 M0 回归,修复信用分因“处罚中心”标题而被整页否决的问题,真机已读到 100 分并完成启动二次确认及检查途中停止。草稿保护版已完成真机复测:OCR 回执判定经三种行合并形态实测收敛为“非汉字承接”规则,testDraft 全链路(有效声明→回读→单次保存→明确回执→草稿箱持久化)与 testDraftInvalid(不支持声明暂停)均通过,未知结果保护有三次真机证据。109 项 JVM 测试通过;19 项 SQLite 为前轮有效结果。复测期间发生一起误公开发布事故(导航盲点坐标误触「发布」),两条测试视频已删除、作品数恢复 24,过程见“本轮验证与交付物”。M0/M1 遗留兼容与异常场景仍待验收,混合正式发布继续等待 M6。
|
||||
|
||||
## 文档导航
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
| 能力 | 状态与证据 |
|
||||
|---|---|
|
||||
| 原头条视频采集、解析、标题改写、下载和发布 | 已实现;2026-10-29、10-30 有历史真机回归记录 |
|
||||
| 既有信用分、配额、休息与恢复 | 原有能力保留;本轮修改了前台入场、停止取消和导航失效检查,尚需整体真机回归 |
|
||||
| 点赞、作者粉丝、发布时间筛选和候选优选 | 代码及原有 16 项策略单测通过;尚未完成本轮真实采集/发布回归 |
|
||||
| 既有信用分、配额、休息与恢复 | 信用分改为核对处罚中心页面、信用分/账号状态标签及分数所在列,拒绝无关数值;真机 100 分、连续两次确认及启动检查途中停止通过。旧 OCR 失败兼容语义保留,完整恢复链仍待验收 |
|
||||
| 点赞、作者粉丝、发布时间筛选和候选优选 | 原 16 项策略单测保留;真机拒绝点赞 0 的候选,完成作者粉丝读取和返回,5 条考察后只将优胜者送入解析、改写及下载。粉丝/时间阈值单独收紧及异常样本仍待补 |
|
||||
| 百度采集 | 有配置和界面,服务未接独立百度采集器,不计为已跑通来源 |
|
||||
| 手机界面 | Compose 已接入首页/热点/任务/互动/我的及来源、筛选、自动化设置;基础五 tab、分类和配置持久化已有真机记录。本轮在无障碍连接页新增“核验头条账号”及真实状态回读;旧功能行为仍需单独回归 |
|
||||
| 分类与作品形式 | 已实现 18 分类多选,不限社会类;图文/视频分别开关。配置持久化、JSON 与扁平导入导出、边界归一化有单测;新功能默认关闭、DRY_RUN |
|
||||
@@ -27,23 +27,28 @@
|
||||
| 统一前台协调 | ForegroundCoordinator 已接入旧步骤、信用分及恢复链;加入停止代际、在途票据和手势取消收尾。纯策略测试通过,来源切换及停止的整机行为待验收 |
|
||||
| 持久化启停 | CrossRunLifecycle 已接入用户启停、模块开关、服务接管/解绑/销毁。停止立即撤回内存许可,事务串行保存;只有最新启动事务完成才公开数据库代际。8 项竞态/故障单测及隔离库接线测试通过;已观察到空闲服务重绑及核验状态失效,旧流程在途重连仍待验收 |
|
||||
| 共享账户额度 | 共享事务与旧快照已实现;本轮新增 LegacyPublishSession,并接入旧 PublishMachine 的准备、指纹、单次点击、取消与未知回执分支。事务已提交而返回值因取消丢失时,按预生成 ID 定位;库中已领取点击许可的预占不释放。M6 强回执未接通,混合正式入口继续关闭;草稿及无共享历史的旧独立模式保留 |
|
||||
| 旧视频草稿 | **新版真机复测通过(2026-11-14 17:31)**:有效声明→回读→单次保存→明确“保存草稿成功”回执→草稿箱持久化(`浩瑞草稿回归 1004aef5`);testDraftInvalid 在 PREPARE 即暂停“不受当前版本支持”;未知结果保护有 14:38/16:11/16:41 三次证据(暂停、素材保留、`files/pending-drafts/` 记录保留,核对后清除)。OCR 回执判定为“非汉字承接”规则(⊙ 图标实测被误读为 0/O/。 并与位置卡片文本同行合并)。待核对处置界面仍未实现(现为人工核对后清理记录);旧配置“内容为原创”仍待用户改选 |
|
||||
| 稳定账号读取 | 18.3.0 自身主页、名片及二维码读取代码已实现,唯一数字 user_id 哈希为账户键;两次独立取证并复核自身资料,昵称和分享追踪字段不作为身份。只读核验不绑定预算,不授予后续运行发布许可 |
|
||||
| 知乎、小红书、微博、抖音采集 | 注册与版本门控已实现,实际采集器尚未实现;知乎/小红书仅取证,所有来源执行能力仍禁用 |
|
||||
| 头条图文与跨平台视频 | 事实补全、自动文章生成、文章编辑器、媒体许可及新发布上下文尚未实现;AUTO 未开放,没有执行真实跨平台发布 |
|
||||
|
||||
## 本轮验证与交付物
|
||||
|
||||
- `:app:testDebugUnitTest`:88 项,0 失败、0 错误(原视频 16、配置 11、来源门控 4、任务策略 18、旧额度快照 7、前台票据 8、运行生命周期 8、账号策略 3、剪贴板请求 3、旧提交会话 10)。新增覆盖同名不同身份、迟到 UI 回调、独占入场、事务返回丢失、停止/取消与不重复点击。
|
||||
- `:app:assembleDebug` 与 `:app:assembleDebugAndroidTest`:构建成功;全套日志 `.tmp/account-qr-build.log`,最终导航修复和 88 项 JVM 离线复查见 `.tmp/account-navigation-build.log`。新增 ZXing core 3.5.3 从官方 Maven 下载到 D:/env,LICENSE/NOTICE 随 APK 分发;Kotlin 改为 Gradle JVM 内编译,避免独立守护进程回落 C 盘。
|
||||
- 应用 APK:`app/build/outputs/apk/debug/app-debug.apk`,2026-11-14 最终导航与二维码版本已覆盖安装,SHA-256 为 `6FDB63295473C130C08ACB950C6C5170C92830C73FC4AD9E93FEAEF5D0AF07FC`;测试 APK 已安装。
|
||||
- `:app:testDebugUnitTest`:107 项,0 失败、0 错误。前轮 88 项之外,本轮新增信用分卡片解析 10 项、草稿回执 4 项、持久化草稿意图 5 项,覆盖无关数字、低分、冲突值、过期/错标题回执、写入失败、重启保护与重复意图拒绝。
|
||||
- `:app:assembleDebug`:本轮构建成功,日志 `.tmp/m0-regression/credit-fix-build.log`、`draft-fix-build.log`;最终复查记录 `.tmp/m0-regression/draft-final-build.log`。前轮测试 APK 构建及 19 项 SQLite 记录仍有效,本轮未改 SQLite 模式或重跑该组。
|
||||
- 应用 APK:`app/build/outputs/apk/debug/app-debug.apk`,最终 SHA-256 为 `311D0E6BCC42A049739AE859A6E993F4547196CD5D3CE2B61F3CFEA1CDE08D61`(含 OCR“非汉字承接”规则与草稿回归广播入口;装机后已完成 17:31 真机复测)。此前 10:26/15:02 等中间构建哈希不再有效,以本行为准。
|
||||
- 真机 SQLite:输出 `SQLite tests: 19, failures: 0`,记录 `.tmp/account-session-sqlite.log`。本轮新增在真实库中模拟预占提交后及点击许可提交后的协程取消:前者按同一 ID 明确释放未点击预占,后者跨重启继续保留 UNKNOWN、额度和素材。使用独立缓存测试库。
|
||||
- 前轮基础 UI 验收仍有效,记录在 `.tmp/continuation-ui/`,没有重复执行整套验收。本轮账号链接/名片取证、运行诊断和新增入口结果保存于 `.tmp/budget-evidence/`。
|
||||
- 真机已完成两次独立名片解码及返回复查,调试入口与“无障碍连接→核验头条账号”按钮均返回成功,界面回读当前显示名。从头条首页进入自身资料页通过;修复启动后过早判断分享弹层已关闭的问题。最终核验途中于 09:28:55 停止,界面显示“账号核验已取消”,无迟到成功或跳页;从按钮重试后于 09:29:18 再次核验通过。日志 `.tmp/budget-evidence/account-final-runtime.log`,截图 `.tmp/account-ui/account-ui-stopped.png`、`account-ui-retried.png`;当天发布计数仍为 0。
|
||||
- `uiautomator dump` 与 instrumentation 可能触发服务重连,临时核验状态会失效;自动化运行中使用文件日志和 `screencap` 观察,避免调试工具自身中断会话。此行为不能当成身份缓存恢复或授权依据。
|
||||
- 本轮 M0 记录在 `.tmp/m0-regression/`:`credit-baseline.log`/`credit-baseline.png` 为原信用分误拒绝;`credit-fixed-runtime.log` 为 100 分读数,`credit-stop-runtime.log` 为导航途中停止,`legacy-flow-runtime.log` 为二次确认及旧采集链路。`draft-after.png/xml` 证明旧发布器误报后仍停在声明弹层;手动关闭六层弹层、选择“内容为转载”并保存后,`draft-saved-manual.png` 记录真实“保存草稿成功”提示。未点击正式发布。旧流程处理计数出现 1,该值对应本轮测试处理,不能解释为公开发布 1 条。
|
||||
|
||||
本轮手机:vivo V1981A / Android 12,头条 18.3.0。自身主页复制链接和名片二维码均已留存,观察到 `profile.zjurl.cn/rogue/ugc/profile` 的数字 `user_id`;原始身份及分享追踪值不写入文档和日志。知乎 11.15.0、小红书 9.54.0、抖音 39.8.0,微博未安装;其来源能力与前轮相同,尚未放行。
|
||||
|
||||
本轮用户已手动开启浩瑞无障碍;原 `com.example.clockin` 服务保留。隔离 instrumentation 结束后系统曾将浩瑞列为断开/崩溃服务,仅重新绑定已启用的浩瑞,并核对原启用列表完整恢复。未代用户登录、修改资料、发送分享、点赞、评论、关注或发布;旧视频保持草稿,新模块关闭。自身资料页及名片仅供只读取证。
|
||||
本轮用户已手动开启浩瑞无障碍;原 `com.example.clockin` 服务保留。隔离 instrumentation 结束后系统曾将浩瑞列为断开/崩溃服务,仅重新绑定已启用的浩瑞,并核对原启用列表完整恢复。未代用户登录、修改资料、发送分享、点赞、评论、关注或公开发布;旧视频保持草稿,新模块关闭。M0 回归执行了采集、一次模型标题改写及下载,并手动核实了一条测试草稿;当前配置“内容为原创”需改选当前版本支持的声明,代码不自动替换用户声明。
|
||||
|
||||
- **草稿保护版真机复测(17:2x–17:31,第 5 轮 APK)**:`ACTION_TEST_DRAFT` 广播触发,`浩瑞草稿回归 1004aef5` 全链路通过——标题回读一致、声明“内容无需标注”回读通过、单次点击存草稿、`草稿回执候选:城市广场。保存草稿成功达广场IMAX店` 被“非汉字承接”规则认出,`收到明确的保存草稿成功提示`→`草稿保存已确认`→待核对记录自动核销→本地素材按设计删除;草稿箱核对 `1004aef5` 在列(证据 `.tmp/m0-regression/draft-box-1004aef5-proof.png`,日志 `testdraft-run4.log`)。16:02 的 testDraftInvalid 在 PREPARE 暂停“作品声明「内容为原创」不受当前版本支持”,未写待核对、未动素材。装机复测最初两轮(14:38 见 `0保存草稿成功`、16:11 见 `宁兴·城O保存草稿成功鄞州万达广场小`)先后暴露“前缀容错不足”“整行匹配过严”两类 OCR 差异,`DraftReceiptPolicy` 由此收敛为现行规则,109 项 JVM 测试通过(含三种合并形态用例)。
|
||||
- **⚠️ 误公开发布事故(已处置)**:PAUSED 会把头条发布编辑器留在前台,红色「发布」按钮恰在 (972,2159);我在草稿箱导航时使用硬编码坐标未先核对屏幕,两次盲点分别把 `063f1df0`、`a12c4807` 误发为公开作品(16:25 有“发布成功,分享给朋友一起看”弹层与作品列表 `063f1df0·2展现0播放` 为证)。用户已手动删除两条,作品数 25→24、列表无浩瑞条目(17:2x 核对),当日公开发布基线恢复为 0。教训:**任何 adb 点击前必须 dump/截图核对当前界面并用节点 bounds 求坐标**;测试收尾先 HOME 离开编辑器再导航。另记:本机 vivo 每次 ADB 装机可能把浩瑞无障碍踢出启用列表(15:52 一次、force-stop 一次被踢,16:25/16:39/17:30 未被踢),恢复需手动开“浩瑞自动发布”;activity intent 投递在本机极不可靠(多次“delivered”仍丢包),**调试命令一律用广播入口**。
|
||||
|
||||
## 固定决策
|
||||
|
||||
@@ -58,9 +63,9 @@
|
||||
|
||||
## 下一对话继续入口
|
||||
|
||||
1. 工作目录仍为 `D:/headlineScript`,本地 `HEAD` 保持 main 的 `561baee`;M1 首批代码及本次接续修改均未提交。远端 `origin/main` 上轮(11-13)核对为同一提交,本轮未拉取远端。继续前先看 `git log -1`、`git status`,按需核对远端,保留未提交修改,勿 reset、clean 或重复创建已有模块。
|
||||
1. 工作目录仍为 `D:/headlineScript`。本轮开始时用户已将前轮 M1 工作提交为 main 的 `db850a7`,工作树干净;本轮信用分与草稿修复尚未提交,未拉取远端。继续前先看 `git log -1`、`git status`,保留未提交修改,勿 reset、clean 或重复创建已有模块。
|
||||
2. 基础 UI 已验收,最新 APK 已装机;记录见本文验证结果与回归清单。后续仅在界面有改动或出现新问题时重做相关场景,不用点击旧视频正式启动来替代 UI 检查。
|
||||
3. 补 M0 的旧采集与启停回归,特别是指标限制、作者主页往返、停止时信用分导航/手势收尾及恢复链。本轮跨日首启的旧信用分检查未从浩瑞首页读到分数,后续头条导航失败并按旧规则放行;需补稳定启动入口与导航回归,不把该结果计为新增健康检查通过。单测及数据库测试不能替代上述行为验收。
|
||||
3. **草稿保护版复测已完成(见“本轮验证与交付物”)**,有效声明→回读→单次保存→明确回执、不支持声明暂停、未知结果保护、草稿箱持久化四项均通过,不必重复。调试入口改用广播(activity intent 在本机不可靠):`adb shell am broadcast -a com.haorui.app.ACTION_TEST_DRAFT --es fixturePath <下载目录>/haorui-draft-regression.mp4`(无效声明用 `ACTION_TEST_DRAFT_INVALID`),仍强制草稿与单车道。成功路径会删除本地夹具,重测前用 `scripts/create-draft-fixture.ps1` 重建并 push 回下载目录。随后补粉丝/时间硬阈值和恢复链回归;M6 账号健康不能只依赖旧信用分兼容门控。**导航红线**:PAUSED 会留下头条编辑器(「发布」按钮在右下),任何 adb 点击前先 dump/截图核屏、用节点 bounds 求坐标,收尾先 HOME。
|
||||
4. 继续 M1 的整机兼容回归与不同账号/异常页面验收;本轮已通过单账号读取、首页导航、停止和残留弹层后重试,不必无改动重复这些场景。复用 `account/ToutiaoAccountReader`、`publish/LegacyPublishSession` 和现有事务,勿另建计数器或用昵称/缓存绑定替代现场身份。当前混合正式入口仍关闭;M6 需要接通健康检查、编辑器最终账号/成品关联和明确作品回执,再开放正式路径。旧共享分支不复用分享面板/草稿超时成功判据。
|
||||
5. 再推进 M2:优先知乎热榜、具体详情身份/真实发布时间、分享原链接与返回路径,再做小红书。知乎回答时间不能当问题时间;小红书混淆资源 ID 不能直接当稳定选择器。未核验字段保留未知,来源版本/能力未通过不得放行。
|
||||
6. 来源稳定后按[开发计划](开发计划.md)推进分类优选、事实补全、图文、视频及新发布协调;整体验收前不开放 AUTO。
|
||||
@@ -80,7 +85,7 @@
|
||||
| automation/HaoRuiAccessibilityService.kt、scheduler/RecoveryChain.kt、ocr/CreditGateRunner.kt、automation/GestureRunner.kt | 本轮改动的真实接线、停止取消与恢复边界,必须补整机回归 |
|
||||
| crossplatform/source/SourceRegistry.kt | 四来源包名及版本/能力门控;目前 verifiedVersions、capabilities 均为空,不能仅因已安装就设为可执行 |
|
||||
|
||||
测试位于 `app/src/test/java/com/haorui/app/crossplatform/`、`app/src/androidTest/java/com/haorui/app/crossplatform/`。最终构建与 JVM 日志 `.tmp/account-navigation-build.log`,JVM 结果为 `app/build/test-results/testDebugUnitTest/`,真机库结果为 `.tmp/account-session-sqlite.log`。测试库与正式任务库隔离,不把测试记录导入真实队列。
|
||||
测试位于 `app/src/test/java/com/haorui/app/` 和 `app/src/androidTest/java/com/haorui/app/crossplatform/`。本轮最终构建与 JVM 日志 `.tmp/m0-regression/draft-final-build.log`,JVM 结果为 `app/build/test-results/testDebugUnitTest/`,前轮真机库结果为 `.tmp/account-session-sqlite.log`。测试库与正式任务库隔离,不把测试记录导入真实队列。
|
||||
|
||||
构建命令(PowerShell;有新增代码时再运行,不必因换对话重复所有检查):
|
||||
|
||||
@@ -95,6 +100,8 @@ gradle --offline :app:testDebugUnitTest :app:assembleDebug :app:assembleDebugAnd
|
||||
|
||||
| 日期 | 事项 | 验证范围 |
|
||||
|---|---|---|
|
||||
| 2026-11-14 | 草稿保护版装机复测:OCR 回执“非汉字承接”规则、广播调试入口、误公开发布事故处置 | testDraft/testDraftInvalid 真机通过、草稿箱持久化、109 项 JVM 通过;误发布的两条测试视频已删除并复核,M0/M1 遗留场景仍待验收 |
|
||||
| 2026-11-14 | M0 信用分卡片解析、旧采集回归、声明回读和草稿明确回执、点击前日志与未知素材保护 | 107 项 JVM 通过;信用分及旧采集至下载已真机验证,新草稿修复版因 ADB 离线待安装,M0 未整体验收 |
|
||||
| 2026-11-14 | 接入账号读取、只读入口、旧发布器共享提交会话与取消故障恢复,手动缓存清理保护未知素材;新增本机名片二维码读取 | 88 项 JVM、19 项真机 SQLite 全通过,最终 APK 已安装;实际账号与新增 UI 验收结果见本文,混合正式发布继续等待 M6 |
|
||||
| 2026-11-13 | M1 共享额度事务、旧额度快照与幂等恢复、v1→v2 保留升级、未知文件保护及混合正式入口暂停保护 | 71 项 JVM、17 项真机 SQLite 全通过,最终应用及测试 APK 已安装;稳定账号核验与旧发布器日志调用仍待接通 |
|
||||
| 2026-11-13 | 接通服务启停、模块开关与任务库运行代际;旧任务暂停、队列与素材代际检查、服务接管及调度器启停同步 | 59 项 JVM 与 9 项真机 SQLite 测试通过;基础 UI、跨页保存、旋转及进程重启通过;已安装新版 APK,真实服务重连和旧链路仍待验收 |
|
||||
|
||||
@@ -76,12 +76,16 @@ AndroidManifest.xml 管理组件、权限及包可见性;res/xml/file_paths.xm
|
||||
|
||||
- 发布器使用 video/mp4 的 ACTION_SEND 和 FileProvider URI,不是通用图文发布器。
|
||||
- 标题写入后回读;声明与封面按当前配置处理。每次只受理一条任务,忙时保留已准备成品,不能重跑整个下载管线。
|
||||
- 声明必须属于当前 `AppConfig.DECLARATIONS`。不支持的旧配置暂停并提示重新选择,不自动替换声明;弹层仅打开一次,选择后要求弹层消失且 `id/jm2` 回读一致,未通过不发送提交动作。
|
||||
- 草稿点击前由 `PendingDraftStore` 写入 `files/pending-drafts/`,记录尝试、路径、标题及声明。先排除旧提示,再仅派发一次保存;`DraftReceiptPolicy` 要求本次 8 秒窗口内的明确“保存草稿成功”,截图前后核对当前编辑器标题及声明。按钮“存草稿”、分享面板和超时均不算回执。
|
||||
- 草稿结果未知或点击中断时保留文件并暂停;下载缓存及失败删除路径均检查持久化保护,损坏日志使清理停止。重启后存在待核对草稿时拒绝自动运行,处置界面与草稿箱自动核对尚未实现。明确确认后的草稿沿用旧处理额度与休息语义,日志区分“草稿保存已确认”和正式“发布成功”。
|
||||
- QuotaManager 的非分时段日限额为 min(publishTotal, completionLimit),分时段使用对应配置;两种模式均检查休息。
|
||||
- 配额快照包含时段计数、剩余休息与最近重置点;启动恢复完成后才武装每日重置,日期使用 todayKey 的同一语义。
|
||||
- FrontStageGuard 是纯读状态表;ForegroundCoordinator 负责原子入场与票据归还。新功能关闭时保留旧步骤的入场方式,启用后每次只允许一个前台操作,来源仅在完整安全边界入场。
|
||||
- 用户停止应清除启动意愿,恢复链不能复活主动停止的任务;协程取消异常必须重抛。
|
||||
- 节点等待、网络与 OCR 都要有超时和有限重试。跨线程状态使用合适的同步;节点副本按现有 API 生命周期管理。
|
||||
- OCR 截图先隐藏悬浮窗,结束后在 finally 恢复。剪贴板读取应保持前台与候选代际匹配。
|
||||
- 信用分不再解析整页任意数字:`CreditScoreParser` 核对上方“账号处罚中心”、信用分及账号状态两列,只解析信用分标签下方的完整 0~100 分数。处罚标题和历史扣分不否决整页;未知、冲突、位置不符返回空,日志不再输出账户页 OCR 全文。原旧门控 UNREADABLE 兼容行为保留,M6 另行验收。
|
||||
- 文件日志不可阻塞状态机;诊断优先看应用文件日志与心跳,不仅依赖 logcat。
|
||||
|
||||
## 本地任务运行生命周期
|
||||
|
||||
@@ -60,6 +60,10 @@ Lynx 页面可能持续更新,uiautomator dump 失败不能直接证明页面
|
||||
|
||||
草稿没有提示、页面消失或分享面板出现,不足以证明新任务已正式发布。视频简介、署名、多项声明和文章编辑器需要新增真机取证。
|
||||
|
||||
2026-11-14 旧视频回归补充:声明选项为 `com.ss.android.article.news:id/fci`,当前配置“内容为原创”不在实际选项中;选择后的摘要为 `id/jm2`。“内容无需标注”会清空摘要,必须确认该选项已点击且弹层已消失才接受空摘要。标题输入键盘可能遮挡下方选项,选择声明及提交前通过可见输入法窗口判断并收起键盘。重复打开会叠加六层声明弹层,背景仍暴露标题与存草稿按钮,不能用背景节点判断可提交。手动选择“内容为转载”并点击存草稿,观察到短暂的“保存草稿成功”提示,页面仍留在编辑器;该提示未出现在常规节点树中,新增代码使用截图 OCR 及当前标题/声明核对,最终自动化结果见回归清单。
|
||||
|
||||
信用分页面已观察到“账号处罚中心”、左侧“信用分 / 100分”和右侧“账号状态 / 正常”。整页含“处罚”不应直接否决当前信用分;新增解析按页面和卡片位置判断,10 项相关 JVM 测试及本机 100 分读取已通过。
|
||||
|
||||
## 新来源适配记录要求
|
||||
|
||||
### 2026-11-14 头条账户页与名片取证
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
param([string]$EncoderPath = 'D:\env\ffmpeg-tools\ffmpeg.exe')
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'env.ps1')
|
||||
if (-not (Test-Path -LiteralPath $EncoderPath -PathType Leaf)) {
|
||||
throw 'FFmpeg is required in D:\env for this development-only fixture.'
|
||||
}
|
||||
$fixtureDirectory = Join-Path (Split-Path -Parent $PSScriptRoot) '.tmp\m0-regression'
|
||||
New-Item -ItemType Directory -Path $fixtureDirectory -Force | Out-Null
|
||||
$fixturePath = Join-Path $fixtureDirectory 'haorui-draft-regression.mp4'
|
||||
& $EncoderPath -nostdin -y -hide_banner -loglevel error -f lavfi -i 'testsrc2=size=640x360:rate=25' `
|
||||
-f lavfi -i 'anullsrc=r=44100:cl=stereo' -t 22 -c:v libx264 -preset veryfast -crf 30 `
|
||||
-pix_fmt yuv420p -c:a aac -b:a 64k -shortest -movflags +faststart $fixturePath
|
||||
if ($LASTEXITCODE -ne 0) { throw "Draft fixture generation failed: $LASTEXITCODE" }
|
||||
Get-Item -LiteralPath $fixturePath | Select-Object FullName, Length
|
||||
Reference in New Issue
Block a user