v73b:给卡片刷新加一条可观测的日志(排障用,不改变行为)

真机排障时发现:修复前 pushAll 在注册表为空时是**静默 return**,
hilog 里一个字符都抓不到 ⇒ 出现"卡片不刷新"时只能一路读代码反推
(v73 的跨进程 preferences 根因就死在那行 return 上)。

现在留两条:
· 为空 → warn,明确说"注册表为空(没卡片 或 跨进程没读到)"
· 推完 → info,报"已推 N 张卡(M 种偏移)"

真机实测:勾一次任务后日志出现
  pushAll:已推 4 张卡(1 种偏移)
⇒ 应用进程确实读到了卡片进程写下的 4 个 formId。
This commit is contained in:
2026-10-21 20:13:28 +08:00
parent 48a0507455
commit 67ce443915
+10
View File
@@ -223,6 +223,14 @@ class FbCardFormsImpl {
async pushAll(ctx: common.Context): Promise<void> { async pushAll(ctx: common.Context): Promise<void> {
const list: string[] = await this.ids(ctx); const list: string[] = await this.ids(ctx);
if (list.length === 0) { if (list.length === 0) {
/* ⚠️ 这一条**必须留**(2026-10-21 真机排障时加的):
修复前这里静默 return,听起来无害,实际是"整条链路断掉也毫无痕迹"——
我用 hilog 查 `pushAll` 时一个字符都抓不到,只能一路读代码猜。
v73 的根因(跨进程 preferences 读到空表)就死在这一行上,
而现场唯一能看到的只是"卡片不刷新"。
⇒ 留一条 warn:下次再出现"卡片不动",看日志立刻能分清是
"没注册表"还是"注册了但更新失败",不用再从代码反推。 */
hilog.warn(DOMAIN, TAG, 'pushAll:注册表为空(桌面没有卡片,或跨进程没读到)');
return; return;
} }
const cache: Map<number, formBindingData.FormBindingData> = const cache: Map<number, formBindingData.FormBindingData> =
@@ -244,6 +252,8 @@ class FbCardFormsImpl {
stale.push(formId); stale.push(formId);
} }
} }
hilog.info(DOMAIN, TAG, 'pushAll:已推 %{public}d 张卡(%{public}d 种偏移)',
list.length, cache.size);
if (stale.length > 0) { if (stale.length > 0) {
const keep: string[] = list.filter((id: string): boolean => stale.indexOf(id) < 0); const keep: string[] = list.filter((id: string): boolean => stale.indexOf(id) < 0);
await this.saveIds(ctx, keep); await this.saveIds(ctx, keep);