Skip to content

feat: 愚人节彩蛋 + 设置页修复 + GCK 安全加固 + CI/CodeRabbit#8

Merged
qiin2333 merged 9 commits intomasterfrom
feat/coderabbit-and-fixes
Apr 2, 2026
Merged

feat: 愚人节彩蛋 + 设置页修复 + GCK 安全加固 + CI/CodeRabbit#8
qiin2333 merged 9 commits intomasterfrom
feat/coderabbit-and-fixes

Conversation

@qiin2333
Copy link
Copy Markdown
Contributor

@qiin2333 qiin2333 commented Apr 2, 2026

变更内容

��� 愚人节彩蛋 - 负延迟串流™

  • 4月1日性能面板所有延迟值显示为负数
  • 解码延迟图标变为 ❄️,颜色变为青色 #64FFDA
  • 首次显示弹出 toast:��� 负延迟串流™ 已激活 — 画面将在你操作之前到达

��� 设置页修复

  • 版本号点击 → 复制到剪贴板
  • 背景图片切换 → 提示「重启应用后生效」

��� GCK 安全加固

  • RegisterAllInputMonitors / UnregisterAllInputMonitors 增加 SAFE_CALL 空值保护
  • TryLoadGameControllerLib 增加 11 个关键符号加载验证,缺失时记录警告
  • GameController_StopMonitor 竞态修复:分离加锁/无锁版本,NapiStopMonitor 现在正确持有 g_mutex

��� CI & 工具链

  • 接入 CodeRabbit AI 代码审查 (.coderabbit.yaml)
  • CI workflow 改为仅构建原生 C++ 代码 (assembleHar nativelib)
  • 新增 ScanKit / ShareKit SDK stubs(kit config + ohos 模块文件)
  • 清理 workflow 末尾孤立 YAML 映射键

Summary by CodeRabbit

发布说明

  • 新功能

    • 新增版本号一键复制功能
    • 新增二维码/条形码扫描功能
    • 新增系统分享功能
    • 添加性能监控特殊显示效果
  • 改进

    • 优化背景图片设置提示信息,说明重启应用后生效
    • 改进游戏手柄控制器的稳定性和错误处理
  • 其他

    • 更新开发工具链配置

qiin2333 added 3 commits April 2, 2026 14:31
- 4月1日当天性能面板所有延迟值显示为负数
- 解码延迟图标变为 ❄️,颜色变为青色
- 首次显示弹出 toast: 负延迟串流™ 已激活
- 非愚人节完全无影响
- 版本号点击复制到剪贴板并 toast 反馈
- 背景图片类型切换后提示重启应用生效
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

添加 CodeRabbit 配置;前端性能面板加入愚人节负延迟彩蛋并调整显示逻辑;设置页改为复制版本号并修改提示;原生手柄模块增强 dlsym 检查并用安全宏封装注册/注销与锁逻辑;新增 ScanKit/ShareKit 类型存根与清单;CI 脚本补入 SDK stub 与占位 DevKeySecret;GitHub 构建改为 HAR 并移除自动发布。

Changes

