Feat: TV remote control via D-pad focus navigation using AccessibilityService
This commit is contained in:
17
common/logger.cpp
Normal file
17
common/logger.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "logger.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
static void (*androidLog)(const char*) = nullptr;
|
||||
|
||||
void UseAndroidLog(void (*cb)(const char*)) {
|
||||
androidLog = cb;
|
||||
}
|
||||
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
void android_log(const char* fmt, ...) {
|
||||
char buf[256];
|
||||
va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap);
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "YAMA_NET", "%s", buf);
|
||||
if (androidLog) androidLog(buf);
|
||||
}
|
||||
#endif
|
||||
@@ -336,6 +336,15 @@ inline const char* getFileName(const char* path)
|
||||
#else
|
||||
#define Mprintf(format, ...) printf(format, ##__VA_ARGS__)
|
||||
#endif
|
||||
#elif defined(__ANDROID__)
|
||||
#include <android/log.h>
|
||||
#include <cstdarg>
|
||||
#ifdef Mprintf
|
||||
#undef Mprintf
|
||||
#endif
|
||||
void UseAndroidLog(void (*cb)(const char*));
|
||||
void android_log(const char* fmt, ...);
|
||||
#define Mprintf android_log
|
||||
#else
|
||||
// Linux: 覆盖 commands.h 中的 printf 回退定义,改用 Logger 写文件
|
||||
#ifdef Mprintf
|
||||
|
||||
@@ -47,4 +47,4 @@ struct RttEstimator {
|
||||
|
||||
// 进程级全局:所有翻译单元共享同一份估算器与心跳间隔
|
||||
inline RttEstimator g_rttEstimator;
|
||||
inline int g_heartbeatInterval = 5; // 默认心跳间隔(秒),可被服务端 CMD_MASTERSETTING 更新
|
||||
inline int g_heartbeatInterval = 30; // 默认心跳间隔(秒),可被服务端 CMD_MASTERSETTING 更新
|
||||
|
||||
Reference in New Issue
Block a user