已开启
fix: 快速启动显示问题 #20316
fix: 快速启动显示问题 #20316
已开启
SkyQAQ创建于 5 天前
SkyQAQ
5 天前

IssueNo:
https://gitcode.com/openharmony/ability_ability_runtime/issues/16080
Description:
fix: 快速启动显示问题
稳定性自检:

自检项 自检结果
涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发
成员变量进行赋值或创建需要排查并发
谨慎在lambda表达式中使用引用捕获
谨慎在未经拷贝的情况下使用外部传入的string、C字符串
map\vector\list\set等stl模板类使用时需要排查并发
谨慎考虑加锁范围
在IPC通信中谨慎使用同步通信方式
禁止传递this指针至其他模块或线程(特别是eventhandler任务)
禁止将外部传入的裸指针在内部直接构造智能指针
禁止多个独立创建的智能指针管理同一地址
禁止在析构函数中抛异步任务
禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁
禁止在对外接口中未经判空直接使用外部传入的指针
禁止接口返回局部变量引用
禁止在信号函数中加锁
禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作
禁止将同一个cpp编译在不同的so中

安全编码自检:

自检项 自检结果
裸指针避免通过隐式转换构造为sptr
json对象在取值之前必须先判断类型,避免类型不匹配
序列化时必须对传入的数组大小进行校验,避免出现超大数组
避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型
外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验
指针变量、表示资源描述符的变量、bool变量必须赋初值
readParcelable获取的对象使用前需要判空
分配和释放内存的函数需要成对出现
申请内存后异常退出前需要及时进行内存释放
内存申请前必须对内存大小进行合法性校验
内存分配后必须判断是否成功
禁止使用realloc、alloca函数
禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰
禁止打印内存地址
整数之间运算时必须严格检查,确保不会出现溢出、反转、除0
禁止对有符号整数进行位操作符运算
禁止对指针进行逻辑或位运算
循环次数如果收外部数据控制,需要检验其合法性
禁止使用内存操作类危险函数,需要使用安全函数
谨慎使用不可重入函数
必须检查安全函数的返回值,并进行正确处理
禁止仅通过TokenType类型判断绕过权限校验

TDD Result:

XTS Result:

是否已执行L0用例

AI检视评分(使用本地代码检视skills扫描):

likedislike
合并受阻
SSkyQAQ
5 天前 关联了issue:[新需求]: fix: 快速启动显示问题
afwk_helper成员
5 天前 评论:

开始进行AI检视!

AI review has been started, please wait...

likedislike
afwk_helper成员
5 天前 评论:
check type result report
start ai_review pass -
likedislike
openharmony_ci
openharmony_ci成员
5 天前 评论:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
openharmony_ciopenharmony_ci成员
5 天前 添加了label:waiting_on_author
openharmony_ciopenharmony_ci成员
5 天前 添加了label:dco检查失败
afwk_helper成员
5 天前 评论:

⚠️ 🤖 AI 代码检视报告 ⚠️

总体评估: NEEDS_ATTENTION

问题统计:

  • 总问题数: 4
  • 严重问题: 0
  • 高危问题: 1

摘要:
代码主要修复了快速启动时的显示问题,调整了窗口状态栏和安全区域的处理逻辑,但在表单校验的 NaN 判断和窗口对象的空指针检查上存在隐患。

📊 详细报告
查看完整的审查详情,包括具体的问题描述、建议和代码位置:
🔗 查看详细报告


此评论由 OpenHarmony Insight 代码审查系统自动生成