Cohort / File(s) Summary
CodeRabbit 配置
\.coderabbit\.yaml
新增 CodeRabbit AI 审查配置,指定中文、审查/聊天行为、路径过滤与特定路径指令,启用 auto_review 与 chat.auto_reply。
前端性能覆盖组件
entry/src/main/ets/components/PerformanceOverlay.ets, entry/src/main/ets/components/PerformanceOverlayManager.ets
新增 isAprilFools() 导出;引入愚人节逻辑在 1s 更新中将正延迟转换为随机负值并显示一次性 Toast;负值改变图标颜色/文案及 decode 的 ❄️ 标识;getLatencyColor 优先处理负值。
设置页面修改
entry/src/main/ets/pages/SettingsPageV2.ets
“版本”操作改为复制 this.appVersion 到系统剪贴板并显示 Toast;背景图片提示改为“重启应用后生效”。
原生手柄模块改动
nativelib/src/main/cpp/game_controller_native.cpp
TryLoadGameControllerLib() 对部分 dlsym 符号计数并发出警告;使用 SAFE_CALL/SAFE_CALL0 宏按指针存在性安全调用注册/注销函数;引入无锁内部停止实现并由带锁外部包装调用。
CI 脚本更改
ci/patch-sdk.sh
在 CI 中条件性拷贝/创建 @kit.ScanKit@kit.ShareKit 的 .json 与 .d.ts 到 $KIT_CONFIGS/$ETS_API,并在缺失时创建 DevKeySecret.ets 占位文件。
GitHub 构建工作流
.github/workflows/build.yml
将 hvigor 目标从 assembleHap/assembleApp 改为 assembleHar,添加 -p module=nativelib@default;移除 HAP/APP 大小输出、构建产物上传及 Release 作业。
SDK 类型存根:ScanKit
ci/sdk-stubs/kit.ScanKit.d.ts, ci/sdk-stubs/ohos.scan.scanCore.d.ts, ci/sdk-stubs/ohos.scan.scanBarcode.d.ts, ci/sdk-stubs/kit.ScanKit.json
新增 @kit.ScanKit 声明与清单,包含 scanCore.ScanType 枚举、scanBarcode.ScanOptions/ScanResult 接口,以及 startScanForResult(context, options?) : Promise<ScanResult>
SDK 类型存根:ShareKit
ci/sdk-stubs/kit.ShareKit.d.ts, ci/sdk-stubs/ohos.share.systemShare.d.ts, ci/sdk-stubs/kit.ShareKit.json
新增 @kit.ShareKit 声明与清单,包含 systemShare 命名空间、SelectionMode/SharePreviewMode 枚举、SharedDataRecordSharedDataShareController 类与方法签名。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地总结了 PR 的主要改动:愚人节彩蛋、设置页修复、GCK 安全加固和 CI/CodeRabbit 工具链更新,与变更内容完全对应。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/coderabbit-and-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@entry/src/main/ets/components/PerformanceOverlay.ets`:
- Around line 196-214: The code currently mutates real metric fields
(this.perfLatency, this.perfNetworkLatency, this.perfHostLatency) inside
isAprilFools() which breaks downstream logic that checks raw values (e.g., !== 0
or < 0); instead preserve the original stats.* values and introduce a separate
aprilFoolsMode/display variables used only for rendering. Concretely: stop
writing back into this.perfLatency/this.perfNetworkLatency/this.perfHostLatency
inside isAprilFools(); add a boolean flag (e.g., this.aprilFoolsMode) set when
isAprilFools() is true and this.aprilFoolsToastShown logic remains the same;
compute negative display values only in the render layer or add dedicated
display fields (e.g., perfLatencyDisplay, perfNetworkLatencyDisplay,
perfHostLatencyDisplay) derived from stats.* and this.aprilFoolsMode so business
logic continues to see original numeric values while the UI shows the
negative-easter-egg values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ed2fd94-42aa-40f3-8357-456d52b39ac5

📥 Commits

Reviewing files that changed from the base of the PR and between 4378b88 and e4fde27.

📒 Files selected for processing (4)
  • .coderabbit.yaml
  • entry/src/main/ets/components/PerformanceOverlay.ets
  • entry/src/main/ets/components/PerformanceOverlayManager.ets
  • entry/src/main/ets/pages/SettingsPageV2.ets

Comment on lines +196 to +214
// 🎃 愚人节彩蛋:负延迟串流™
if (isAprilFools()) {
if (stats.latency > 0) {
this.perfLatency = -(stats.latency * (0.3 + Math.random() * 0.4));
}
if (stats.networkLatency > 0) {
this.perfNetworkLatency = -Math.ceil(stats.networkLatency * (0.2 + Math.random() * 0.3));
}
if (stats.hostLatency > 0) {
this.perfHostLatency = -(stats.hostLatency * (0.3 + Math.random() * 0.3));
}
if (!this.aprilFoolsToastShown) {
this.aprilFoolsToastShown = true;
promptAction.showToast({
message: '🔮 负延迟串流™ 已激活\n画面将在你操作之前到达',
duration: 5000
});
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

别把彩蛋状态塞进真实延迟值里。

Line 198、Line 201 和 Line 204 只有在值 > 0 时才改写;配合 Line 585、Line 621、Line 719 和 Line 745 的 !== 0 判断,4 月 1 日只要原始延迟还是 0,面板就会继续显示 N/A/0ms,达不到“所有延迟值都显示为负数”的效果。并且后续渲染统一用 < 0 当彩蛋开关,语义被绑在了业务值上。建议保留真实统计值,单独引入 aprilFoolsMode 或 display 字段,在渲染层生成负值展示。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@entry/src/main/ets/components/PerformanceOverlay.ets` around lines 196 - 214,
The code currently mutates real metric fields (this.perfLatency,
this.perfNetworkLatency, this.perfHostLatency) inside isAprilFools() which
breaks downstream logic that checks raw values (e.g., !== 0 or < 0); instead
preserve the original stats.* values and introduce a separate
aprilFoolsMode/display variables used only for rendering. Concretely: stop
writing back into this.perfLatency/this.perfNetworkLatency/this.perfHostLatency
inside isAprilFools(); add a boolean flag (e.g., this.aprilFoolsMode) set when
isAprilFools() is true and this.aprilFoolsToastShown logic remains the same;
compute negative display values only in the render layer or add dedicated
display fields (e.g., perfLatencyDisplay, perfNetworkLatencyDisplay,
perfHostLatencyDisplay) derived from stats.* and this.aprilFoolsMode so business
logic continues to see original numeric values while the UI shows the
negative-easter-egg values.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nativelib/src/main/cpp/game_controller_native.cpp (1)

