添加 Hook 消息接收与本地调试模式,便于 LSPosed/Telegram 联调。

新增 HookMessageReceiver 与通知服务 Hook 上报链路,支持未登录本地监听;补充 build/install 脚本并忽略 platform-tools 与 xposed 构建产物。
This commit is contained in:
2026-07-02 12:36:08 +08:00
parent f0eebb834e
commit 7c80b7073a
14 changed files with 246 additions and 57 deletions

View File

@@ -86,15 +86,46 @@ public class NotificationService extends NotificationListenerService {
retryManager.restoreFromPersistence();
}
private static final String ACTION_HOOK_MESSAGE = "ACTION_HOOK_MESSAGE";
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && "ACTION_START_MONITORING".equals(intent.getAction())) {
startMonitoring();
if (intent != null) {
if ("ACTION_START_MONITORING".equals(intent.getAction())) {
startMonitoring();
} else if (ACTION_HOOK_MESSAGE.equals(intent.getAction())) {
handleHookMessageIntent(intent);
}
}
NotificationActivity.sendMessage("监听服务成功!");
return START_STICKY;
}
public static void submitFromHook(Context context, MessageInfo messageInfo,
String title, String content, long timestamp) {
Intent intent = new Intent(context, NotificationService.class);
intent.setAction(ACTION_HOOK_MESSAGE);
intent.putExtra("hook_package", messageInfo.getPackageName());
intent.putExtra("hook_title", title);
intent.putExtra("hook_content", content);
intent.putExtra("hook_timestamp", timestamp);
context.startService(intent);
}
private void handleHookMessageIntent(Intent intent) {
String packageName = intent.getStringExtra("hook_package");
MessageInfo messageInfo = App.getMessageByNotiList(this, packageName);
if (messageInfo == null) {
return;
}
NotificationExtractor.Result result = new NotificationExtractor.Result(
intent.getStringExtra("hook_title"),
intent.getStringExtra("hook_content"),
intent.getLongExtra("hook_timestamp", System.currentTimeMillis())
);
submitNotification(messageInfo, result);
}
public static boolean isMonitoring() {
return isMonitoring;
}
@@ -167,17 +198,17 @@ public class NotificationService extends NotificationListenerService {
}
private void submitNotification(MessageInfo messageInfo, NotificationExtractor.Result result) {
// 检查是否已登录
if (!tokenManager.isLoggedIn()) {
NotificationActivity.sendMessage("未登录,请先登录");
return;
}
// 调试用:暂时跳过登录检查
// if (!tokenManager.isLoggedIn()) {
// NotificationActivity.sendMessage("未登录,请先登录");
// return;
// }
// 检查是否关联了银行账户
if (TextUtils.isEmpty(messageInfo.getBankInfoId())) {
NotificationActivity.sendMessage("该应用未关联银行账户,请先配置");
return;
}
// 调试用:本地模式可不绑定服务器银行账户
// if (TextUtils.isEmpty(messageInfo.getBankInfoId())) {
// NotificationActivity.sendMessage("该应用未关联银行账户,请先配置");
// return;
// }
try {
JSONObject jsonObject = new JSONObject();