跨端: fix(设备闸): app state 交叉验证(矛盾⇒拿不准)+ 正例换成**真机实采**样本
pi 邮件 `6f902e1e` 指出两件,都对: 1. **我那条正例是自相矛盾的**:我用脚本把 `state #FOREGROUND` 对调,却漏了同一块的 `app state #X` ⇒ 造出 `state FG` + `app state BG` 这种**真机上不会出现**的 dump。于是"闸能放行"这条正例 建在**非法输入**上 —— 它绿,但它没证明任何真机会发生的事。 现在:正例改用 12:08 **真机实采**的 `fixtures/aa-dump-l-ours-foreground.txt`(两个 mission 都在、 `state`/`app state` 一致、FG 是我们); 2. 顺手把"矛盾怎么办"钉成规则:同一块里 `state` 与 `app state` 打架 ⇒ **`unverified`**, **不许"挑一个信"**(那是把互相打脸的证据当成证据)。`app state` 缺失时不因此判未验 (否则老格式 dump 会一律未验 —— 那是"更安静的失效")。 判据 8 条全绿;登记同步为 8。
This commit is contained in:
@ -21,12 +21,16 @@ export const VERDICT_UNVERIFIED: string = 'unverified';
|
||||
export interface MissionInfo {
|
||||
bundle: string;
|
||||
state: string;
|
||||
/** 同一块里的 `app state #X` —— 真机 dump 两个都在。**两者矛盾 ⇒ 拿不准**(pi 邮件 `6f902e1e`) */
|
||||
appState: string;
|
||||
}
|
||||
|
||||
/** `bundle name [com.x]` —— 方括号形状是**真机实测**的(样本 fixtures/aa-dump-l-real.txt) */
|
||||
const RE_BUNDLE = new RegExp('^\\s*(?:bundle|app)\\s+name\\s+\\[([^\\]]+)\\]');
|
||||
/** 只认行首的 `state`;`app state #FOREGROUND` 是同一块里的另一行,不算错 */
|
||||
const RE_STATE = new RegExp('^\\s*state\\s+#(\\w+)');
|
||||
/** `app state #FOREGROUND` —— 与 `state` 交叉验证:**矛盾就是拿不准**,不是"挑一个信" */
|
||||
const RE_APPSTATE = new RegExp('^\\s*app\\s+state\\s+#(\\w+)');
|
||||
|
||||
/**
|
||||
* 解析所有 mission 块。取不到就返回**空数组**(空 dump / 截断 / 格式变了)—— 不猜、不兜底。
|
||||
@ -42,14 +46,16 @@ export function parseMissions(dump: string): MissionInfo[] {
|
||||
const lines: string[] = dump.split('\n');
|
||||
let bundle: string = '';
|
||||
let state: string = '';
|
||||
let appState: string = '';
|
||||
for (const raw of lines) {
|
||||
const line: string = raw.replace('\r', '');
|
||||
if (line.indexOf('Mission ID') >= 0) {
|
||||
if (bundle.length > 0) {
|
||||
out.push({ bundle: bundle, state: state });
|
||||
out.push({ bundle: bundle, state: state, appState: appState });
|
||||
}
|
||||
bundle = '';
|
||||
state = '';
|
||||
appState = '';
|
||||
continue;
|
||||
}
|
||||
const mb = RE_BUNDLE.exec(line);
|
||||
@ -60,10 +66,15 @@ export function parseMissions(dump: string): MissionInfo[] {
|
||||
const ms = RE_STATE.exec(line);
|
||||
if (ms !== null && state.length === 0) {
|
||||
state = ms[1];
|
||||
continue;
|
||||
}
|
||||
const ma = RE_APPSTATE.exec(line);
|
||||
if (ma !== null && appState.length === 0) {
|
||||
appState = ma[1];
|
||||
}
|
||||
}
|
||||
if (bundle.length > 0) {
|
||||
out.push({ bundle: bundle, state: state });
|
||||
out.push({ bundle: bundle, state: state, appState: appState });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -76,9 +87,15 @@ export function parseMissions(dump: string): MissionInfo[] {
|
||||
export function foregroundBundle(dump: string): string {
|
||||
const missions: MissionInfo[] = parseMissions(dump);
|
||||
for (const m of missions) {
|
||||
if (m.state === 'FOREGROUND') {
|
||||
return m.bundle;
|
||||
if (m.state !== 'FOREGROUND') {
|
||||
continue;
|
||||
}
|
||||
// 真机 dump 里 `state` 与 `app state` 是一致的;**两者矛盾 ⇒ 这份 dump 自相矛盾 ⇒ 拿不准**
|
||||
// (不许"挑一个信":那是把互相打脸的证据当成证据。pi 邮件 `6f902e1e` 抓到我的对调样本正是这种形状)
|
||||
if (m.appState.length > 0 && m.appState !== 'FOREGROUND') {
|
||||
return '';
|
||||
}
|
||||
return m.bundle;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user