778-835: ⚠️ Potential issue | 🟠 Major

RegisterAllInputMonitors 直接调用的 50+ 函数指针缺少验证导致风险。

初始化时通过 dlsym 加载了大量 OH_GamePad_* 函数指针(按键和轴监听注册/注销),但仅验证了 pfn_OH_GameDevice_RegisterDeviceMonitor 一个符号。其余 49+ 函数指针未做空指针检查,若设备上的 libohgame_controller.z.so 缺少其中任一符号,直接调用将触发崩溃。

建议在 RegisterAllInputMonitorsUnregisterAllInputMonitors 中补充成组的空指针检查,或在初始化阶段验证所有必需符号是否加载成功。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nativelib/src/main/cpp/game_controller_native.cpp` around lines 778 - 835,
RegisterAllInputMonitors and UnregisterAllInputMonitors call many OH_GamePad_*
function pointers without null checks (only
pfn_OH_GameDevice_RegisterDeviceMonitor was validated); update these functions
to guard each call (e.g., check the corresponding function pointer is non-null
before invoking OH_GamePad_ButtonA_RegisterButtonInputMonitor /
OH_GamePad_ButtonA_UnregisterButtonInputMonitor and all other
OH_GamePad_*_Register*/Unregister* symbols), skip the call and log a clear error
if a symbol is missing, and/or add a single initialization-time verifier that
asserts all required OH_GamePad_* function pointers were loaded (in addition to
pfn_OH_GameDevice_RegisterDeviceMonitor) so missing symbols are detected early.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@nativelib/src/main/cpp/game_controller_native.cpp`:
- Around line 778-835: RegisterAllInputMonitors and UnregisterAllInputMonitors
call many OH_GamePad_* function pointers without null checks (only
pfn_OH_GameDevice_RegisterDeviceMonitor was validated); update these functions
to guard each call (e.g., check the corresponding function pointer is non-null
before invoking OH_GamePad_ButtonA_RegisterButtonInputMonitor /
OH_GamePad_ButtonA_UnregisterButtonInputMonitor and all other
OH_GamePad_*_Register*/Unregister* symbols), skip the call and log a clear error
if a symbol is missing, and/or add a single initialization-time verifier that
asserts all required OH_GamePad_* function pointers were loaded (in addition to
pfn_OH_GameDevice_RegisterDeviceMonitor) so missing symbols are detected early.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 419e73e0-f02d-429b-aa7b-3dfcef3ee122