likedislike
afwk_helper成员5 天前进行代码检视2
services/dialog_ui/ams_system_dialog/feature/src/main/ets/view/IntentDetailPage.ets
已过期
@@ -357,3 +358,3 @@
357358 let validate: boolean = true;
358359 this.required?.forEach((key: string) => {
359- if (executeParam[key] === undefined || executeParam[key] === null) {
360+ if (executeParam[key] === undefined || executeParam[key] === null ||
afwk_helper5 天前评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟠 表单校验中 Number.isNaN 使用不当

位置: L360-L361 | 严重程度: High

❓ 问题描述

Number.isNaN() 只在参数严格等于 NaN 时返回 true。如果 executeParam[key] 是非数字的字符串(如表单输入的文本),类型断言 as number 在运行时会被擦除,Number.isNaN("abc") 会返回 false,导致非数字的字符串能够绕过必填项校验。

💡 修复建议

修改建议:使用全局 isNaN 配合 Number() 转换,确保非数字的字符串也能被正确校验为无效值。

360: if (executeParam[key] === undefined || executeParam[key] === null ||
361: executeParam[key] === '' || isNaN(Number(executeParam[key]))) {


likedislike
System
系统消息系统
3 天前 评论:

changed this line on 7f9f7e2b view diff detail

afwk_helper成员5 天前进行代码检视2
services/dialog_ui/ams_system_dialog/feature/src/main/ets/entryability/EntryAbility.ets
已过期
@@ -130,0 +104,4 @@
104+ this.colorMode = this.context.config.colorMode;
105+ hilog.info(DOMAIN, TAG, 'onWindowStageCreate: colorMode=%{public}d', this.colorMode);
106+ try {
107+ windowStage.getMainWindow((err, data) => {
afwk_helper5 天前评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 getMainWindow 回调未对 data 进行判空

位置: L107-L114 | 严重程度: Medium

❓ 问题描述

在 windowStage.getMainWindow 的回调中,仅检查了 err.code,但未对返回的 data (window.Window) 进行判空。如果 API 在某些异常情况下返回了非零错误码且 data 为空,后续的 this.mainWindow = data 及 data.getWindowAvoidArea() 可能会导致空指针异常或崩溃。

💡 修复建议

修改建议:在检查 err 后,增加对 data 是否为空的判断,确保后续操作安全。

108: if (err && err.code !== 0) {
109: hilog.error(DOMAIN, TAG, 'Failed to get main window. code=%{public}d, Cause: %{public}s',
110: err.code, JSON.stringify(err.message ?? err));
111: return;
112: }
113: if (!data) { return; }
114: this.mainWindow = data;


likedislike
System
系统消息系统
3 天前 评论:

changed this line on 70cdc9ac view diff detail

afwk_helper成员5 天前进行代码检视2
services/dialog_ui/ams_system_dialog/feature/src/main/ets/entryability/EntryAbility.ets
已过期
@@ -113,1 +104,3 @@
113- })
104+ this.colorMode = this.context.config.colorMode;
105+ hilog.info(DOMAIN, TAG, 'onWindowStageCreate: colorMode=%{public}d', this.colorMode);
106+ try {
afwk_helper5 天前评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 onWindowStageCreate 中存在多层回调嵌套

位置: L106-L144 | 严重程度: Medium

❓ 问题描述

在 onWindowStageCreate 中,使用了多层嵌套回调(getMainWindow 回调内部包含 loadContent 回调,再包含 setWindowSystemBarProperties 的 Promise)。这种“回调地狱”降低了代码的可读性和可维护性,且容易遗漏错误处理。

💡 修复建议

修改建议:使用 Promise 链式调用或 async/await 重构嵌套回调,避免“回调地狱”并提升可维护性。

106: try {
107: windowStage.getMainWindow().then((data: window.Window) => {
108: // ... set properties
109: return windowStage.loadContent('pages/Index');
110: }).then(() => {
111: // ... set system bar properties
112: }).catch((err: BusinessError) => {
113: hilog.error(DOMAIN, TAG, 'Failed in window stage create. Cause: %{public}s', JSON.stringify(err));
114: });


likedislike
System
系统消息系统
3 天前 评论:

changed this line on 70cdc9ac view diff detail

SSkyQAQ
3 天前 审查状态已重置,审查人: afwk_helper
SSkyQAQ
3 天前 强制推送  1 个提交:70cdc9ac-fix: 意图调试应用bug, Co-Authored-By: Agent
openharmony_ci
openharmony_ci成员
3 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
3 天前 删除了label:dco检查失败
openharmony_ciopenharmony_ci成员
3 天前 添加了label:dco检查成功
SSkyQAQ
3 天前 审查状态已重置,审查人: afwk_helper
SSkyQAQ
3 天前 强制推送  1 个提交:f43c0010-fix: 意图调试应用bug, Co-Authored-By: Agent
openharmony_ci
openharmony_ci成员
3 天前 评论:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
openharmony_ciopenharmony_ci成员
3 天前 删除了label:dco检查成功
openharmony_ciopenharmony_ci成员
3 天前 添加了label:dco检查失败
SSkyQAQ
3 天前 审查状态已重置,审查人: afwk_helper
SSkyQAQ
3 天前 强制推送  1 个提交:7f9f7e2b-fix: 注释掉全屏设置, Co-Authored-By: Agent
openharmony_ci
openharmony_ci成员
3 天前 评论:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
hwliujinwei2 天前进行代码检视1
services/dialog_ui/ams_system_dialog/feature/src/main/ets/entryability/EntryAbility.ets
@@ -6,7 +6,7 @@
66 *
77 * http://www.apache.org/licenses/LICENSE-2.0
88 *
99 * Unless required by applicable law or agreed to in writing, software
hwliujinwei2 天前评论:

[重要] 不应直接注释掉代码提交到代码库。如果该调用不再需要,应直接删除;如果需要条件控制,应通过配置项或条件判断实现。注释掉的代码会造成维护困惑,不符合代码规范。

likedislike
hwliujinwei2 天前进行代码检视1
services/dialog_ui/ams_system_dialog/feature/src/main/ets/entryability/EntryAbility.ets
@@ -6,7 +6,7 @@
66 *
77 * http://www.apache.org/licenses/LICENSE-2.0
88 *
99 * Unless required by applicable law or agreed to in writing, software
hwliujinwei2 天前评论:

[次要] 注释掉 setWindowLayoutFullScreen 后缺少说明为何禁用全屏布局的注释。建议添加简要注释说明根因(如快速启动时全屏布局导致的显示问题),便于后续维护者理解。

likedislike
hwliujinwei2 天前进行代码检视1
services/dialog_ui/ams_system_dialog/feature/src/main/ets/entryability/EntryAbility.ets
@@ -6,7 +6,7 @@
66 *
77 * http://www.apache.org/licenses/LICENSE-2.0
88 *
99 * Unless required by applicable law or agreed to in writing, software
hwliujinwei2 天前评论:

[重要] 不建议直接注释代码,应直接删除不需要的调用。版本控制已保留历史,注释代码会降低可读性。请删除注释掉的代码块。

likedislike