fix(mmp): 停止反复强跳红包历史页,避免打断前台使用

领取台恢复改为仅拉起 TNG 前台;Hook 侧限次/冷却,已在历史页不再重复打开。
This commit is contained in:
mars
2026-08-06 16:45:53 +08:00
parent ae65351d8e
commit 3fe84a8dd3
3 changed files with 41 additions and 13 deletions

View File

@@ -85,8 +85,11 @@ public final class TngMoneyPacketHook {
private static volatile long sLastHistoryBounceAt;
private static volatile boolean sBounceHistoryPending;
private static volatile long sLastHookStatusAt;
private static final long HISTORY_BOUNCE_COOLDOWN_MS = 45_000L;
private static final long HISTORY_BOUNCE_COOLDOWN_MS = 120_000L;
private static final long HISTORY_BOUNCE_FINISH_DELAY_MS = 2_200L;
/** 无模板时最多主动打开历史页次数(进程内),避免一直把用户拽进历史页 */
private static volatile int sNoTemplateOpenCount;
private static final int MAX_NO_TEMPLATE_OPEN = 2;
private static final long HOOK_STATUS_COOLDOWN_MS = 20_000L;
/** 曾拿到过 session之后变空 / RPC 鉴权失败 → 视为断线,恢复后强制重拉 */
private static volatile boolean sHadSession;
@@ -412,6 +415,7 @@ public final class TngMoneyPacketHook {
sTemplateHistoryRequest = cloneRequestShallow(historyReq);
sLoginDonorRequest = historyReq;
cacheLoginFromRequestObject(historyReq);
sNoTemplateOpenCount = 0;
XposedBridge.log(TAG + " cached history request template"
+ " session=" + abbreviate(stringField(historyReq,
"sessionId", "getSessionId")));
@@ -1630,13 +1634,20 @@ public final class TngMoneyPacketHook {
maybeBounceHistoryPage("template-rpc-fail");
return false;
}
// 2) 无模板时:自造请求易「非法参数」,直接拉起官方历史页让 App 发正确 RPC
// 2) 无模板时:自造请求易「非法参数」,短进官方历史页让 App 发正确 RPC(限次 + 冷却)
if (!sOpenHistoryIfNoTemplate && !sAutoBounceHistoryOnDisconnect) {
XposedBridge.log(TAG + " auto-history no template, openHistory disabled ("
+ reason + ")");
return false;
}
XposedBridge.log(TAG + " auto-history no template → open HistoryActivity (" + reason + ")");
if (sNoTemplateOpenCount >= MAX_NO_TEMPLATE_OPEN) {
XposedBridge.log(TAG + " auto-history no template, open capped ("
+ reason + " count=" + sNoTemplateOpenCount + ")");
return false;
}
sNoTemplateOpenCount++;
XposedBridge.log(TAG + " auto-history no template → open HistoryActivity ("
+ reason + " #" + sNoTemplateOpenCount + ")");
openMoneyPacketHistoryActivity(true);
return false;
} catch (Throwable t) {
@@ -1671,6 +1682,25 @@ public final class TngMoneyPacketHook {
+ (now - sLastHistoryBounceAt));
return;
}
}
// 已在历史页则不再 startActivity避免反复跳转
try {
Context ctx0 = getContext();
if (ctx0 instanceof android.app.Activity) {
String cur = ((android.app.Activity) ctx0).getClass().getName();
if (cur.contains("MoneyPacketHistoryActivity")) {
XposedBridge.log(TAG + " already on HistoryActivity, skip open");
if (bounceBack) {
sLastHistoryBounceAt = now;
sBounceHistoryPending = true;
scheduleHistoryBounceFinish(ctx0);
}
return;
}
}
} catch (Throwable ignored) {
}
if (bounceBack) {
sLastHistoryBounceAt = now;
sBounceHistoryPending = true;
}