📥 Commits

Reviewing files that changed from the base of the PR and between e4fde27 and eaaec81.

📒 Files selected for processing (1)
  • nativelib/src/main/cpp/game_controller_native.cpp

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/patch-sdk.sh`:
- Around line 132-136: The DEV_KEY_SECRET path is constructed relative to the
current working directory which breaks when the script is invoked from
elsewhere; update the script to compute repository root from the script location
(e.g., use a SCRIPT_DIR or REPO_ROOT derived from $(dirname "$0")/..), then set
DEV_KEY_SECRET to that absolute path (use the unique variable name
DEV_KEY_SECRET). Before copying, explicitly check that the template file
"${DEV_KEY_SECRET}.example" exists and fail with a clear error message if it
does not (instead of letting set -e cause an opaque crash); still create parent
directories with mkdir -p "$(dirname "$DEV_KEY_SECRET")" and only then cp the
example into DEV_KEY_SECRET.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4aea9f03-552f-41c5-ac5c-9bbe42f9e6a9

📥 Commits

Reviewing files that changed from the base of the PR and between eaaec81 and 56ae040.

📒 Files selected for processing (7)
  • ci/patch-sdk.sh
  • ci/sdk-stubs/kit.ScanKit.d.ts
  • ci/sdk-stubs/kit.ScanKit.json
  • ci/sdk-stubs/kit.ShareKit.d.ts
  • ci/sdk-stubs/kit.ShareKit.json
  • entry/src/main/ets/components/CustomKeyOverlay.ets
  • entry/src/main/ets/service/QrShareService.ets
✅ Files skipped from review due to trivial changes (4)
  • ci/sdk-stubs/kit.ScanKit.json
  • ci/sdk-stubs/kit.ShareKit.json
  • ci/sdk-stubs/kit.ScanKit.d.ts
  • ci/sdk-stubs/kit.ShareKit.d.ts

Comment on lines +132 to +136
DEV_KEY_SECRET="entry/src/main/ets/config/DevKeySecret.ets"
if [ ! -f "$DEV_KEY_SECRET" ]; then
mkdir -p "$(dirname "$DEV_KEY_SECRET")"
cp "${DEV_KEY_SECRET}.example" "$DEV_KEY_SECRET"
echo " Created DevKeySecret from example"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

DevKeySecret 使用相对路径会导致 CI 调用目录变化时失败

Line 132 依赖当前工作目录是仓库根目录;如果从其他目录调用脚本,这里会找不到目标路径。并且 Line 135 在 .example 缺失时会直接中断整个脚本(set -e)。建议改成基于脚本位置解析仓库根目录,并显式校验模板文件存在。

🔧 建议修复
 # ─── DevKeySecret (CI-only placeholder) ───
-DEV_KEY_SECRET="entry/src/main/ets/config/DevKeySecret.ets"
-if [ ! -f "$DEV_KEY_SECRET" ]; then
-  mkdir -p "$(dirname "$DEV_KEY_SECRET")"
-  cp "${DEV_KEY_SECRET}.example" "$DEV_KEY_SECRET"
+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+DEV_KEY_SECRET="$REPO_ROOT/entry/src/main/ets/config/DevKeySecret.ets"
+DEV_KEY_SECRET_EXAMPLE="${DEV_KEY_SECRET}.example"
+if [ ! -f "$DEV_KEY_SECRET" ]; then
+  if [ ! -f "$DEV_KEY_SECRET_EXAMPLE" ]; then
+    echo "❌ Missing template: $DEV_KEY_SECRET_EXAMPLE" >&2
+    exit 1
+  fi
+  mkdir -p "$(dirname "$DEV_KEY_SECRET")"
+  cp "$DEV_KEY_SECRET_EXAMPLE" "$DEV_KEY_SECRET"
   echo "  Created DevKeySecret from example"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/patch-sdk.sh` around lines 132 - 136, The DEV_KEY_SECRET path is
constructed relative to the current working directory which breaks when the
script is invoked from elsewhere; update the script to compute repository root
from the script location (e.g., use a SCRIPT_DIR or REPO_ROOT derived from
$(dirname "$0")/..), then set DEV_KEY_SECRET to that absolute path (use the
unique variable name DEV_KEY_SECRET). Before copying, explicitly check that the
template file "${DEV_KEY_SECRET}.example" exists and fail with a clear error
message if it does not (instead of letting set -e cause an opaque crash); still
create parent directories with mkdir -p "$(dirname "$DEV_KEY_SECRET")" and only
then cp the example into DEV_KEY_SECRET.

- GCK helper 函数移入 #if GAME_CONTROLLER_KIT_AVAILABLE 条件编译块
- ScanKit/ShareKit SDK stubs (kit_configs + ohos 模块 + declare module)
- DevKeySecret 自动生成
- catch(e) 类型修复: JSON.stringify(e) → String(e)
- VirtualKeyboard 回调移除 void 返回类型注解
- VirtualKeyboard 包裹 Column 容器(恢复旧写法)
@qiin2333 qiin2333 force-pushed the feat/coderabbit-and-fixes branch from 5f2715c to ca07c9f Compare April 2, 2026 08:22
qiin2333 added 3 commits April 2, 2026 16:27
- 回退 game_controller_native.cpp 条件编译改动
- 回退 QrShareService/CustomKeyOverlay catch 类型改动
- 回退 StreamPage VirtualKeyboard Column包裹改动
- CI workflow 改为 assembleHar 仅构建 nativelib 模块
- 移除 HAP/APP 签名构建和 Release 产物上传
- RegisterAllInputMonitors/UnregisterAllInputMonitors 使用 SAFE_CALL 宏
- TryLoadGameControllerLib 增加关键符号加载验证
- 缺失符号时记录警告日志而非崩溃
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
nativelib/src/main/cpp/game_controller_native.cpp (1)

1327-1351: 持锁期间调用回调存在潜在死锁风险。

GameController_HeartbeatCheck 在持有 g_mutex 时调用 g_deviceCallbacknapi_call_threadsafe_function。如果回调函数尝试重新进入本模块(如调用 getDeviceCount),将在同一线程上重复获取 g_mutex 导致死锁(std::mutex 不可重入)。

建议将断开设备的数据先收集到临时容器,释放锁后再发送回调:

♻️ 建议重构
     // 检查缓存的设备是否仍然连接
     std::vector<std::string> disconnectedIds;
     for (auto& pair : g_deviceInfos) {
         if (currentDevices.find(pair.first) == currentDevices.end()) {
             disconnectedIds.push_back(pair.first);
         }
     }
     
-    // 发送断开通知(在锁外执行以避免死锁)
-    // 注意: 这里我们释放锁后才发送回调
     std::vector<std::pair<std::string, GameControllerInfo>> disconnectedDevices;
     for (const auto& deviceId : disconnectedIds) {
         auto it = g_deviceInfos.find(deviceId);
         if (it != g_deviceInfos.end()) {
             disconnectedDevices.push_back(*it);
             g_deviceInfos.erase(it);
         }
         g_deviceStates.erase(deviceId);
         disconnectedCount++;
     }
+    
+    // 解锁后再发送回调
+    } // end of lock_guard scope
     
-    // 释放锁后发送回调
-    // 注: 由于回调可能很快,这里简化处理,直接在锁内调用
-    // 如果有问题可以改为在锁外调用
     for (const auto& pair : disconnectedDevices) {
         // ... callback invocations ...
     }

As per coding guidelines, nativelib/src/main/cpp/** 应关注线程安全。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nativelib/src/main/cpp/game_controller_native.cpp` around lines 1327 - 1351,
In GameController_HeartbeatCheck, avoid calling g_deviceCallback and
napi_call_threadsafe_function while holding g_mutex to prevent deadlocks;
instead, copy the disconnectedDevices entries (or the minimal data: deviceId
string and GameControllerInfo) into a temporary vector/local container while
holding g_mutex, then release the mutex and iterate that temporary container to
invoke g_deviceCallback (setting info.isConnected=false) and
napi_call_threadsafe_function using g_tsfnDevice; ensure you preserve deviceId
and info when copying and free any heap allocations used for napi events after
the call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build.yml:
- Around line 336-339: The YAML at the end of the workflow contains orphaned
mapping keys — remove the standalone keys fail_on_unmatched_files, env and the
GITHUB_TOKEN entry (they are not under any job/step) so the workflow parses
correctly; keep the explanatory comment but delete those three lines or relocate
them under the appropriate step/job if intended, and ensure there are no other
top-level stray mapping entries.

---

Nitpick comments:
In `@nativelib/src/main/cpp/game_controller_native.cpp`:
- Around line 1327-1351: In GameController_HeartbeatCheck, avoid calling
g_deviceCallback and napi_call_threadsafe_function while holding g_mutex to
prevent deadlocks; instead, copy the disconnectedDevices entries (or the minimal
data: deviceId string and GameControllerInfo) into a temporary vector/local
container while holding g_mutex, then release the mutex and iterate that
temporary container to invoke g_deviceCallback (setting info.isConnected=false)
and napi_call_threadsafe_function using g_tsfnDevice; ensure you preserve
deviceId and info when copying and free any heap allocations used for napi
events after the call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53688fae-3448-4dfe-992d-df0a0de92959

📥 Commits

Reviewing files that changed from the base of the PR and between c79be21 and 5c192b6.

📒 Files selected for processing (10)
  • .github/workflows/build.yml
  • ci/patch-sdk.sh
  • ci/sdk-stubs/kit.ScanKit.d.ts
  • ci/sdk-stubs/kit.ScanKit.json
  • ci/sdk-stubs/kit.ShareKit.d.ts
  • ci/sdk-stubs/kit.ShareKit.json
  • ci/sdk-stubs/ohos.scan.scanBarcode.d.ts
  • ci/sdk-stubs/ohos.scan.scanCore.d.ts
  • ci/sdk-stubs/ohos.share.systemShare.d.ts
  • nativelib/src/main/cpp/game_controller_native.cpp
✅ Files skipped from review due to trivial changes (7)
  • ci/sdk-stubs/kit.ScanKit.json
  • ci/sdk-stubs/kit.ShareKit.json
  • ci/sdk-stubs/ohos.scan.scanCore.d.ts
  • ci/sdk-stubs/ohos.scan.scanBarcode.d.ts
  • ci/sdk-stubs/kit.ScanKit.d.ts
  • ci/sdk-stubs/kit.ShareKit.d.ts
  • ci/sdk-stubs/ohos.share.systemShare.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/patch-sdk.sh

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
nativelib/src/main/cpp/game_controller_native.cpp (1)

362-380: 符号验证逻辑合理,但注释略有出入

注释说"验证所有按键/轴监听函数",但实际只检查了 11 个关键函数(共 22 个注册函数)。这是合理的关键路径检查,但如果日后维护者依赖此注释可能产生误解。

建议将注释改为"验证关键按键/轴监听函数"或补全检查列表。不影响功能。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nativelib/src/main/cpp/game_controller_native.cpp` around lines 362 - 380,
注释不准确:注释写“验证所有按键/轴监听函数”,但代码只检查了关键函数(例如
OH_GamePad_ButtonA_RegisterButtonInputMonitor、OH_GamePad_RightTrigger_RegisterAxisInputMonitor
等 11 个符号);请将注释改为“验证关键按键/轴监听函数”或等价表述以反映实际行为,或者把缺失的注册函数(其余约 11 个注册符号)也加入
CHECK_FUNC 列表以实现真正的“全部检查”;更新 game_controller_native.cpp 中该注释/检查块以保持描述与实现一致。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nativelib/src/main/cpp/game_controller_native.cpp`:
- Around line 798-801: The StopMonitor path has a race because NapiStopMonitor
calls GameController_StopMonitor() without taking g_mutex; create a locked
internal wrapper to ensure thread-safety: implement a new function
GameController_StopMonitorLocked() that acquires g_mutex, performs the current
StopMonitor logic (modify g_monitoring, g_inputPaused, call
UnregisterAllInputMonitors, etc.), then releases g_mutex; change NapiStopMonitor
to call GameController_StopMonitorLocked(); keep existing callers that already
hold g_mutex calling the original GameController_StopMonitor() (or rename the
unlocked version to GameController_StopMonitorUnlocked) to avoid double-locking,
and update comments accordingly referencing UnregisterAllInputMonitors,
GameController_StopMonitor, NapiStopMonitor, StartMonitor, PauseInputMonitor,
ResumeInputMonitor.

---

Nitpick comments:
In `@nativelib/src/main/cpp/game_controller_native.cpp`:
- Around line 362-380: 注释不准确:注释写“验证所有按键/轴监听函数”,但代码只检查了关键函数(例如
OH_GamePad_ButtonA_RegisterButtonInputMonitor、OH_GamePad_RightTrigger_RegisterAxisInputMonitor
等 11 个符号);请将注释改为“验证关键按键/轴监听函数”或等价表述以反映实际行为,或者把缺失的注册函数(其余约 11 个注册符号)也加入
CHECK_FUNC 列表以实现真正的“全部检查”;更新 game_controller_native.cpp 中该注释/检查块以保持描述与实现一致。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c8be783e-474b-4676-ac37-e07a63d5bc2f

📥 Commits

Reviewing files that changed from the base of the PR and between 5c192b6 and 866d057.

📒 Files selected for processing (1)
  • nativelib/src/main/cpp/game_controller_native.cpp

@qiin2333 qiin2333 changed the title feat: 愚人节彩蛋 + 设置页修复 + CodeRabbit 接入 feat: 上线问题反馈修复 + CodeRabbit 接入 Apr 2, 2026
@qiin2333 qiin2333 changed the title feat: 上线问题反馈修复 + CodeRabbit 接入 feat: v749-v752 功能合集 + CI 原生代码构建 + CodeRabbit Apr 2, 2026
@qiin2333 qiin2333 changed the title feat: v749-v752 功能合集 + CI 原生代码构建 + CodeRabbit feat: 愚人节彩蛋 + 设置页修复 + CI 原生构建 + CodeRabbit Apr 2, 2026
@qiin2333 qiin2333 changed the title feat: 愚人节彩蛋 + 设置页修复 + CI 原生构建 + CodeRabbit feat: 愚人节彩蛋 + 设置页修复 + GCK 安全加固 + CI/CodeRabbit Apr 2, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nativelib/src/main/cpp/game_controller_native.cpp (1)

907-928: ⚠️ Potential issue | 🔴 Critical

缺少 GameController_StopMonitorUnlocked 的前向声明

GameController_Uninit() 在第 913 行调用 GameController_StopMonitorUnlocked(),但该函数直到第 1038 行才定义。由于该函数是 static,必须在使用前声明,否则编译会失败。

GameController_Uninit() 之前添加前向声明:

+static void GameController_StopMonitorUnlocked();
+
 void GameController_Uninit(void) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nativelib/src/main/cpp/game_controller_native.cpp` around lines 907 - 928,
The call to the static function GameController_StopMonitorUnlocked inside
GameController_Uninit occurs before the function is defined, causing a compile
error; add a forward declaration for the static function (e.g., static void
GameController_StopMonitorUnlocked(); ) above the definition of
GameController_Uninit so the compiler knows its signature when Uninit is
compiled, ensuring the existing static linkage and function prototype match the
actual definition later in the file.
🧹 Nitpick comments (1)
.github/workflows/build.yml (1)

304-320: 构建步骤修改符合模块配置。

  • 步骤名改为 "Build Native" 符合实际用途
  • assembleHarnativelib/hvigorfile.ts 中的 harTasks 配置一致
  • -p module=nativelib@default 中的模块名和目标均与 nativelib/oh-package.json5nativelib/build-profile.json5 匹配

小建议:日志文件名 build-hap.log 可考虑改为 build-har.logbuild-native.log 以保持命名一致性。

可选:重命名日志文件
        node hvigorw.js assembleHar \
          --mode module \
          -p module=nativelib@default \
          -p product=default \
          -p buildMode="${BUILD_MODE}" \
          --no-daemon \
          --stacktrace \
-          2>&1 | tee build-hap.log
+          2>&1 | tee build-native.log

同步更新 artifact 上传路径(第 333 行):

        path: |
-          build-hap.log
+          build-native.log
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build.yml around lines 304 - 320, The current workflow
step "Build Native" runs hvigorw.js assembleHar and writes output to
build-hap.log which mismatches the assembleHar/har naming; change the log
filename used in that step from build-hap.log to a consistent name (e.g.,
build-har.log or build-native.log) in the node command invocation, and also
update any downstream references to that artifact (the artifact upload/action
that expects build-hap.log) so they point to the new filename; target the "Build
Native" step and the artifact upload stage that references build-hap.log when
making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@nativelib/src/main/cpp/game_controller_native.cpp`:
- Around line 907-928: The call to the static function
GameController_StopMonitorUnlocked inside GameController_Uninit occurs before
the function is defined, causing a compile error; add a forward declaration for
the static function (e.g., static void GameController_StopMonitorUnlocked(); )
above the definition of GameController_Uninit so the compiler knows its
signature when Uninit is compiled, ensuring the existing static linkage and
function prototype match the actual definition later in the file.

---

Nitpick comments:
In @.github/workflows/build.yml:
- Around line 304-320: The current workflow step "Build Native" runs hvigorw.js
assembleHar and writes output to build-hap.log which mismatches the
assembleHar/har naming; change the log filename used in that step from
build-hap.log to a consistent name (e.g., build-har.log or build-native.log) in
the node command invocation, and also update any downstream references to that
artifact (the artifact upload/action that expects build-hap.log) so they point
to the new filename; target the "Build Native" step and the artifact upload
stage that references build-hap.log when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57873ef1-3d16-4058-93a5-4b7745b3165b

📥 Commits

Reviewing files that changed from the base of the PR and between 866d057 and a0855b7.

📒 Files selected for processing (2)
  • .github/workflows/build.yml
  • nativelib/src/main/cpp/game_controller_native.cpp

@qiin2333 qiin2333 force-pushed the feat/coderabbit-and-fixes branch from a0855b7 to 62e576e Compare April 2, 2026 09:15
- NapiStopMonitor 路径现在正确持有 g_mutex
- Uninit 内部调用无锁版 GameController_StopMonitorUnlocked 避免死锁
@qiin2333 qiin2333 merged commit ece11b3 into master Apr 2, 2026
1 of 2 checks passed
@qiin2333 qiin2333 deleted the feat/coderabbit-and-fixes branch April 2, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant