Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
比较版本
c1dea793506d62a6de9bad6e95772e1e9b4eb14f...d30c80ffd2c6094beda6358b29c8c24252ebe945
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
9 个月 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
源分支
d30c80ffd2c6094beda6358b29c8c24252ebe945
选择Git版本
...
目标分支
c1dea793506d62a6de9bad6e95772e1e9b4eb14f
选择Git版本
比较
Commits (85)
https://gitcode.net/openharmony/communication_ipc/-/commit/01b176d5709ac524ac7859742b35ccd5758657dd
修复使用RawData相关接口传输超过1M数据时失败的问题
2023-08-02T17:12:36+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d66709b513eddf9b10d2f15f1b732c44722670fb
修复rawdata传输问题的检视意见修改
2023-08-03T14:53:37+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/bb2bfd0bb41213ec6dbc35624856bde4d3c7c68b
修复rawdata出现问题修改的检视意见
2023-08-03T20:43:15+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/3f98a11f34f19ee9ebeacea3bd6ac3f3c63ab4b8
ipc仓ipc_js合并到ipc部件中修改
2023-08-04T16:06:51+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/5ccdc0080076a1a01b7d4608198302b719321c73
修改Emulator编译失败的问题
2023-08-08T01:22:39+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/b0a84c12717e3b428b9c59863fd124d88a22d139
修改编译失败的问题
2023-08-08T01:59:21+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/a4ae636d4eb34566b5ccb65ca033f98a8b592e32
修改编译错误
2023-08-08T02:15:56+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/4188fee02d0b8017de5a1088cd8c6159b4dad78e
修复rawdata出现问题修改的检视意见以及相应逻辑完善
2023-08-08T17:39:38+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d385950f1edf6fc300802d86ae0fc233e3c756e9
修改门禁中编译成功,但测试失败的情况(例如底层使用时仍然是需要librpc.z.so文件,所以此处修改group名,保留rpc的so文件名)
2023-08-10T09:10:23+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/4686ffba89d270fc9927f7d853f06dad5e05caad
BlockUntilThreadAvailable接口用例添加
2023-08-10T07:39:20+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/75c56b5c71b6a68f263ef630f84f83e2c5a8b8a5
BlockUntilThreadAvailable接口用例添加
2023-08-10T07:59:48+00:00
dengyutao
dengyutao2@huawei.com
<a href="https://gitee.com/openharmony/communication_ipc/issues/I7S741" rel="nofollow noreferrer noopener" target="_blank">https://gitee.com/openharmony/communication_ipc/issues/I7S741</a>Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/aa8c4d055bb0920377551643118034b9a520ba55
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-10T08:08:59+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/75d32acefca7022c61c8a9f2302c130fe64bba34
update interfaces/innerkits/ipc_core/libipc_core_map.
2023-08-10T08:44:00+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/5218927e054a580f6ab65b950e3eaeeb53141ed5
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-10T09:29:55+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/680b121bfe65f1848b513713621b768810089f23
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-10T10:44:32+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/7b87d933e32a52bbe305fb2de7774f2d8193d0e2
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-10T11:29:38+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/b5677c1dae002d12e527b490cd25913a09a72b6a
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T03:10:40+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/be55e7ece6801a9ec000da5c1e03c7ca3f9e6310
update ipc/native/src/core/source/ipc_thread_pool.cpp.
2023-08-11T04:52:38+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/5ab8a28f208e1c2d8cdfcf970f21596d68e71ed4
update ipc/native/src/core/source/ipc_thread_pool.cpp.
2023-08-11T05:30:25+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/0acf60f6c3b85885f5854ec2a9896429a4f4f310
update ipc/native/src/core/source/ipc_thread_pool.cpp.
2023-08-11T06:26:53+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/cbc7a5c5adb026658675576c9be1a9a4ddff27d5
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T06:45:16+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/7ff8ee99f3df9f4d01e557b477383bbb8b0d212d
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T08:44:27+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c90ce892d7831e3382cc9a1b9de6508ab2ae2bbe
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T08:50:04+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/aff944d2a51f63f9ada97612c7dedb22ae41ccbb
update interfaces/innerkits/ipc_core/libipc_core_map.
2023-08-11T09:35:59+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/801024576cdd6aab4db376b7f78d5a703830c9b4
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T09:37:32+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d89a278c37ce25d98097e3d4962518fa9436f022
修复rawdata出现问题修改的检视意见以及相应逻辑完善
2023-08-11T18:18:50+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/2f4e1de8210f01d3ecc6b5c042e008fa19ee7e60
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-11T10:22:43+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/b6a7b1456600b7a9bf3ce0f31ee4a1d2fc7aab07
ipc仓ipc_js合并到ipc部件中修改之删除多余部件定义
2023-08-14T14:40:42+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/33d0ca589762d1d62a3acd7ca2889d02eeb6fa66
RawData问题修复对应测试用例修改
2023-08-14T16:11:27+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/a35b0d77e6abcf02c9c73cf78122ad41e2551dd1
add strong ref to avoid using option after free by ark engine
2023-08-14T09:03:29+00:00
shufewhx
wanghaoxu1@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">shufewhx</a> <<a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">wanghaoxu1@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/03ca51a6ab8dda832d1b51e36844664dabab0182
!761 BlockUntilThreadAvailable接口用例添加
2023-08-15T01:59:21+00:00
openharmony_ci
120357966@qq.com
Merge pull request !761 from dengyutao/master
https://gitcode.net/openharmony/communication_ipc/-/commit/a49e167133088d230af73ced396c8a8b9e8db09b
检视意见修改
2023-08-15T16:54:17+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/af2417cb87918d89926764da18f49c0f8131fe78
update ipc/native/src/core/source/message_parcel.cpp.
2023-08-15T11:40:23+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c00831b47585b384a1af5c9ae07580a11f9ec164
fix weak ref mem leak
2023-08-16T10:15:46+08:00
18392170496
magentang4@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">18392170496</a> <<a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">magentang4@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/02250df798599297fd9d07137d8fb590999d2f39
!752 修复使用RawData相关接口传输超过1M数据时失败的问题
2023-08-16T07:49:31+00:00
openharmony_ci
120357966@qq.com
Merge pull request !752 from lishengming14/master
https://gitcode.net/openharmony/communication_ipc/-/commit/7c1b0ee94e581e4cfc3741935736698d2ac8088a
!764 fix weak ref mem leak
2023-08-16T08:03:22+00:00
openharmony_ci
120357966@qq.com
Merge pull request !764 from 马根堂/master
https://gitcode.net/openharmony/communication_ipc/-/commit/adf45afb07b19de7c64aff85dba925bf587907d2
!763 add strong ref to avoid using MessageOption object freed by ark engine
2023-08-16T08:03:57+00:00
openharmony_ci
120357966@qq.com
Merge pull request !763 from wanghaoxu/master
https://gitcode.net/openharmony/communication_ipc/-/commit/0eebd9bbc6c8a42b68ebe9b39fbe42cc4f5ff4c8
修改rawData问题中函数参数类型使用不当的问题
2023-08-17T10:39:00+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d2093a3f629a61869023dfea3d933b45c41fb2c0
同步ClearFileDescriptor()函数和ContainFileDescriptors()函数出现的数据越界问题修改
2023-08-17T11:00:51+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c1e828312811923e9a7cde7032d87c4e449960a9
检视意见修改
2023-08-17T18:46:03+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/5e28f14c0f2ffe7b3c6fe7902c0ddddd929ed0c0
提供由c++ IRemoteObject对象向rust RemoteObj对象转换
2023-08-17T19:20:24+08:00
chenchong_666
chenchong57@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong_666</a> <<a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong57@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/1c5585049e132f7dd51d3b8882378b0306ac0f8b
!767 提供由c++ IRemoteObject对象向rust RemoteObj对象转换函数
2023-08-17T12:28:06+00:00
openharmony_ci
120357966@qq.com
Merge pull request !767 from chenchong_666/master
https://gitcode.net/openharmony/communication_ipc/-/commit/8cf721439d8870817779a78723b7dda6bae011a5
!765 修改rawdata问题修复中函数参数类型使用不当的问题
2023-08-17T12:37:58+00:00
openharmony_ci
120357966@qq.com
Merge pull request !765 from lishengming14/master
https://gitcode.net/openharmony/communication_ipc/-/commit/5bc39e6cb99f7c96d3be6bf8cd2a1f6f408ad515
更新注释
2023-08-18T01:17:33+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/5db0749dd9e1836475eed53d02ee483a6639e435
【质量补充】完善env判断逻辑
2023-08-21T15:22:51+08:00
18392170496
magentang4@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">18392170496</a> <<a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">magentang4@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/6241038bd5731c6c013fd5b02259a25bfe63f844
!770 【质量补充】完善env判断逻辑
2023-08-21T10:19:50+00:00
openharmony_ci
120357966@qq.com
Merge pull request !770 from 马根堂/master
https://gitcode.net/openharmony/communication_ipc/-/commit/1d3db6105cb9eaee84f398952ad6744fe24327fd
!766 压测时出现~MessageParcel()函数中出现越界导致crash,同步修改
2023-08-22T03:42:46+00:00
openharmony_ci
120357966@qq.com
Merge pull request !766 from lishengming14/master
https://gitcode.net/openharmony/communication_ipc/-/commit/f186456adfe7c73de8df8dee7d07524a1ad8ff81
将ipc_rpc组名替换为ipc_js
2023-08-22T12:02:43+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/a0b2941d735f743f11c36f5b63426e529b7ffebb
替换ipc_rpc为ipc_js
2023-08-22T12:21:03+00:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/e608f86877ea529573a292e3eb2cca47db272b31
add ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-24T08:32:04+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/ddbc9d7e624e7cc9c7371f2fca392022be62027c
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T08:35:50+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/9485826df31631c350999be1cff30c0650328dbb
update ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-24T08:37:32+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/b57920cdcfcba44da0162f2249982075830f871f
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T08:43:40+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/1d63a0af5e459eb948ad5733905e00f92ae6838d
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T08:51:26+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/539da164e64e963a5c2d2a00fb8bd2f256829899
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T08:51:52+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/aee62b1ff09069175bc1d94966ffc1d69af2c6c2
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T09:19:39+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/15b3a0366878d78ec4d32667129ed340c121be2a
update ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-24T10:06:17+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/60b62819e21528fdc5c6e70bb96994f041268a1a
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T10:09:16+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/7929cda58530c369355c36f7e99d6ee98bb9bc24
提供CRemoteObject和CIRemoteObject结构体,其他部件可以使用
2023-08-24T19:12:53+08:00
chenchong_666
chenchong57@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong_666</a> <<a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong57@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/411197d98fe491925337dde02611c4d4ce3669d7
napi中处理数据argv数组使用时使用了魔数,进行修改
2023-08-24T19:15:40+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/e799a3adb8ae376ce65a5b953d39a56b3d1cf852
update ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-24T11:19:30+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d947b1e70173a00a06d7daa6794f65f39a41eb8c
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T11:23:49+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/92f2b4b92b829d2aade1e8a7ae7434a1dba9ec21
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T11:26:15+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/801bb19d8abf11a1bd167ca01495f0a697f353f5
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T12:23:09+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c5d992ccc132516823b05abf202c080d2ed4d175
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-24T12:46:14+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/f0bed6c1b321d92e3cf1664415007fe183e62733
!777 提供CRemoteObject和CIRemoteObject结构体,其他部件可以使用
2023-08-24T13:11:33+00:00
openharmony_ci
120357966@qq.com
Merge pull request !777 from chenchong_666/master
https://gitcode.net/openharmony/communication_ipc/-/commit/a2de6752d7130d53a2c879024c2e4eef4188cbe4
update ipc/native/test/unittest/common/BUILD.gn.
2023-08-25T01:04:31+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c37eac00f28381b795a4d9127455bd177d753da5
魔数修改,关于使用napi时定义数组时使用的魔数
2023-08-25T10:30:12+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/96c96eb56561a3c0f08fa75b62e4a527e81b358f
update ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-25T02:53:01+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/2e38a8ad1ab8cc40bf0d0925d240644afeab01d3
update ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp.
2023-08-25T02:57:49+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/0cae801b1b951de81d40d796354c6ed9a987f70e
ReadMe文档中添加rust侧开发指导说明
2023-08-25T11:39:33+08:00
chenchong_666
chenchong57@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong_666</a> <<a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong57@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/afb0fdfdad7ca5d79f4253a41fe0c94e84baeb78
修改rust文档说明
2023-08-25T15:05:40+08:00
chenchong_666
chenchong57@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong_666</a> <<a href="mailto:chenchong57@huawei.com" title="chenchong57@huawei.com">chenchong57@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/a2e571c842ab6a8197ac861c2cdecc21c8d4c454
update ipc/native/test/unittest/common/ipc_skeleton_unittest.cpp.
2023-08-25T07:38:28+00:00
dengyutao
dengyutao2@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao</a> <<a href="mailto:dengyutao2@huawei.com" title="dengyutao2@huawei.com">dengyutao2@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/de909a38dcf10210eefdf015e330dfeaac3b1dfc
!781 在README文档中添加rust侧开发指导说明
2023-08-25T08:24:47+00:00
openharmony_ci
120357966@qq.com
Merge pull request !781 from chenchong_666/master
https://gitcode.net/openharmony/communication_ipc/-/commit/b4f78592cc2e73b6a0dac75dbcb101c499db2ed6
add debug log for deathrecipient
2023-08-25T08:46:18+00:00
shufewhx
wanghaoxu1@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">shufewhx</a> <<a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">wanghaoxu1@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/c402f0b064befc717659960e3162bff941c445e3
检视意见修改,去除多余注释
2023-08-25T17:48:14+08:00
lishengming14
lishengming14@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14</a> <<a href="mailto:lishengming14@huawei.com" title="lishengming14@huawei.com">lishengming14@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/a756137d8f98bda0d320cc80e0bbcee853736bc7
!775 添加接口ut测试
2023-08-25T10:24:50+00:00
openharmony_ci
120357966@qq.com
Merge pull request !775 from dengyutao/master
https://gitcode.net/openharmony/communication_ipc/-/commit/24d5fa3bca76bcedbcd7ca440f7bd390c0b4103f
!778 napi中解析数据argv数组魔数使用修改
2023-08-26T02:48:54+00:00
openharmony_ci
120357966@qq.com
Merge pull request !778 from lishengming14/master
https://gitcode.net/openharmony/communication_ipc/-/commit/d44cd0f4bca170d90bfb695396672a7958312af8
Signed-off-by:caojiale1 <caojiale1@huawei.com>
2023-08-26T11:45:33+08:00
caojiale1
caojiale1@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:caojiale1@huawei.com" title="caojiale1@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:caojiale1@huawei.com" title="caojiale1@huawei.com">caojiale1</a> <<a href="mailto:caojiale1@huawei.com" title="caojiale1@huawei.com">caojiale1@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/bff889d253efa70e9b4b8be9f40b3fab6194a1c4
!774 add log for deathrecipient
2023-08-26T08:14:41+00:00
openharmony_ci
120357966@qq.com
Merge pull request !774 from wanghaoxu/master
https://gitcode.net/openharmony/communication_ipc/-/commit/3937a167f4ac313284b30a4225d5818a697d4786
!755 communication_ipc-ipc_js合并到ipc部件中修改
2023-08-29T10:51:02+00:00
openharmony_ci
120357966@qq.com
Merge pull request !755 from lishengming14/master
https://gitcode.net/openharmony/communication_ipc/-/commit/56c54080a2db4dc5f054ca8b6fec9693ae7083aa
!784 自测试仓部件名整改
2023-08-29T12:52:23+00:00
openharmony_ci
120357966@qq.com
Merge pull request !784 from caojiale1/master
https://gitcode.net/openharmony/communication_ipc/-/commit/faa556c46b5082fc998638714b545c5e371b721f
fixed a security issue in the use of RPC mutex.
2023-09-01T10:33:33+08:00
18392170496
magentang4@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">18392170496</a> <<a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">magentang4@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/dd5c65106ca41b896dc65232bdb95585937589a1
mutex
2023-09-01T10:50:53+08:00
18392170496
magentang4@huawei.com
Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">18392170496</a> <<a href="mailto:magentang4@huawei.com" title="magentang4@huawei.com">magentang4@huawei.com</a>></span>
https://gitcode.net/openharmony/communication_ipc/-/commit/d30c80ffd2c6094beda6358b29c8c24252ebe945
!787 fixed a security issue in the use of RPC mutex.
2023-09-01T09:49:28+00:00
openharmony_ci
120357966@qq.com
Merge pull request !787 from 马根堂/master
展开全部
隐藏空白更改
内联
并排
Showing
31 changed file
with
1268 addition
and
630 deletion
+1268
-630
README_zh.md
README_zh.md
+354
-26
bundle.json
bundle.json
+11
-1
interfaces/innerkits/rust/src/ipc/remote_obj.rs
interfaces/innerkits/rust/src/ipc/remote_obj.rs
+21
-1
interfaces/innerkits/rust/src/ipc_binding.rs
interfaces/innerkits/rust/src/ipc_binding.rs
+12
-0
interfaces/innerkits/rust/src/lib.rs
interfaces/innerkits/rust/src/lib.rs
+2
-0
interfaces/kits/bundle.json
interfaces/kits/bundle.json
+0
-55
interfaces/kits/js/napi/BUILD.gn
interfaces/kits/js/napi/BUILD.gn
+50
-41
ipc/native/src/c_wrapper/include/c_remote_object.h
ipc/native/src/c_wrapper/include/c_remote_object.h
+3
-1
ipc/native/src/c_wrapper/source/c_remote_object.cpp
ipc/native/src/c_wrapper/source/c_remote_object.cpp
+33
-0
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+2
-0
ipc/native/src/core/source/message_parcel.cpp
ipc/native/src/core/source/message_parcel.cpp
+44
-21
ipc/native/src/mock/include/dbinder_base_invoker.h
ipc/native/src/mock/include/dbinder_base_invoker.h
+34
-19
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
+1
-0
ipc/native/src/napi/src/napi_ipc_skeleton.cpp
ipc/native/src/napi/src/napi_ipc_skeleton.cpp
+13
-12
ipc/native/src/napi/src/napi_message_option.cpp
ipc/native/src/napi/src/napi_message_option.cpp
+23
-18
ipc/native/src/napi/src/napi_remote_proxy.cpp
ipc/native/src/napi/src/napi_remote_proxy.cpp
+46
-37
ipc/native/src/napi_common/include/napi_message_sequence.h
ipc/native/src/napi_common/include/napi_message_sequence.h
+4
-0
ipc/native/src/napi_common/include/napi_remote_object_internal.h
...ive/src/napi_common/include/napi_remote_object_internal.h
+1
-0
ipc/native/src/napi_common/source/napi_ashmem.cpp
ipc/native/src/napi_common/source/napi_ashmem.cpp
+69
-62
ipc/native/src/napi_common/source/napi_message_parcel.cpp
ipc/native/src/napi_common/source/napi_message_parcel.cpp
+176
-171
ipc/native/src/napi_common/source/napi_message_sequence.cpp
ipc/native/src/napi_common/source/napi_message_sequence.cpp
+139
-77
ipc/native/src/napi_common/source/napi_remote_object.cpp
ipc/native/src/napi_common/source/napi_remote_object.cpp
+60
-49
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
...tive/src/napi_common/source/napi_remote_object_holder.cpp
+51
-4
ipc/native/test/unittest/common/BUILD.gn
ipc/native/test/unittest/common/BUILD.gn
+21
-0
ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp
...native/test/unittest/common/ipc_block_thread_unittest.cpp
+61
-0
ipc/native/test/unittest/common/message_parcel_unittest.cpp
ipc/native/test/unittest/common/message_parcel_unittest.cpp
+3
-3
ipc/native/test/unittest/js/BUILD.gn
ipc/native/test/unittest/js/BUILD.gn
+2
-1
ipc/native/test/unittest/rust/client/src/main.rs
ipc/native/test/unittest/rust/client/src/main.rs
+15
-2
ipc/native/test/unittest/rust/server/src/main.rs
ipc/native/test/unittest/rust/server/src/main.rs
+2
-2
services/dbinder/dbinder_service/include/dbinder_remote_listener.h
...dbinder/dbinder_service/include/dbinder_remote_listener.h
+1
-1
services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp
...er/dbinder_service/src/socket/dbinder_remote_listener.cpp
+14
-26
未找到文件。
README_zh.md
浏览文件 @
d30c80ff
...
@@ -17,7 +17,7 @@ IPC(Inter-Process Communication)与RPC(Remote Procedure Call)机制用
...
@@ -17,7 +17,7 @@ IPC(Inter-Process Communication)与RPC(Remote Procedure Call)机制用
## 系统架构<a name="section1950291414611"></a>
## 系统架构<a name="section1950291414611"></a>
**图 1**
IPC通信机制架构图
<a
name=
"fig312319321710"
></a>
**图 1**
IPC通信机制架构图
<a
name=
"fig312319321710"
></a>
![](
figures/ipc-architecture.png
"IPC通信机制架构图"
)
![](
figures/ipc-architecture.png
"IPC通信机制架构图"
)
## 目录<a name="section161941989596"></a>
## 目录<a name="section161941989596"></a>
...
@@ -68,6 +68,12 @@ external_deps = [
...
@@ -68,6 +68,12 @@ external_deps = [
]
]
```
```
**Rust侧编译依赖**
```
external_deps = [ "ipc:ipc_rust" ]
```
## 说明<a name="section1312121216216"></a>
## 说明<a name="section1312121216216"></a>
**JS侧实现跨进程通信基本步骤:**
**JS侧实现跨进程通信基本步骤:**
...
@@ -102,6 +108,34 @@ external_deps = [
...
@@ -102,6 +108,34 @@ external_deps = [
6.
通过SA的标识和设备NetworkId,从SAMgr获取Proxy,通过Proxy实现与Stub的跨进程通信。
6.
通过SA的标识和设备NetworkId,从SAMgr获取Proxy,通过Proxy实现与Stub的跨进程通信。
**Rust侧实现跨进程通信的基本步骤:**
1.
定义接口
继承IPC框架的IRemoteBroker特征,定义一个业务自己的trait,在此trait中定义proxy和stub之间的IPC方法。
2.
定义服务
和c++ 定义的服务类似,Rust服务相关的类型有两个;
1)由业务提供名字,通过宏define_remote_object定义。
2)由业务定义,框架不关心其内容,只要求其必须实现步骤1中定义的接口trait。
3.
定义代理
代理的定义由业务提供名字,通过宏define_remote_object定义代理的类型。
4.
创建并注册服务
服务定义完成后,只有注册到samgr后,其他进程才能获取该服务的代理,完成和该服务的通信。
5.
获取代理
通过向samgr发起请求,可以获取到指定服务的代理对象,之后便可以调用该代理对象的IPC方法实现和服务的通信。
6.
测试服务能力
### 接口说明<a name="section1551164914237"></a>
### 接口说明<a name="section1551164914237"></a>
**表 1**
JS侧IPC关键API
**表 1**
JS侧IPC关键API
...
@@ -160,10 +194,10 @@ external_deps = [
...
@@ -160,10 +194,10 @@ external_deps = [
```
```
import rpc from "@ohos.rpc"
import rpc from "@ohos.rpc"
let proxy = null
let proxy = null
let connectId = null
let connectId = null
// 单个设备
// 单个设备
let want = {
let want = {
// 包名和组件名写实际的值
// 包名和组件名写实际的值
...
@@ -181,7 +215,7 @@ external_deps = [
...
@@ -181,7 +215,7 @@ external_deps = [
}
}
}
}
connectId = globalThis.context.connectServiceExtensionAbility(want, connect)
connectId = globalThis.context.connectServiceExtensionAbility(want, connect)
// 如果是跨设备绑定,可以使用deviceManager获取目标设备NetworkId
// 如果是跨设备绑定,可以使用deviceManager获取目标设备NetworkId
import deviceManager from '@ohos.distributedHardware.deviceManager'
import deviceManager from '@ohos.distributedHardware.deviceManager'
function deviceManagerCallback(deviceManager) {
function deviceManagerCallback(deviceManager) {
...
@@ -198,9 +232,9 @@ external_deps = [
...
@@ -198,9 +232,9 @@ external_deps = [
// 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数
// 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数
deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback)
deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback)
```
```
2.
服务端被绑定的Ability在onConnect方法里返回继承自rpc.RemoteObject的对象,该对象需要实现onRemoteMessageRequest方法,处理客户端的请求。
2.
服务端被绑定的Ability在onConnect方法里返回继承自rpc.RemoteObject的对象,该对象需要实现onRemoteMessageRequest方法,处理客户端的请求。
```
```
...
@@ -220,7 +254,7 @@ external_deps = [
...
@@ -220,7 +254,7 @@ external_deps = [
}
}
```
```
3.
客户端在onConnect回调里接收到代理对象,调用sendRequest方法发起请求,在期约或者回调函数里接收结果。
3.
客户端在onConnect回调里接收到代理对象,调用sendRequest方法发起请求,在期约或者回调函数里接收结果。
...
@@ -246,7 +280,7 @@ external_deps = [
...
@@ -246,7 +280,7 @@ external_deps = [
data.reclaim()
data.reclaim()
reply.reclaim()
reply.reclaim()
})
})
// 使用回调函数
// 使用回调函数
function sendRequestCallback(result) {
function sendRequestCallback(result) {
try {
try {
...
@@ -267,7 +301,7 @@ external_deps = [
...
@@ -267,7 +301,7 @@ external_deps = [
proxy.sendRequest(1, data, reply, option, sendRequestCallback)
proxy.sendRequest(1, data, reply, option, sendRequestCallback)
```
```
4.
IPC通信结束后,使用UIAbility的接口断开连接。
4.
IPC通信结束后,使用UIAbility的接口断开连接。
...
@@ -280,7 +314,7 @@ external_deps = [
...
@@ -280,7 +314,7 @@ external_deps = [
})
})
```
```
**Native侧使用说明**
**Native侧使用说明**
...
@@ -298,7 +332,7 @@ external_deps = [
...
@@ -298,7 +332,7 @@ external_deps = [
};
};
```
```
2.
定义和实现服务端TestAbilityStub
2.
定义和实现服务端TestAbilityStub
...
@@ -310,11 +344,11 @@ external_deps = [
...
@@ -310,11 +344,11 @@ external_deps = [
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
int TestPingAbility(const std::u16string &dummy) override;
int TestPingAbility(const std::u16string &dummy) override;
};
};
int Test
Service
Stub::OnRemoteRequest(uint32_t code,
int Test
Ability
Stub::OnRemoteRequest(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
{
if (data.ReadInterfaceToken() != GetDescriptor()) { //校验是否为本服务的接口描述符,避免中继攻击
if (data.ReadInterfaceToken() != GetDescriptor()) { //
校验是否为本服务的接口描述符,避免中继攻击
return -1;
return -1;
}
}
switch (code) {
switch (code) {
...
@@ -330,7 +364,7 @@ external_deps = [
...
@@ -330,7 +364,7 @@ external_deps = [
}
}
```
```
3.
定义服务端业务函数具体实现类TestAbility
3.
定义服务端业务函数具体实现类TestAbility
...
@@ -339,13 +373,13 @@ external_deps = [
...
@@ -339,13 +373,13 @@ external_deps = [
public:
public:
int TestPingAbility(const std::u16string &dummy);
int TestPingAbility(const std::u16string &dummy);
}
}
int TestAbility::TestPingAbility(const std::u16string &dummy) {
int TestAbility::TestPingAbility(const std::u16string &dummy) {
return 0;
return 0;
}
}
```
```
4.
定义和实现客户端TestAbilityProxy
4.
定义和实现客户端TestAbilityProxy
...
@@ -359,16 +393,16 @@ external_deps = [
...
@@ -359,16 +393,16 @@ external_deps = [
private:
private:
static inline BrokerDelegator<TestAbilityProxy> delegator_; // 方便使用iface_cast宏
static inline BrokerDelegator<TestAbilityProxy> delegator_; // 方便使用iface_cast宏
}
}
TestAbilityProxy::TestAbilityProxy(const sptr<IRemoteObject> &impl)
TestAbilityProxy::TestAbilityProxy(const sptr<IRemoteObject> &impl)
: IRemoteProxy<ITestAbility>(impl)
: IRemoteProxy<ITestAbility>(impl)
{
{
}
}
int TestAbilityProxy::TestPingService(const std::u16string &dummy) {
int TestAbilityProxy::TestPingService(const std::u16string &dummy) {
MessageOption option;
MessageOption option;
MessageParcel dataParcel, replyParcel;
MessageParcel dataParcel, replyParcel;
if(!dataParcel.WriteInterfaceToken(GetDescriptor())) { //所有对外接口的proxy实现都要写入接口描述符,用于stub端检验
if(!dataParcel.WriteInterfaceToken(GetDescriptor())) { //
所有对外接口的proxy实现都要写入接口描述符,用于stub端检验
return -1;
return -1;
}
}
if(!dataParcel.WriteString16(dummy)) {
if(!dataParcel.WriteString16(dummy)) {
...
@@ -380,7 +414,7 @@ external_deps = [
...
@@ -380,7 +414,7 @@ external_deps = [
}
}
```
```
5.
同步调用与异步调用
5.
同步调用与异步调用
...
@@ -393,7 +427,7 @@ external_deps = [
...
@@ -393,7 +427,7 @@ external_deps = [
option.setFlags(option.TF_ASYNC);
option.setFlags(option.TF_ASYNC);
```
```
6.
SA注册与启动
6.
SA注册与启动
...
@@ -403,7 +437,7 @@ external_deps = [
...
@@ -403,7 +437,7 @@ external_deps = [
// 注册到本设备内
// 注册到本设备内
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
samgr->AddSystemAbility(said, new TestAbility());
samgr->AddSystemAbility(said, new TestAbility());
// 在组网场景下,会被同步到其他设备上
// 在组网场景下,会被同步到其他设备上
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
ISystemAbilityManager::SAExtraProp saExtra;
ISystemAbilityManager::SAExtraProp saExtra;
...
@@ -411,7 +445,7 @@ external_deps = [
...
@@ -411,7 +445,7 @@ external_deps = [
int result = samgr->AddSystemAbility(said, new TestAbility(), saExtra);
int result = samgr->AddSystemAbility(said, new TestAbility(), saExtra);
```
```
7.
SA获取与调用
7.
SA获取与调用
...
@@ -422,14 +456,308 @@ external_deps = [
...
@@ -422,14 +456,308 @@ external_deps = [
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(said);
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(said);
sptr<ITestAbility> testAbility = iface_cast<ITestAbility>(remoteObject); // 使用iface_cast宏转换成具体类型
sptr<ITestAbility> testAbility = iface_cast<ITestAbility>(remoteObject); // 使用iface_cast宏转换成具体类型
// 获取其他设备注册的SA的Proxy
// 获取其他设备注册的SA的Proxy
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(sdid, deviceId); // deviceId是指定设备的标识符
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(sdid, deviceId); // deviceId是指定设备的标识符
sptr<TestAbilityProxy> proxy(new TestAbilityProxy(remoteObject)); // 直接构造具体Proxy
sptr<TestAbilityProxy> proxy(new TestAbilityProxy(remoteObject)); // 直接构造具体Proxy
```
```
**Rust侧使用说明**
以下为CALCULATOR服务的完整开发步骤。
1.
定义接口
继承IPC框架IRemoteBroker特征,定义一个业务自己的trait,该trait中定义proxy和stub之间的IPC方法。示例如下定义了ICalc trait:
```
/// Function between proxy and stub of ICalcService
pub trait ICalc: IRemoteBroker {
/// Calc add num1 + num2
fn add(&self, num1: i32, num2: i32) -> IpcResult<i32>;
/// Calc sub num1 + num2
fn sub(&self, num1: i32, num2: i32) -> IpcResult<i32>;
/// Calc mul num1 + num2
fn mul(&self, num1: i32, num2: i32) -> IpcResult<i32>;
/// Calc div num1 + num2
fn div(&self, num1: i32, num2: i32) -> IpcResult<i32>;
}
```
1.
1 定义枚举ICalcCode
ICalcCode枚举中的变体表示calculator服务的不同功能。当然这一步不是必须的,但是为了提高代码的可读性,建议按照如下方法为每一个IPC方法定义code,示例如下:
```
/// Function code of ICalcService
pub enum ICalcCode {
/// add
CodeAdd = FIRST_CALL_TRANSACTION, // 由IPC框架定义,值为1,建议业务使用该值作为第一个IPC方法的code
/// sub
CodeSub,
/// mul
CodeMul,
/// div
CodeDiv,
}
```
1.
2 ICalCode转换
ICalCode实现TryFrom trait,可以实现u32类型到CalCode枚举类型的转换。
```
impl TryFrom<u32> for ICalcCode {
type Error = IpcStatusCode;
fn try_from(code: u32) -> IpcResult<Self> {
match code {
_ if code == ICalcCode::CodeAdd as u32 => Ok(ICalcCode::CodeAdd),
_ if code == ICalcCode::CodeSub as u32 => Ok(ICalcCode::CodeSub),
_ if code == ICalcCode::CodeMul as u32 => Ok(ICalcCode::CodeMul),
_ if code == ICalcCode::CodeDiv as u32 => Ok(ICalcCode::CodeDiv),
_ => Err(IpcStatusCode::Failed),
}
}
}
```
2.
定义服务
和c++ 定义的服务类似,Rust服务相关的类型有两个:
1)由业务提供名字,通过宏define_remote_object!定义,如本例中的CalcStub。
2)由业务定义,框架不关心其内容,只要求其必须实现步骤1中定义的接口trait,如本例中的CalcService。
2.
1 定义CalcService服务
CalcService的定义如下所示,实现了ICalc和IRemoteBroker特征,服务中没有任何成员,如有需要可以根据业务需要进行定义。
```
/// example.calc.ipc.ICalcService type
pub struct CalcService;
// 实现ICalc特征
impl ICalc for CalcService {
fn add(&self, num1: i32, num2: i32) -> IpcResult<i32> {
Ok(add(&num1, &num2))
}
fn sub(&self, num1: i32, num2: i32) -> IpcResult<i32> {
Ok(sub(&num1, &num2))
}
fn mul(&self, num1: i32, num2: i32) -> IpcResult<i32> {
Ok(mul(&num1, &num2))
}
fn div(&self, num1: i32, num2: i32) -> IpcResult<i32> {
Ok(div(&num1, &num2))
}
}
// 实现IRemoteBroker特征
impl IRemoteBroker for CalcService {}
/// add num1 + num2
pub fn add(num1: &i32, num2: &i32) -> i32 {
num1 + num2
}
/// sub num1 + num2
pub fn sub(num1: &i32, num2: &i32) -> i32 {
num1 - num2
}
/// mul num1 + num2
pub fn mul(num1: &i32, num2: &i32) -> i32 {
num1 * num2
}
/// div num1 + num2
pub fn div(num1: &i32, num2: &i32) -> i32 {
match num2 {
0 => {
println!("Zero cannot be divided");
-1
},
_ => num1 / num2,
}
}
```
2.
2 实现on_icalc_remote_request()方法
当服务收到IPC请求,IPC框架会回调该方法,业务在该方法中完成如下处理:
1)完成参数的解析。
2)调用具体的服务IPC方法。
3)将处理结果写会reply。
示例代码如下:
```
fn on_icalc_remote_request(stub: &dyn ICalc, code: u32, data: &BorrowedMsgParcel,
reply: &mut BorrowedMsgParcel) -> IpcResult<()> {
match code.try_into()? {
ICalcCode::CodeAdd => {
let num1: i32 = data.read().expect("Failed to read num1 in addition operation");
let num2: i32 = data.read().expect("Failed to read num2 in addition operation");
let ret = stub.add(num1, num2)?;
reply.write(&ret)?;
Ok(())
}
ICalcCode::CodeSub => {
let num1: i32 = data.read().expect("Failed to read num1 in subtraction operation");
let num2: i32 = data.read().expect("Failed to read num1 in subtraction operation");
let ret = stub.sub(num1, num2)?;
reply.write(&ret)?;
Ok(())
}
ICalcCode::CodeMul => {
let num1: i32 = data.read().expect("Failed to read num1 in multiplication operation");
let num2: i32 = data.read().expect("Failed to read num1 in multiplication operation");
let ret = stub.mul(num1, num2)?;
reply.write(&ret)?;
Ok(())
}
ICalcCode::CodeDiv => {
let num1: i32 = data.read().expect("Failed to read num1 in division operation");
let num2: i32 = data.read().expect("Failed to read num1 in division operation");
let ret = stub.div(num1, num2)?;
reply.write(&ret)?;
Ok(())
}
}
}
```
3.
定义代理
代理的定义由业务提供名字,通过宏define_remote_object定义代理的类型,业务需要为代理实现ICalc。示例如下:
```
impl ICalc for CalcProxy {
fn add(&self, num1: i32, num2: i32) -> IpcResult<i32> {
let mut data = MsgParcel::new().expect("MsgParcel should success");
data.write(&num1)?;
data.write(&num2)?;
let reply = self.remote.send_request(ICalcCode::CodeAdd as u32,
&data, false)?;
let ret: i32 = reply.read().expect("need reply i32");
Ok(ret)
}
fn sub(&self, num1: i32, num2: i32) -> IpcResult<i32> {
let mut data = MsgParcel::new().expect("MsgParcel should success");
data.write(&num1)?;
data.write(&num2)?;
let reply = self.remote.send_request(ICalcCode::CodeSub as u32,
&data, false)?;
let ret: i32 = reply.read().expect("need reply i32");
Ok(ret)
}
fn mul(&self, num1: i32, num2: i32) -> IpcResult<i32> {
let mut data = MsgParcel::new().expect("MsgParcel should success");
data.write(&num1)?;
data.write(&num2)?;
let reply = self.remote.send_request(ICalcCode::CodeMul as u32,
&data, false)?;
let ret: i32 = reply.read().expect("need reply i32");
Ok(ret)
}
fn div(&self, num1: i32, num2: i32) -> IpcResult<i32> {
let mut data = MsgParcel::new().expect("MsgParcel should success");
data.write(&num1)?;
data.write(&num2)?;
let reply = self.remote.send_request(ICalcCode::CodeDiv as u32,
&data, false)?;
let ret: i32 = reply.read().expect("need reply i32");
Ok(ret)
}
}
```
上述对象最终通过宏define_remote_object调用,将业务定义的类型和IPC框架进行结合,宏define_remote_object提供了如下几个关键信息:
1)服务的接口特征ICalc。
2)服务的描述符为“example.calc.ipc.ICalcService”。
3)Rust服务类型名为CalcStub。
4)服务处理IPC请求的入口方法为on_icalc_remote_request。
5)代理类型为CalcProxy。
示例代码如下:
```
define_remote_object!(
ICalc["example.calc.ipc.ICalcService"] {
stub: CalcStub(on_icalc_remote_request),
proxy: CalcProxy,
}
);
```
4.
创建并注册服务
服务定义完成后,只有注册到samgr后,其他进程才能获取该服务的代理,然后完成和该服务的通信。示例代码如下:
```
fn main() {
init_access_token();
// 创建服务对象,最终的服务对象为CalcStub
let service = CalcStub::new_remote_stub(CalcService).expect("create CalcService success");
// 向samgr注册服务
add_service(&service.as_object().expect("get ICalc service failed"),
EXAMPLE_IPC_CALC_SERVICE_ID).expect("add server to samgr failed");
println!("join to ipc work thread");
// 将主线程转换为IPC线程,至此服务所在进程陷入循环
join_work_thread();
}
```
注意:add_service为IPC 框架提供的临时调试接口,该接口应该由samgr模块提供。
5.
获取代理
通过向samgr发起请求,可以获取到指定服务的代理对象,之后便可以调用该代理对象的IPC方法实现和服务的通信。示例代码如下:
```
fn get_calc_service() -> RemoteObjRef<dyn ICalc>
{
let object = get_service(EXAMPLE_IPC_CALC_SERVICE_ID).expect("get icalc service failed");
let remote = <dyn ICalc as FromRemoteObj>::try_from(object);
let remote = match remote {
Ok(x) => x,
Err(error) => {
println!("convert RemoteObj to CalcProxy failed: {}", error);
panic!();
}
};
remote
}
```
注意:示例中的get_service()为IPC框架提供的临时接口,该接口由samgr模块提供。
6.
测试Calculartor服务能力
当测试用例Calculator_Ability pass表示CalcService 服务能力ok。
```
#[test]
fn calculator_ability() {
let remote = get_calc_service();
// add
let ret = remote.add(5, 5).expect("add failed");
assert_eq!(ret, 10);
// sub
let ret = remote.sub(5, 5).expect("sub failed");
assert_eq!(ret, 0);
// mul
let ret = remote.mul(5, 5).expect("mul failed");
assert_eq!(ret, 25);
// div
let ret = remote.div(5, 5).expect("div failed");
assert_eq!(ret, 1);
}
```
## 相关仓<a name="section1371113476307"></a>
## 相关仓<a name="section1371113476307"></a>
...
...
bundle.json
浏览文件 @
d30c80ff
...
@@ -37,7 +37,8 @@
...
@@ -37,7 +37,8 @@
"access_token"
,
"access_token"
,
"dsoftbus"
,
"dsoftbus"
,
"napi"
,
"napi"
,
"common"
"common"
,
"build_framework"
],
],
"third_party"
:
[
"third_party"
:
[
"libuv"
,
"libuv"
,
...
@@ -116,6 +117,15 @@
...
@@ -116,6 +117,15 @@
"header_files"
:
[],
"header_files"
:
[],
"header_base"
:
[]
"header_base"
:
[]
}
}
},
{
"name"
:
"//foundation/communication/ipc/interfaces/kits/js/napi:ipc_js"
,
"header"
:
{
"header_files"
:
[
"napi_remote_object.h"
],
"header_base"
:
"//foundation/communication/ipc/interfaces/innerkits/ipc_napi_common/include"
}
}
}
],
],
"test"
:
[
"test"
:
[
...
...
interfaces/innerkits/rust/src/ipc/remote_obj.rs
浏览文件 @
d30c80ff
...
@@ -21,7 +21,7 @@ use crate::{
...
@@ -21,7 +21,7 @@ use crate::{
MsgParcel
,
BorrowedMsgParcel
,
AsRawPtr
,
IpcStatusCode
,
MsgParcel
,
BorrowedMsgParcel
,
AsRawPtr
,
IpcStatusCode
,
parcel
::
vec_u16_to_string
,
parse_status_code
,
parcel
::
vec_u16_to_string
,
parse_status_code
,
};
};
use
crate
::
ipc_binding
::{
CRemoteObject
,
CDeathRecipient
};
use
crate
::
ipc_binding
::{
CRemoteObject
,
CDeathRecipient
,
CIRemoteObject
};
use
crate
::
parcel
::
parcelable
::{
Serialize
,
Deserialize
,
allocate_vec_with_buffer
};
use
crate
::
parcel
::
parcelable
::{
Serialize
,
Deserialize
,
allocate_vec_with_buffer
};
use
std
::
ffi
::{
c_void
,
CString
,
c_char
};
use
std
::
ffi
::{
c_void
,
CString
,
c_char
};
use
crate
::
String16
;
use
crate
::
String16
;
...
@@ -59,6 +59,26 @@ impl RemoteObj {
...
@@ -59,6 +59,26 @@ impl RemoteObj {
pub
unsafe
fn
as_inner
(
&
self
)
->
*
mut
CRemoteObject
{
pub
unsafe
fn
as_inner
(
&
self
)
->
*
mut
CRemoteObject
{
self
.0
.as_ptr
()
self
.0
.as_ptr
()
}
}
/// Convert an `RemoteObj` by `CIRemoteObject` pointer.
pub
fn
from_raw_ciremoteobj
(
obj
:
*
mut
CIRemoteObject
)
->
Option
<
RemoteObj
>
{
if
obj
.is_null
()
{
None
}
else
{
// SAFETY: he returned CIRemoteObject may be a null pointer
unsafe
{
let
sa
=
ipc_binding
::
CreateCRemoteObject
(
obj
as
*
mut
_
as
*
mut
c_void
);
RemoteObj
::
from_raw
(
sa
)
}
}
}
/// Extract a raw `CIRemoteObject` pointer from this wrapper.
/// # Safety
/// The returned CIRemoteObject may be a null pointer
pub
unsafe
fn
as_raw_ciremoteobj
(
&
self
)
->
*
mut
CIRemoteObject
{
ipc_binding
::
GetCIRemoteObject
(
self
.0
.as_ptr
())
as
*
mut
CIRemoteObject
}
}
}
impl
IRemoteObj
for
RemoteObj
{
impl
IRemoteObj
for
RemoteObj
{
...
...
interfaces/innerkits/rust/src/ipc_binding.rs
浏览文件 @
d30c80ff
...
@@ -17,11 +17,21 @@
...
@@ -17,11 +17,21 @@
use
std
::
ffi
::{
c_char
,
c_void
,
c_ulong
};
use
std
::
ffi
::{
c_char
,
c_void
,
c_ulong
};
/// CRemoteObject is a member of RemoteObject,
/// RemoteObject always contained a native CRemoteObject pointer.
#[repr(C)]
#[repr(C)]
pub
struct
CRemoteObject
{
pub
struct
CRemoteObject
{
_
private
:
[
u8
;
0
],
_
private
:
[
u8
;
0
],
}
}
/// CIRemoteObject is a member of CRemoteObject,
/// CRemoteObject always contained a native CIRemoteObject pointer.
/// Please refer to the CRemoteObject object on side c
#[repr(C)]
pub
struct
CIRemoteObject
{
_
private
:
[
u8
;
0
],
}
#[repr(C)]
#[repr(C)]
pub
struct
CDeathRecipient
{
pub
struct
CDeathRecipient
{
_
private
:
[
u8
;
0
],
_
private
:
[
u8
;
0
],
...
@@ -135,6 +145,8 @@ pub type OnCParcelReadElement = unsafe extern "C" fn (
...
@@ -135,6 +145,8 @@ pub type OnCParcelReadElement = unsafe extern "C" fn (
// C interface for IPC core object
// C interface for IPC core object
extern
"C"
{
extern
"C"
{
pub
fn
CreateCRemoteObject
(
object
:
*
mut
c_void
)
->
*
mut
CRemoteObject
;
pub
fn
GetCIRemoteObject
(
object
:
*
mut
CRemoteObject
)
->
*
mut
c_void
;
pub
fn
CreateRemoteStub
(
descripor
:
*
const
c_char
,
on_remote_request
:
OnRemoteRequest
,
pub
fn
CreateRemoteStub
(
descripor
:
*
const
c_char
,
on_remote_request
:
OnRemoteRequest
,
on_remote_object_destroy
:
OnRemoteObjectDestroy
,
on_remote_object_destroy
:
OnRemoteObjectDestroy
,
user_data
:
*
const
c_void
,
on_remote_dump
:
OnRemoteDump
)
->
*
mut
CRemoteObject
;
user_data
:
*
const
c_void
,
on_remote_dump
:
OnRemoteDump
)
->
*
mut
CRemoteObject
;
...
...
interfaces/innerkits/rust/src/lib.rs
浏览文件 @
d30c80ff
...
@@ -48,6 +48,8 @@ pub use crate::process::{
...
@@ -48,6 +48,8 @@ pub use crate::process::{
get_local_device_id
,
get_calling_device_id
,
reset_calling_identity
,
get_local_device_id
,
get_calling_device_id
,
reset_calling_identity
,
};
};
pub
use
crate
::
ipc_binding
::{
CRemoteObject
,
CIRemoteObject
};
/// First request code available for user IPC request(inclusive)
/// First request code available for user IPC request(inclusive)
pub
const
FIRST_CALL_TRANSACTION
:
isize
=
0x00000001
;
pub
const
FIRST_CALL_TRANSACTION
:
isize
=
0x00000001
;
/// Last request code available for user IPC request(inclusive)
/// Last request code available for user IPC request(inclusive)
...
...
interfaces/kits/bundle.json
已删除
100644 → 0
浏览文件 @
c1dea793
{
"name"
:
"@openharmony/ipc_js"
,
"version"
:
"3.1.0"
,
"description"
:
"ipc_js"
,
"publishAs"
:
"code-segment"
,
"scripts"
:
{
"install"
:
"DEST_PATH=${DEP_BUNDLE_BASE}/foundation/communication/ipc_js && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
},
"author"
:
{},
"repository"
:
""
,
"license"
:
"Apache License 2.0"
,
"segment"
:
{
"destPath"
:
"foundation/communication/ipc/interfaces/kits"
},
"component"
:
{
"name"
:
"ipc_js"
,
"subsystem"
:
"communication"
,
"adapted_system_type"
:
[
"standard"
],
"features"
:
[],
"rom"
:
"500KB"
,
"ram"
:
"100KB"
,
"deps"
:
{
"components"
:
[
"napi"
,
"c_utils"
,
"hitrace"
,
"hilog"
,
"ipc"
],
"third_party"
:
[
"libuv"
,
"bounds_checking_function"
]
},
"build"
:
{
"sub_component"
:
[
"//foundation/communication/ipc/interfaces/kits/js/napi:rpc"
],
"inner_kits"
:
[
{
"name"
:
"//foundation/communication/ipc/interfaces/kits/js/napi:rpc"
,
"header"
:
{
"header_files"
:
[
"napi_remote_object.h"
],
"header_base"
:
"//foundation/communication/ipc/interfaces/innerkits/ipc_napi_common/include"
}
}
],
"test"
:
[
]
}
}
}
\ No newline at end of file
interfaces/kits/js/napi/BUILD.gn
浏览文件 @
d30c80ff
...
@@ -12,50 +12,59 @@
...
@@ -12,50 +12,59 @@
# limitations under the License.
# limitations under the License.
import("//build/ohos.gni")
import("//build/ohos.gni")
if (support_jsapi) {
SUBSYSTEM_DIR = "//foundation/communication/ipc"
SUBSYSTEM_DIR = "//foundation/communication/ipc"
config("rpc_public_config") {
visibility = [ ":*" ]
include_dirs = [ "$SUBSYSTEM_DIR/ipc/native/src/napi/include" ]
}
ohos_shared_library("rpc") {
sanitize = {
integer_overflow = true
}
version_script = "librpc_map"
include_dirs = [
"$SUBSYSTEM_DIR/utils/include",
"//foundation/arkui/napi/interfaces/kits",
"//foundation/arkui/napi/native_engine",
"//utils/system/safwk/native/include",
"$SUBSYSTEM_DIR/ipc/native/c/adapter/include",
"$SUBSYSTEM_DIR/ipc/native/c/adapter/access_token/include",
"$SUBSYSTEM_DIR/ipc/native/src/napi_common/include",
]
public_configs = [ ":rpc_public_config" ]
sources = [
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_ipc_skeleton.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_message_option.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_remote_proxy.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_rpc_native_module.cpp",
]
deps = [
"$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core:ipc_core",
"$SUBSYSTEM_DIR/interfaces/innerkits/ipc_napi_common:ipc_napi_common",
"//third_party/libuv:uv",
]
config("rpc_public_config") {
external_deps = [
visibility = [ ":*" ]
"c_utils:utils",
include_dirs = [ "$SUBSYSTEM_DIR/ipc/native/src/napi/include" ]
"hilog:libhilog",
"hitrace:hitrace_meter",
"napi:ace_napi",
]
relative_install_dir = "module"
subsystem_name = "communication"
part_name = "ipc"
}
}
}
ohos_shared_library("rpc
") {
group("ipc_js
") {
sanitize =
{
if (support_jsapi)
{
integer_overflow = true
deps = [ ":rpc" ]
}
}
version_script = "librpc_map"
include_dirs = [
"$SUBSYSTEM_DIR/utils/include",
"//foundation/arkui/napi/interfaces/kits",
"//foundation/arkui/napi/native_engine",
"//utils/system/safwk/native/include",
"$SUBSYSTEM_DIR/ipc/native/c/adapter/include",
"$SUBSYSTEM_DIR/ipc/native/c/adapter/access_token/include",
"$SUBSYSTEM_DIR/ipc/native/src/napi_common/include",
]
public_configs = [ ":rpc_public_config" ]
sources = [
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_ipc_skeleton.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_message_option.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_remote_proxy.cpp",
"$SUBSYSTEM_DIR/ipc/native/src/napi/src/napi_rpc_native_module.cpp",
]
deps = [ "//third_party/libuv:uv" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",
"ipc:ipc_napi_common",
"napi:ace_napi",
]
relative_install_dir = "module"
subsystem_name = "communication"
part_name = "ipc_js"
}
}
ipc/native/src/c_wrapper/include/c_remote_object.h
浏览文件 @
d30c80ff
...
@@ -30,7 +30,7 @@ struct CDeathRecipient;
...
@@ -30,7 +30,7 @@ struct CDeathRecipient;
typedef
struct
CDeathRecipient
CDeathRecipient
;
typedef
struct
CDeathRecipient
CDeathRecipient
;
// Callback as remote stub
// Callback as remote stub
typedef
int
(
*
OnRemoteRequestCb
)(
const
void
*
userData
,
int
code
,
typedef
int
(
*
OnRemoteRequestCb
)(
const
void
*
userData
,
int
code
,
const
CParcel
*
data
,
CParcel
*
reply
);
const
CParcel
*
data
,
CParcel
*
reply
);
typedef
int
(
*
OnRemoteDumpCb
)(
const
void
*
userData
,
const
CParcel
*
data
);
typedef
int
(
*
OnRemoteDumpCb
)(
const
void
*
userData
,
const
CParcel
*
data
);
typedef
void
(
*
OnRemoteObjectDestroyCb
)(
const
void
*
userData
);
typedef
void
(
*
OnRemoteObjectDestroyCb
)(
const
void
*
userData
);
...
@@ -40,6 +40,8 @@ typedef void (*OnDeathRecipientDestroyCb)(const void *userData);
...
@@ -40,6 +40,8 @@ typedef void (*OnDeathRecipientDestroyCb)(const void *userData);
typedef
bool
(
*
On16BytesAllocator
)(
void
*
stringData
,
uint16_t
**
buffer
,
int32_t
len
);
typedef
bool
(
*
On16BytesAllocator
)(
void
*
stringData
,
uint16_t
**
buffer
,
int32_t
len
);
CRemoteObject
*
CreateCRemoteObject
(
void
*
obj
);
void
*
GetCIRemoteObject
(
CRemoteObject
*
obj
);
CRemoteObject
*
CreateRemoteStub
(
const
char
*
desc
,
OnRemoteRequestCb
callback
,
CRemoteObject
*
CreateRemoteStub
(
const
char
*
desc
,
OnRemoteRequestCb
callback
,
OnRemoteObjectDestroyCb
destroy
,
const
void
*
userData
,
OnRemoteDumpCb
dumpCallback
);
OnRemoteObjectDestroyCb
destroy
,
const
void
*
userData
,
OnRemoteDumpCb
dumpCallback
);
...
...
ipc/native/src/c_wrapper/source/c_remote_object.cpp
浏览文件 @
d30c80ff
...
@@ -289,4 +289,37 @@ bool GetInterfaceDescriptor(CRemoteObject *object, void *value, On16BytesAllocat
...
@@ -289,4 +289,37 @@ bool GetInterfaceDescriptor(CRemoteObject *object, void *value, On16BytesAllocat
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
CRemoteObject
*
CreateCRemoteObject
(
void
*
obj
)
{
if
(
obj
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"%{public}s: recipient is null
\n
"
,
__func__
);
return
nullptr
;
}
CRemoteObject
*
holder
=
new
(
std
::
nothrow
)
CRemoteObjectHolder
();
if
(
holder
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"%{public}s: create proxy holder failed
\n
"
,
__func__
);
return
nullptr
;
}
sptr
<
IRemoteObject
>
sa
=
reinterpret_cast
<
IRemoteObject
*
>
(
obj
);
holder
->
IncStrongRef
(
nullptr
);
holder
->
remote_
=
sa
;
return
holder
;
}
void
*
GetCIRemoteObject
(
CRemoteObject
*
obj
)
{
if
(
!
IsValidRemoteObject
(
obj
,
__func__
))
{
ZLOGE
(
LOG_LABEL
,
"%{public}s: recipient is null
\n
"
,
__func__
);
return
nullptr
;
}
if
(
obj
->
remote_
==
nullptr
)
{
ZLOGI
(
LOG_LABEL
,
"%{public}s: The pointer inside CRemoteObject is a null pointer
\n
"
,
__func__
);
return
nullptr
;
}
return
obj
->
remote_
.
GetRefPtr
();
}
}
\ No newline at end of file
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
d30c80ff
...
@@ -325,6 +325,7 @@ bool IPCObjectProxy::AddDeathRecipient(const sptr<DeathRecipient> &recipient)
...
@@ -325,6 +325,7 @@ bool IPCObjectProxy::AddDeathRecipient(const sptr<DeathRecipient> &recipient)
#endif
#endif
return
false
;
return
false
;
}
}
ZLOGD
(
LABEL
,
"handle: %{public}u add deathrecipient"
,
handle_
);
#ifndef CONFIG_IPC_SINGLE
#ifndef CONFIG_IPC_SINGLE
if
(
proto_
==
IRemoteObject
::
IF_PROT_DATABUS
)
{
if
(
proto_
==
IRemoteObject
::
IF_PROT_DATABUS
)
{
if
(
!
AddDbinderDeathRecipient
())
{
if
(
!
AddDbinderDeathRecipient
())
{
...
@@ -375,6 +376,7 @@ bool IPCObjectProxy::RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
...
@@ -375,6 +376,7 @@ bool IPCObjectProxy::RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
dbinderStatus
=
RemoveDbinderDeathRecipient
();
dbinderStatus
=
RemoveDbinderDeathRecipient
();
}
}
#endif
#endif
ZLOGD
(
LABEL
,
"handle: %{public}u remove deathrecipient, res: %{public}d"
,
handle_
,
status
);
return
status
&&
dbinderStatus
;
return
status
&&
dbinderStatus
;
}
}
return
recipientErased
;
return
recipientErased
;
...
...
ipc/native/src/core/source/message_parcel.cpp
浏览文件 @
d30c80ff
...
@@ -238,11 +238,19 @@ int MessageParcel::ReadFileDescriptor()
...
@@ -238,11 +238,19 @@ int MessageParcel::ReadFileDescriptor()
void
MessageParcel
::
ClearFileDescriptor
()
void
MessageParcel
::
ClearFileDescriptor
()
{
{
binder_size_t
*
object
=
reinterpret_cast
<
binder_size_t
*>
(
GetObjectOffsets
());
size_t
dataOffset
=
0
;
size_t
objectNum
=
GetOffsetsSize
();
binder_size_t
*
object
=
nullptr
;
uintptr_t
data
=
GetData
();
const
flat_binder_object
*
flat
=
nullptr
;
for
(
size_t
i
=
0
;
i
<
objectNum
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
GetOffsetsSize
();
i
++
)
{
const
flat_binder_object
*
flat
=
reinterpret_cast
<
flat_binder_object
*>
(
data
+
object
[
i
]);
object
=
reinterpret_cast
<
binder_size_t
*>
(
GetObjectOffsets
());
// offset + size
dataOffset
=
object
[
i
]
+
sizeof
(
flat_binder_object
);
if
(
dataOffset
>
GetDataSize
())
{
ZLOGE
(
LOG_LABEL
,
"object offset is overflow, dataOffset:%{public}zu, dataSize:%{public}zu"
,
dataOffset
,
GetDataSize
());
break
;
}
flat
=
reinterpret_cast
<
flat_binder_object
*>
(
GetData
()
+
object
[
i
]);
if
(
flat
->
hdr
.
type
==
BINDER_TYPE_FD
&&
flat
->
handle
>
0
)
{
if
(
flat
->
hdr
.
type
==
BINDER_TYPE_FD
&&
flat
->
handle
>
0
)
{
::
close
(
flat
->
handle
);
::
close
(
flat
->
handle
);
}
}
...
@@ -251,11 +259,19 @@ void MessageParcel::ClearFileDescriptor()
...
@@ -251,11 +259,19 @@ void MessageParcel::ClearFileDescriptor()
bool
MessageParcel
::
ContainFileDescriptors
()
const
bool
MessageParcel
::
ContainFileDescriptors
()
const
{
{
binder_size_t
*
object
=
reinterpret_cast
<
binder_size_t
*>
(
GetObjectOffsets
());
size_t
dataOffset
=
0
;
size_t
objectNum
=
GetOffsetsSize
();
binder_size_t
*
object
=
nullptr
;
uintptr_t
data
=
GetData
();
const
flat_binder_object
*
flat
=
nullptr
;
for
(
size_t
i
=
0
;
i
<
objectNum
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
GetOffsetsSize
();
i
++
)
{
const
flat_binder_object
*
flat
=
reinterpret_cast
<
flat_binder_object
*>
(
data
+
object
[
i
]);
object
=
reinterpret_cast
<
binder_size_t
*>
(
GetObjectOffsets
());
// offset + size
dataOffset
=
object
[
i
]
+
sizeof
(
flat_binder_object
);
if
(
dataOffset
>
GetDataSize
())
{
ZLOGE
(
LOG_LABEL
,
"object offset is overflow, dataOffset:%{public}zu, dataSize:%{public}zu"
,
dataOffset
,
GetDataSize
());
break
;
}
flat
=
reinterpret_cast
<
flat_binder_object
*>
(
GetData
()
+
object
[
i
]);
if
(
flat
->
hdr
.
type
==
BINDER_TYPE_FD
)
{
if
(
flat
->
hdr
.
type
==
BINDER_TYPE_FD
)
{
return
true
;
return
true
;
}
}
...
@@ -302,6 +318,7 @@ bool MessageParcel::WriteRawData(const void *data, size_t size)
...
@@ -302,6 +318,7 @@ bool MessageParcel::WriteRawData(const void *data, size_t size)
return
false
;
return
false
;
}
}
if
(
size
<=
MIN_RAWDATA_SIZE
)
{
if
(
size
<=
MIN_RAWDATA_SIZE
)
{
rawDataSize_
=
size
;
return
WriteUnpadBuffer
(
data
,
size
);
return
WriteUnpadBuffer
(
data
,
size
);
}
}
int
fd
=
AshmemCreate
(
"Parcel RawData"
,
size
);
int
fd
=
AshmemCreate
(
"Parcel RawData"
,
size
);
...
@@ -348,13 +365,15 @@ bool MessageParcel::RestoreRawData(std::shared_ptr<char> rawData, size_t size)
...
@@ -348,13 +365,15 @@ bool MessageParcel::RestoreRawData(std::shared_ptr<char> rawData, size_t size)
const
void
*
MessageParcel
::
ReadRawData
(
size_t
size
)
const
void
*
MessageParcel
::
ReadRawData
(
size_t
size
)
{
{
int32_t
bufferSize
=
ReadInt32
();
size_t
bufferSize
=
static_cast
<
size_t
>
(
ReadInt32
());
if
(
static_cast
<
unsigned
int
>
(
bufferSize
)
!=
size
)
{
if
(
bufferSize
!=
size
)
{
return
nullptr
;
ZLOGI
(
LOG_LABEL
,
"ReadRawData: the buffersize %{public}zu not equal the parameter size %{public}zu"
,
bufferSize
,
size
);
}
}
size_t
realReadSize
=
bufferSize
<
size
?
bufferSize
:
size
;
if
(
static_cast
<
unsigned
int
>
(
bufferSize
)
<=
MIN_RAWDATA_SIZE
)
{
if
(
bufferSize
<=
MIN_RAWDATA_SIZE
)
{
return
ReadUnpadBuffer
(
size
);
rawDataSize_
=
realReadSize
;
return
ReadUnpadBuffer
(
realReadSize
);
}
}
/* if rawDataFd_ == 0 means rawData is received from remote */
/* if rawDataFd_ == 0 means rawData is received from remote */
...
@@ -363,9 +382,11 @@ const void *MessageParcel::ReadRawData(size_t size)
...
@@ -363,9 +382,11 @@ const void *MessageParcel::ReadRawData(size_t size)
if
(
ReadFileDescriptor
())
{
if
(
ReadFileDescriptor
())
{
// do nothing
// do nothing
}
}
if
(
rawDataSize_
!=
size
)
{
if
(
rawDataSize_
!=
realReadSize
)
{
return
nullptr
;
ZLOGI
(
LOG_LABEL
,
"rawData is received from remote, the rawDataSize_ %{public}zu"
" not equal realReadSize %{public}zu"
,
rawDataSize_
,
realReadSize
);
}
}
rawDataSize_
=
realReadSize
;
return
rawData_
.
get
();
return
rawData_
.
get
();
}
}
int
fd
=
ReadFileDescriptor
();
int
fd
=
ReadFileDescriptor
();
...
@@ -375,17 +396,19 @@ const void *MessageParcel::ReadRawData(size_t size)
...
@@ -375,17 +396,19 @@ const void *MessageParcel::ReadRawData(size_t size)
readRawDataFd_
=
fd
;
readRawDataFd_
=
fd
;
int
ashmemSize
=
AshmemGetSize
(
fd
);
int
ashmemSize
=
AshmemGetSize
(
fd
);
if
(
ashmemSize
<
0
||
size_t
(
ashmemSize
)
<
s
ize
)
{
if
(
ashmemSize
<
0
||
size_t
(
ashmemSize
)
<
realReadS
ize
)
{
// Do not close fd here, which will be closed in MessageParcel's destructor.
// Do not close fd here, which will be closed in MessageParcel's destructor.
ZLOGE
(
LOG_LABEL
,
"ashmemSize %{public}d less than realReadSize %{public}zu"
,
ashmemSize
,
realReadSize
);
return
nullptr
;
return
nullptr
;
}
}
void
*
ptr
=
::
mmap
(
nullptr
,
s
ize
,
PROT_READ
,
MAP_SHARED
,
fd
,
0
);
void
*
ptr
=
::
mmap
(
nullptr
,
realReadS
ize
,
PROT_READ
,
MAP_SHARED
,
fd
,
0
);
if
(
ptr
==
MAP_FAILED
)
{
if
(
ptr
==
MAP_FAILED
)
{
// Do not close fd here, which will be closed in MessageParcel's destructor.
// Do not close fd here, which will be closed in MessageParcel's destructor.
return
nullptr
;
return
nullptr
;
}
}
kernelMappedRead_
=
ptr
;
kernelMappedRead_
=
ptr
;
rawDataSize_
=
s
ize
;
rawDataSize_
=
realReadS
ize
;
return
ptr
;
return
ptr
;
}
}
...
...
ipc/native/src/mock/include/dbinder_base_invoker.h
浏览文件 @
d30c80ff
...
@@ -96,6 +96,7 @@ public:
...
@@ -96,6 +96,7 @@ public:
virtual
int
CheckAndSetCallerInfo
(
uint32_t
listenFd
,
uint64_t
stubIndex
)
=
0
;
virtual
int
CheckAndSetCallerInfo
(
uint32_t
listenFd
,
uint64_t
stubIndex
)
=
0
;
virtual
int
OnSendRawData
(
std
::
shared_ptr
<
T
>
session
,
const
void
*
data
,
size_t
size
)
=
0
;
virtual
int
OnSendRawData
(
std
::
shared_ptr
<
T
>
session
,
const
void
*
data
,
size_t
size
)
=
0
;
bool
CheckTransactionData
(
const
dbinder_transaction_data
*
tr
)
const
;
bool
CheckTransactionData
(
const
dbinder_transaction_data
*
tr
)
const
;
std
::
mutex
&
GetObjectMutex
();
private:
private:
uint32_t
TranslateBinderType
(
flat_binder_object
*
binderObject
,
char
*
sessionOffset
,
std
::
shared_ptr
<
T
>
session
);
uint32_t
TranslateBinderType
(
flat_binder_object
*
binderObject
,
char
*
sessionOffset
,
std
::
shared_ptr
<
T
>
session
);
...
@@ -125,6 +126,9 @@ private:
...
@@ -125,6 +126,9 @@ private:
std
::
shared_ptr
<
ThreadProcessInfo
>
MakeThreadProcessInfo
(
uint32_t
handle
,
const
char
*
buffer
,
uint32_t
size
);
std
::
shared_ptr
<
ThreadProcessInfo
>
MakeThreadProcessInfo
(
uint32_t
handle
,
const
char
*
buffer
,
uint32_t
size
);
std
::
shared_ptr
<
ThreadMessageInfo
>
MakeThreadMessageInfo
(
uint32_t
handle
);
std
::
shared_ptr
<
ThreadMessageInfo
>
MakeThreadMessageInfo
(
uint32_t
handle
);
uint32_t
MakeRemoteHandle
(
std
::
shared_ptr
<
T
>
session
);
uint32_t
MakeRemoteHandle
(
std
::
shared_ptr
<
T
>
session
);
private:
std
::
mutex
objectMutex_
;
};
};
template
<
class
T
>
template
<
class
T
>
...
@@ -901,27 +905,32 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
...
@@ -901,27 +905,32 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
const
uint32_t
flags
=
tr
->
flags
;
const
uint32_t
flags
=
tr
->
flags
;
uint64_t
senderSeqNumber
=
tr
->
seqNumber
;
uint64_t
senderSeqNumber
=
tr
->
seqNumber
;
auto
*
stub
=
current
->
QueryStubByIndex
(
tr
->
cookie
);
int
error
=
ERR_NONE
;
if
(
stub
==
nullptr
)
{
{
ZLOGE
(
LOG_LABEL
,
"stubIndex is invalid"
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
objectMutex_
);
return
;
auto
*
stub
=
current
->
QueryStubByIndex
(
tr
->
cookie
);
}
if
(
stub
==
nullptr
)
{
if
(
!
IRemoteObjectTranslateWhenRcv
(
reinterpret_cast
<
char
*>
(
tr
->
buffer
),
tr
->
buffer_size
,
data
,
ZLOGE
(
LOG_LABEL
,
"stubIndex is invalid"
);
listenFd
,
nullptr
))
{
return
;
ZLOGE
(
LOG_LABEL
,
"translate object failed"
);
}
return
;
if
(
!
IRemoteObjectTranslateWhenRcv
(
reinterpret_cast
<
char
*>
(
tr
->
buffer
),
tr
->
buffer_size
,
data
,
}
listenFd
,
nullptr
))
{
ZLOGE
(
LOG_LABEL
,
"translate object failed"
);
return
;
}
auto
*
stubObject
=
reinterpret_cast
<
IPCObjectStub
*>
(
stub
);
auto
*
stubObject
=
reinterpret_cast
<
IPCObjectStub
*>
(
stub
);
MessageOption
option
;
MessageOption
option
;
option
.
SetFlags
(
flags
);
option
.
SetFlags
(
flags
);
// cannot use stub any more after SendRequest because this cmd may be
// cannot use stub any more after SendRequest because this cmd may be
// dbinder dec ref and thus stub will be destroyed
// dbinder dec ref and thus stub will be destroyed
int
error
=
stubObject
->
SendRequest
(
tr
->
code
,
data
,
reply
,
option
);
int
error
=
stubObject
->
SendRequest
(
tr
->
code
,
data
,
reply
,
option
);
if
(
error
!=
ERR_NONE
)
{
if
(
error
!=
ERR_NONE
)
{
ZLOGE
(
LOG_LABEL
,
"stub sendrequest failed, cmd: %{public}u, error: %{public}d"
,
tr
->
code
,
error
);
ZLOGE
(
LOG_LABEL
,
"stub sendrequest failed, cmd: %{public}u, error: %{public}d"
,
tr
->
code
,
error
);
// can not return;
// can not return;
}
}
}
if
(
data
.
GetRawData
()
!=
nullptr
)
{
if
(
data
.
GetRawData
()
!=
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"delete raw data in process skeleton, fd: %{public}u"
,
listenFd
);
ZLOGE
(
LOG_LABEL
,
"delete raw data in process skeleton, fd: %{public}u"
,
listenFd
);
current
->
DetachRawData
(
listenFd
);
current
->
DetachRawData
(
listenFd
);
...
@@ -1058,5 +1067,11 @@ template <class T> bool DBinderBaseInvoker<T>::CheckTransactionData(const dbinde
...
@@ -1058,5 +1067,11 @@ template <class T> bool DBinderBaseInvoker<T>::CheckTransactionData(const dbinde
return
true
;
return
true
;
}
}
template
<
class
T
>
std
::
mutex
&
DBinderBaseInvoker
<
T
>::
GetObjectMutex
()
{
return
objectMutex_
;
}
}
// namespace OHOS
}
// namespace OHOS
#endif // OHOS_IPC_DBINDER_BASE_INVOKER_H
#endif // OHOS_IPC_DBINDER_BASE_INVOKER_H
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
浏览文件 @
d30c80ff
...
@@ -547,6 +547,7 @@ bool DBinderDatabusInvoker::OnDatabusSessionServerSideClosed(std::shared_ptr<Ses
...
@@ -547,6 +547,7 @@ bool DBinderDatabusInvoker::OnDatabusSessionServerSideClosed(std::shared_ptr<Ses
// detach info whose listen fd equals the given one
// detach info whose listen fd equals the given one
std
::
list
<
uint64_t
>
stubIndexs
=
current
->
DetachAppInfoToStubIndex
(
session
->
GetPeerPid
(),
session
->
GetPeerUid
(),
std
::
list
<
uint64_t
>
stubIndexs
=
current
->
DetachAppInfoToStubIndex
(
session
->
GetPeerPid
(),
session
->
GetPeerUid
(),
tokenId
,
session
->
GetPeerDeviceId
(),
IPCProcessSkeleton
::
ConvertChannelID2Int
(
channelId
));
tokenId
,
session
->
GetPeerDeviceId
(),
IPCProcessSkeleton
::
ConvertChannelID2Int
(
channelId
));
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
GetObjectMutex
());
for
(
auto
it
=
stubIndexs
.
begin
();
it
!=
stubIndexs
.
end
();
it
++
)
{
for
(
auto
it
=
stubIndexs
.
begin
();
it
!=
stubIndexs
.
end
();
it
++
)
{
// note that we canont remove mapping from stub to index here because other session may still be used
// note that we canont remove mapping from stub to index here because other session may still be used
IRemoteObject
*
stub
=
current
->
QueryStubByIndex
(
*
it
);
IRemoteObject
*
stub
=
current
->
QueryStubByIndex
(
*
it
);
...
...
ipc/native/src/napi/src/napi_ipc_skeleton.cpp
浏览文件 @
d30c80ff
...
@@ -29,7 +29,8 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_IPC,
...
@@ -29,7 +29,8 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_IPC,
static
NapiError
napiErr
;
static
NapiError
napiErr
;
static
const
size_t
ARGV_INDEX_0
=
0
;
static
const
size_t
ARGV_INDEX_0
=
0
;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_LENGTH_1
=
1
;
static
constexpr
size_t
UINT64_STRING_MAX_LEN
=
20
;
static
constexpr
size_t
UINT64_STRING_MAX_LEN
=
20
;
napi_value
NAPI_IPCSkeleton_getContextObject
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPI_IPCSkeleton_getContextObject
(
napi_env
env
,
napi_callback_info
info
)
...
@@ -136,17 +137,17 @@ napi_value NAPI_IPCSkeleton_isLocalCalling(napi_env env, napi_callback_info info
...
@@ -136,17 +137,17 @@ napi_value NAPI_IPCSkeleton_isLocalCalling(napi_env env, napi_callback_info info
napi_value
NAPI_IPCSkeleton_flushCommands
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPI_IPCSkeleton_flushCommands
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
argv
[
0
]);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
argv
[
ARGV_INDEX_
0
]);
int32_t
result
=
IPCSkeleton
::
FlushCommands
(
target
);
int32_t
result
=
IPCSkeleton
::
FlushCommands
(
target
);
napi_value
napiValue
=
nullptr
;
napi_value
napiValue
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
result
,
&
napiValue
));
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
result
,
&
napiValue
));
...
@@ -156,7 +157,7 @@ napi_value NAPI_IPCSkeleton_flushCommands(napi_env env, napi_callback_info info)
...
@@ -156,7 +157,7 @@ napi_value NAPI_IPCSkeleton_flushCommands(napi_env env, napi_callback_info info)
napi_value
NAPI_IPCSkeleton_flushCmdBuffer
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPI_IPCSkeleton_flushCmdBuffer
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
...
@@ -166,13 +167,13 @@ napi_value NAPI_IPCSkeleton_flushCmdBuffer(napi_env env, napi_callback_info info
...
@@ -166,13 +167,13 @@ napi_value NAPI_IPCSkeleton_flushCmdBuffer(napi_env env, napi_callback_info info
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_object
)
{
if
(
valueType
!=
napi_object
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
argv
[
0
]);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
argv
[
ARGV_INDEX_
0
]);
IPCSkeleton
::
FlushCommands
(
target
);
IPCSkeleton
::
FlushCommands
(
target
);
napi_value
napiValue
=
nullptr
;
napi_value
napiValue
=
nullptr
;
napi_get_undefined
(
env
,
&
napiValue
);
napi_get_undefined
(
env
,
&
napiValue
);
...
@@ -283,20 +284,20 @@ napi_value NAPI_IPCSkeleton_setCallingIdentity(napi_env env, napi_callback_info
...
@@ -283,20 +284,20 @@ napi_value NAPI_IPCSkeleton_setCallingIdentity(napi_env env, napi_callback_info
size_t
argc
=
1
;
size_t
argc
=
1
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT_BASE
(
env
,
argc
==
expectedArgc
,
"requires 1 parameters"
,
retValue
);
NAPI_ASSERT_BASE
(
env
,
argc
==
expectedArgc
,
"requires 1 parameters"
,
retValue
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT_BASE
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
,
retValue
);
NAPI_ASSERT_BASE
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
,
retValue
);
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
NAPI_ASSERT_BASE
(
env
,
bufferSize
<
maxLen
,
"string length too large"
,
retValue
);
NAPI_ASSERT_BASE
(
env
,
bufferSize
<
maxLen
,
"string length too large"
,
retValue
);
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT_BASE
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
,
retValue
);
NAPI_ASSERT_BASE
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
,
retValue
);
std
::
string
identity
=
stringValue
;
std
::
string
identity
=
stringValue
;
...
@@ -423,7 +424,7 @@ napi_value NAPI_IPCSkeleton_restoreCallingIdentity(napi_env env, napi_callback_i
...
@@ -423,7 +424,7 @@ napi_value NAPI_IPCSkeleton_restoreCallingIdentity(napi_env env, napi_callback_i
size_t
argc
=
1
;
size_t
argc
=
1
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
napi_value
argv
[
ARGV_INDEX
_1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH
_1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
expectedArgc
)
{
if
(
argc
!=
expectedArgc
)
{
...
...
ipc/native/src/napi/src/napi_message_option.cpp
浏览文件 @
d30c80ff
...
@@ -22,7 +22,12 @@
...
@@ -22,7 +22,12 @@
namespace
OHOS
{
namespace
OHOS
{
static
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LOG_LABEL
=
{
LOG_CORE
,
LOG_ID_IPC
,
"NapiMessageOption"
};
static
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LOG_LABEL
=
{
LOG_CORE
,
LOG_ID_IPC
,
"NapiMessageOption"
};
static
const
size_t
ARGV_INDEX_0
=
0
;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_LENGTH_1
=
1
;
static
const
size_t
ARGV_LENGTH_2
=
2
;
/*
/*
* Get flags field from ohos.rpc.MessageOption.
* Get flags field from ohos.rpc.MessageOption.
*/
*/
...
@@ -48,14 +53,14 @@ static napi_value NapiOhosRpcMessageOptionSetFlags(napi_env env, napi_callback_i
...
@@ -48,14 +53,14 @@ static napi_value NapiOhosRpcMessageOptionSetFlags(napi_env env, napi_callback_i
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
int32_t
flags
=
0
;
int32_t
flags
=
0
;
napi_status
status
=
napi_get_value_int32
(
env
,
argv
[
0
],
&
flags
);
napi_status
status
=
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
flags
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get int32 value"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get int32 value"
);
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
...
@@ -91,14 +96,14 @@ static napi_value NapiOhosRpcMessageOptionSetAsync(napi_env env, napi_callback_i
...
@@ -91,14 +96,14 @@ static napi_value NapiOhosRpcMessageOptionSetAsync(napi_env env, napi_callback_i
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_boolean
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_boolean
,
"type mismatch for parameter 1"
);
bool
flags
=
false
;
bool
flags
=
false
;
napi_status
status
=
napi_get_value_bool
(
env
,
argv
[
0
],
&
flags
);
napi_status
status
=
napi_get_value_bool
(
env
,
argv
[
ARGV_INDEX_
0
],
&
flags
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get boolean value"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get boolean value"
);
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
...
@@ -134,14 +139,14 @@ static napi_value NapiOhosRpcMessageOptionSetWaittime(napi_env env, napi_callbac
...
@@ -134,14 +139,14 @@ static napi_value NapiOhosRpcMessageOptionSetWaittime(napi_env env, napi_callbac
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
NAPI_ASSERT
(
env
,
thisVar
!=
nullptr
,
"failed to get js message option object"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
int32_t
waittime
=
0
;
int32_t
waittime
=
0
;
napi_status
status
=
napi_get_value_int32
(
env
,
argv
[
0
],
&
waittime
);
napi_status
status
=
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
waittime
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get int32 value"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get int32 value"
);
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
option
);
...
@@ -155,7 +160,7 @@ static napi_value NapiOhosRpcMessageOptionSetWaittime(napi_env env, napi_callbac
...
@@ -155,7 +160,7 @@ static napi_value NapiOhosRpcMessageOptionSetWaittime(napi_env env, napi_callbac
static
napi_value
NAPIMessageOption_JS_Constructor
(
napi_env
env
,
napi_callback_info
info
)
static
napi_value
NAPIMessageOption_JS_Constructor
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
...
@@ -166,28 +171,28 @@ static napi_value NAPIMessageOption_JS_Constructor(napi_env env, napi_callback_i
...
@@ -166,28 +171,28 @@ static napi_value NAPIMessageOption_JS_Constructor(napi_env env, napi_callback_i
waittime
=
MessageOption
::
TF_WAIT_TIME
;
waittime
=
MessageOption
::
TF_WAIT_TIME
;
}
else
if
(
argc
==
1
)
{
}
else
if
(
argc
==
1
)
{
napi_valuetype
valueType
;
napi_valuetype
valueType
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
||
valueType
==
napi_boolean
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
||
valueType
==
napi_boolean
,
"type mismatch for parameter 1"
);
if
(
valueType
==
napi_boolean
)
{
if
(
valueType
==
napi_boolean
)
{
bool
jsBoolFlags
=
false
;
bool
jsBoolFlags
=
false
;
napi_get_value_bool
(
env
,
argv
[
0
],
&
jsBoolFlags
);
napi_get_value_bool
(
env
,
argv
[
ARGV_INDEX_
0
],
&
jsBoolFlags
);
flags
=
jsBoolFlags
?
MessageOption
::
TF_ASYNC
:
MessageOption
::
TF_SYNC
;
flags
=
jsBoolFlags
?
MessageOption
::
TF_ASYNC
:
MessageOption
::
TF_SYNC
;
}
else
{
}
else
{
int32_t
jsFlags
=
0
;
int32_t
jsFlags
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
jsFlags
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
jsFlags
);
flags
=
jsFlags
==
0
?
MessageOption
::
TF_SYNC
:
MessageOption
::
TF_ASYNC
;
flags
=
jsFlags
==
0
?
MessageOption
::
TF_SYNC
:
MessageOption
::
TF_ASYNC
;
}
}
waittime
=
MessageOption
::
TF_WAIT_TIME
;
waittime
=
MessageOption
::
TF_WAIT_TIME
;
}
else
{
}
else
{
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
int32_t
jsFlags
=
0
;
int32_t
jsFlags
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
jsFlags
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
jsFlags
);
int32_t
jsWaittime
=
0
;
int32_t
jsWaittime
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
jsWaittime
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
jsWaittime
);
flags
=
jsFlags
==
0
?
MessageOption
::
TF_SYNC
:
MessageOption
::
TF_ASYNC
;
flags
=
jsFlags
==
0
?
MessageOption
::
TF_SYNC
:
MessageOption
::
TF_ASYNC
;
waittime
=
jsWaittime
;
waittime
=
jsWaittime
;
}
}
...
...
ipc/native/src/napi/src/napi_remote_proxy.cpp
浏览文件 @
d30c80ff
...
@@ -41,7 +41,10 @@ static const size_t ARGV_INDEX_0 = 0;
...
@@ -41,7 +41,10 @@ static const size_t ARGV_INDEX_0 = 0;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_INDEX_2
=
2
;
static
const
size_t
ARGV_INDEX_2
=
2
;
static
const
size_t
ARGV_INDEX_3
=
3
;
static
const
size_t
ARGV_INDEX_3
=
3
;
static
const
size_t
ARGV_INDEX_4
=
4
;
static
const
size_t
ARGV_LENGTH_2
=
2
;
static
const
size_t
ARGV_LENGTH_5
=
5
;
void
ExecuteSendRequest
(
napi_env
env
,
void
*
data
)
void
ExecuteSendRequest
(
napi_env
env
,
void
*
data
)
{
{
SendRequestParam
*
param
=
reinterpret_cast
<
SendRequestParam
*>
(
data
);
SendRequestParam
*
param
=
reinterpret_cast
<
SendRequestParam
*>
(
data
);
...
@@ -66,6 +69,7 @@ void SendRequestCbComplete(napi_env env, napi_status status, void *data)
...
@@ -66,6 +69,7 @@ void SendRequestCbComplete(napi_env env, napi_status status, void *data)
napi_delete_reference
(
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
env
,
param
->
jsDataRef
);
napi_delete_reference
(
env
,
param
->
jsDataRef
);
napi_delete_reference
(
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
env
,
param
->
jsOptionRef
);
napi_delete_reference
(
env
,
param
->
callback
);
napi_delete_reference
(
env
,
param
->
callback
);
napi_delete_async_work
(
env
,
param
->
asyncWork
);
napi_delete_async_work
(
env
,
param
->
asyncWork
);
delete
param
;
delete
param
;
...
@@ -85,6 +89,7 @@ void SendRequestPromiseComplete(napi_env env, napi_status status, void *data)
...
@@ -85,6 +89,7 @@ void SendRequestPromiseComplete(napi_env env, napi_status status, void *data)
napi_delete_reference
(
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
env
,
param
->
jsDataRef
);
napi_delete_reference
(
env
,
param
->
jsDataRef
);
napi_delete_reference
(
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
env
,
param
->
jsOptionRef
);
napi_delete_async_work
(
env
,
param
->
asyncWork
);
napi_delete_async_work
(
env
,
param
->
asyncWork
);
delete
param
;
delete
param
;
}
}
...
@@ -106,6 +111,7 @@ napi_value SendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32_t c
...
@@ -106,6 +111,7 @@ napi_value SendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32_t c
.
jsCodeRef
=
nullptr
,
.
jsCodeRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsOptionRef
=
nullptr
,
.
callback
=
nullptr
,
.
callback
=
nullptr
,
.
env
=
env
,
.
env
=
env
,
.
traceId
=
0
,
.
traceId
=
0
,
...
@@ -119,10 +125,11 @@ napi_value SendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32_t c
...
@@ -119,10 +125,11 @@ napi_value SendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32_t c
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
}
}
}
}
napi_create_reference
(
env
,
argv
[
0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
4
],
1
,
&
sendRequestParam
->
callback
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_3
],
1
,
&
sendRequestParam
->
jsOptionRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_4
],
1
,
&
sendRequestParam
->
callback
);
napi_value
resourceName
=
nullptr
;
napi_value
resourceName
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
__func__
,
NAPI_AUTO_LENGTH
,
&
resourceName
));
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
__func__
,
NAPI_AUTO_LENGTH
,
&
resourceName
));
NAPI_CALL
(
env
,
napi_create_async_work
(
env
,
nullptr
,
resourceName
,
ExecuteSendRequest
,
NAPI_CALL
(
env
,
napi_create_async_work
(
env
,
nullptr
,
resourceName
,
ExecuteSendRequest
,
...
@@ -151,6 +158,7 @@ napi_value SendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint32_t
...
@@ -151,6 +158,7 @@ napi_value SendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint32_t
.
jsCodeRef
=
nullptr
,
.
jsCodeRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsOptionRef
=
nullptr
,
.
callback
=
nullptr
,
.
callback
=
nullptr
,
.
env
=
env
,
.
env
=
env
,
.
traceId
=
0
,
.
traceId
=
0
,
...
@@ -164,9 +172,10 @@ napi_value SendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint32_t
...
@@ -164,9 +172,10 @@ napi_value SendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint32_t
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
}
}
}
}
napi_create_reference
(
env
,
argv
[
0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_3
],
1
,
&
sendRequestParam
->
jsOptionRef
);
napi_value
resourceName
=
nullptr
;
napi_value
resourceName
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
__func__
,
NAPI_AUTO_LENGTH
,
&
resourceName
));
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
__func__
,
NAPI_AUTO_LENGTH
,
&
resourceName
));
NAPI_CALL
(
env
,
napi_create_async_work
(
env
,
nullptr
,
resourceName
,
ExecuteSendRequest
,
NAPI_CALL
(
env
,
napi_create_async_work
(
env
,
nullptr
,
resourceName
,
ExecuteSendRequest
,
...
@@ -180,31 +189,31 @@ napi_value NAPI_RemoteProxy_sendRequest(napi_env env, napi_callback_info info)
...
@@ -180,31 +189,31 @@ napi_value NAPI_RemoteProxy_sendRequest(napi_env env, napi_callback_info info)
size_t
argc
=
4
;
size_t
argc
=
4
;
size_t
argcCallback
=
5
;
size_t
argcCallback
=
5
;
size_t
argcPromise
=
4
;
size_t
argcPromise
=
4
;
napi_value
argv
[
5
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
5
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
argcPromise
||
argc
==
argcCallback
,
"requires 4 or 5 parameters"
);
NAPI_ASSERT
(
env
,
argc
==
argcPromise
||
argc
==
argcCallback
,
"requires 4 or 5 parameters"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 2"
);
napi_typeof
(
env
,
argv
[
2
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
2
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 3"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 3"
);
napi_typeof
(
env
,
argv
[
3
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
3
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 4"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 4"
);
NAPI_MessageParcel
*
data
=
nullptr
;
NAPI_MessageParcel
*
data
=
nullptr
;
napi_status
status
=
napi_unwrap
(
env
,
argv
[
1
],
(
void
**
)
&
data
);
napi_status
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
1
],
(
void
**
)
&
data
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get data message parcel"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get data message parcel"
);
NAPI_MessageParcel
*
reply
=
nullptr
;
NAPI_MessageParcel
*
reply
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
2
],
(
void
**
)
&
reply
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
2
],
(
void
**
)
&
reply
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get reply message parcel"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get reply message parcel"
);
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
3
],
(
void
**
)
&
option
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
3
],
(
void
**
)
&
option
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get message option"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get message option"
);
int32_t
code
=
0
;
int32_t
code
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
code
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
code
);
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
...
@@ -277,7 +286,7 @@ napi_value NAPI_RemoteProxy_sendMessageRequest(napi_env env, napi_callback_info
...
@@ -277,7 +286,7 @@ napi_value NAPI_RemoteProxy_sendMessageRequest(napi_env env, napi_callback_info
size_t
argc
=
4
;
size_t
argc
=
4
;
size_t
argcCallback
=
5
;
size_t
argcCallback
=
5
;
size_t
argcPromise
=
4
;
size_t
argcPromise
=
4
;
napi_value
argv
[
5
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
5
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
argcPromise
&&
argc
!=
argcCallback
)
{
if
(
argc
!=
argcPromise
&&
argc
!=
argcCallback
)
{
...
@@ -292,7 +301,7 @@ napi_value NAPI_RemoteProxy_sendMessageRequest(napi_env env, napi_callback_info
...
@@ -292,7 +301,7 @@ napi_value NAPI_RemoteProxy_sendMessageRequest(napi_env env, napi_callback_info
return
checkArgsResult
;
return
checkArgsResult
;
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
code
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
code
);
napi_value
result
=
nullptr
;
napi_value
result
=
nullptr
;
napi_get_undefined
(
env
,
&
result
);
napi_get_undefined
(
env
,
&
result
);
...
@@ -338,21 +347,21 @@ napi_value NAPI_RemoteProxy_addDeathRecipient(napi_env env, napi_callback_info i
...
@@ -338,21 +347,21 @@ napi_value NAPI_RemoteProxy_addDeathRecipient(napi_env env, napi_callback_info i
ZLOGI
(
LOG_LABEL
,
"add death recipient"
);
ZLOGI
(
LOG_LABEL
,
"add death recipient"
);
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
expectedArgc
=
2
;
size_t
expectedArgc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
int32_t
flag
=
0
;
int32_t
flag
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
flag
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
flag
);
napi_value
result
;
napi_value
result
;
if
(
argv
[
0
]
==
nullptr
)
{
if
(
argv
[
ARGV_INDEX_
0
]
==
nullptr
)
{
napi_get_boolean
(
env
,
false
,
&
result
);
napi_get_boolean
(
env
,
false
,
&
result
);
return
result
;
return
result
;
}
}
...
@@ -371,7 +380,7 @@ napi_value NAPI_RemoteProxy_addDeathRecipient(napi_env env, napi_callback_info i
...
@@ -371,7 +380,7 @@ napi_value NAPI_RemoteProxy_addDeathRecipient(napi_env env, napi_callback_info i
return
result
;
return
result
;
}
}
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
new
NAPIDeathRecipient
(
env
,
argv
[
0
]);
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
new
NAPIDeathRecipient
(
env
,
argv
[
ARGV_INDEX_
0
]);
if
(
target
->
AddDeathRecipient
(
nativeRecipient
))
{
if
(
target
->
AddDeathRecipient
(
nativeRecipient
))
{
NAPIDeathRecipientList
*
list
=
proxyHolder
->
list_
;
NAPIDeathRecipientList
*
list
=
proxyHolder
->
list_
;
if
(
list
->
Add
(
nativeRecipient
))
{
if
(
list
->
Add
(
nativeRecipient
))
{
...
@@ -411,7 +420,7 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
...
@@ -411,7 +420,7 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
{
{
ZLOGI
(
LOG_LABEL
,
"register death recipient"
);
ZLOGI
(
LOG_LABEL
,
"register death recipient"
);
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
...
@@ -420,9 +429,9 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
...
@@ -420,9 +429,9 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
return
checkArgsResult
;
return
checkArgsResult
;
}
}
int32_t
flag
=
0
;
int32_t
flag
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
flag
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
flag
);
if
(
argv
[
0
]
==
nullptr
)
{
if
(
argv
[
ARGV_INDEX_
0
]
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"invalid parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"invalid parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
...
@@ -443,7 +452,7 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
...
@@ -443,7 +452,7 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
PROXY_OR_REMOTE_OBJECT_INVALID_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
PROXY_OR_REMOTE_OBJECT_INVALID_ERROR
);
}
}
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
new
NAPIDeathRecipient
(
env
,
argv
[
0
]);
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
new
NAPIDeathRecipient
(
env
,
argv
[
ARGV_INDEX_
0
]);
if
(
target
->
AddDeathRecipient
(
nativeRecipient
))
{
if
(
target
->
AddDeathRecipient
(
nativeRecipient
))
{
NAPIDeathRecipientList
*
list
=
proxyHolder
->
list_
;
NAPIDeathRecipientList
*
list
=
proxyHolder
->
list_
;
if
(
list
->
Add
(
nativeRecipient
))
{
if
(
list
->
Add
(
nativeRecipient
))
{
...
@@ -459,24 +468,24 @@ napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_inf
...
@@ -459,24 +468,24 @@ napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_inf
{
{
ZLOGI
(
LOG_LABEL
,
"remove death recipient"
);
ZLOGI
(
LOG_LABEL
,
"remove death recipient"
);
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
size_t
expectedArgc
=
2
;
size_t
expectedArgc
=
2
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
napi_value
result
;
napi_value
result
;
if
(
argv
[
0
]
==
nullptr
)
{
if
(
argv
[
ARGV_INDEX_
0
]
==
nullptr
)
{
napi_get_boolean
(
env
,
false
,
&
result
);
napi_get_boolean
(
env
,
false
,
&
result
);
return
result
;
return
result
;
}
}
int32_t
flag
=
0
;
int32_t
flag
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
flag
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
flag
);
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
napi_status
status
=
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
napi_status
status
=
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
...
@@ -492,7 +501,7 @@ napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_inf
...
@@ -492,7 +501,7 @@ napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_inf
return
result
;
return
result
;
}
}
sptr
<
NAPIDeathRecipientList
>
list
=
proxyHolder
->
list_
;
sptr
<
NAPIDeathRecipientList
>
list
=
proxyHolder
->
list_
;
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
list
->
Find
(
argv
[
0
]);
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
list
->
Find
(
argv
[
ARGV_INDEX_
0
]);
if
(
nativeRecipient
==
nullptr
)
{
if
(
nativeRecipient
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"recipient not found"
);
ZLOGE
(
LOG_LABEL
,
"recipient not found"
);
napi_get_boolean
(
env
,
false
,
&
result
);
napi_get_boolean
(
env
,
false
,
&
result
);
...
@@ -539,7 +548,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
...
@@ -539,7 +548,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
{
{
ZLOGI
(
LOG_LABEL
,
"unregister death recipient"
);
ZLOGI
(
LOG_LABEL
,
"unregister death recipient"
);
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
...
@@ -548,7 +557,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
...
@@ -548,7 +557,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
return
checkArgsResult
;
return
checkArgsResult
;
}
}
int32_t
flag
=
0
;
int32_t
flag
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
flag
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
flag
);
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
NAPIRemoteProxyHolder
*
proxyHolder
=
nullptr
;
napi_status
status
=
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
napi_status
status
=
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
proxyHolder
);
...
@@ -568,7 +577,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
...
@@ -568,7 +577,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
napi_value
result
=
nullptr
;
napi_value
result
=
nullptr
;
napi_get_undefined
(
env
,
&
result
);
napi_get_undefined
(
env
,
&
result
);
sptr
<
NAPIDeathRecipientList
>
list
=
proxyHolder
->
list_
;
sptr
<
NAPIDeathRecipientList
>
list
=
proxyHolder
->
list_
;
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
list
->
Find
(
argv
[
0
]);
sptr
<
NAPIDeathRecipient
>
nativeRecipient
=
list
->
Find
(
argv
[
ARGV_INDEX_
0
]);
if
(
nativeRecipient
==
nullptr
)
{
if
(
nativeRecipient
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"recipient not found"
);
ZLOGE
(
LOG_LABEL
,
"recipient not found"
);
return
result
;
return
result
;
...
...
ipc/native/src/napi_common/include/napi_message_sequence.h
浏览文件 @
d30c80ff
...
@@ -119,6 +119,10 @@ private:
...
@@ -119,6 +119,10 @@ private:
napi_value
&
thisVar
,
napi_value
*
argv
);
napi_value
&
thisVar
,
napi_value
*
argv
);
static
napi_value
JS_readParcelableArrayCallJsFunc
(
napi_env
env
,
napi_value
&
element
,
napi_value
&
thisVar
);
static
napi_value
JS_readParcelableArrayCallJsFunc
(
napi_env
env
,
napi_value
&
element
,
napi_value
&
thisVar
);
static
napi_value
JS_checkWriteRawDataArgs
(
napi_env
env
,
size_t
argc
,
napi_value
*
argv
);
static
napi_value
JS_checkWriteRawDataArgs
(
napi_env
env
,
size_t
argc
,
napi_value
*
argv
);
static
bool
JS_WriteRawDataForArray
(
napi_env
env
,
napi_value
jsArray
,
uint32_t
size
,
NAPI_MessageSequence
*
napiSequence
);
static
bool
JS_WriteRawDataForTypedArray
(
napi_env
env
,
napi_value
jsTypedArray
,
size_t
size
,
NAPI_MessageSequence
*
napiSequence
);
napi_env
env_
=
nullptr
;
napi_env
env_
=
nullptr
;
bool
owner
;
bool
owner
;
...
...
ipc/native/src/napi_common/include/napi_remote_object_internal.h
浏览文件 @
d30c80ff
...
@@ -86,6 +86,7 @@ struct SendRequestParam {
...
@@ -86,6 +86,7 @@ struct SendRequestParam {
napi_ref
jsCodeRef
;
napi_ref
jsCodeRef
;
napi_ref
jsDataRef
;
napi_ref
jsDataRef
;
napi_ref
jsReplyRef
;
napi_ref
jsReplyRef
;
napi_ref
jsOptionRef
;
napi_ref
callback
;
napi_ref
callback
;
napi_env
env
;
napi_env
env
;
std
::
string
traceValue
;
std
::
string
traceValue
;
...
...
ipc/native/src/napi_common/source/napi_ashmem.cpp
浏览文件 @
d30c80ff
...
@@ -29,6 +29,13 @@ constexpr size_t BYTE_SIZE_32 = 4;
...
@@ -29,6 +29,13 @@ constexpr size_t BYTE_SIZE_32 = 4;
NapiError
NAPIAshmem
::
napiErr
;
NapiError
NAPIAshmem
::
napiErr
;
static
const
size_t
ARGV_INDEX_0
=
0
;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_INDEX_2
=
2
;
static
const
size_t
ARGV_LENGTH_1
=
1
;
static
const
size_t
ARGV_LENGTH_2
=
2
;
static
const
size_t
ARGV_LENGTH_3
=
3
;
NAPIAshmem
::
NAPIAshmem
(
sptr
<
Ashmem
>
&
ashmem
)
:
ashmem_
(
ashmem
)
NAPIAshmem
::
NAPIAshmem
(
sptr
<
Ashmem
>
&
ashmem
)
:
ashmem_
(
ashmem
)
{
{
if
(
ashmem
==
nullptr
)
{
if
(
ashmem
==
nullptr
)
{
...
@@ -53,28 +60,28 @@ napi_value NAPIAshmem::CreateAshmem(napi_env env, napi_callback_info info)
...
@@ -53,28 +60,28 @@ napi_value NAPIAshmem::CreateAshmem(napi_env env, napi_callback_info info)
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_string
)
{
if
(
valueType
!=
napi_string
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
nullptr
;
return
nullptr
;
}
}
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
if
(
bufferSize
==
0
)
{
if
(
bufferSize
==
0
)
{
ZLOGE
(
LOG_LABEL
,
"invalid ashmem name"
);
ZLOGE
(
LOG_LABEL
,
"invalid ashmem name"
);
return
nullptr
;
return
nullptr
;
}
}
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
return
nullptr
;
return
nullptr
;
}
}
int32_t
ashmemSize
=
0
;
int32_t
ashmemSize
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
ashmemSize
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
ashmemSize
);
if
(
ashmemSize
<=
0
)
{
if
(
ashmemSize
<=
0
)
{
ZLOGE
(
LOG_LABEL
,
"invalid ashmem size"
);
ZLOGE
(
LOG_LABEL
,
"invalid ashmem size"
);
return
nullptr
;
return
nullptr
;
...
@@ -94,7 +101,7 @@ napi_value NAPIAshmem::CreateAshmem(napi_env env, napi_callback_info info)
...
@@ -94,7 +101,7 @@ napi_value NAPIAshmem::CreateAshmem(napi_env env, napi_callback_info info)
napi_value
NAPIAshmem
::
CreateAshmemFromExisting
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPIAshmem
::
CreateAshmemFromExisting
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
nullptr
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
nullptr
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
napi_value
global
=
nullptr
;
napi_value
global
=
nullptr
;
...
@@ -104,10 +111,10 @@ napi_value NAPIAshmem::CreateAshmemFromExisting(napi_env env, napi_callback_info
...
@@ -104,10 +111,10 @@ napi_value NAPIAshmem::CreateAshmemFromExisting(napi_env env, napi_callback_info
status
=
napi_get_named_property
(
env
,
global
,
"AshmemConstructor_"
,
&
constructor
);
status
=
napi_get_named_property
(
env
,
global
,
"AshmemConstructor_"
,
&
constructor
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"get Ashmem constructor failed"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"get Ashmem constructor failed"
);
bool
isAshmem
=
false
;
bool
isAshmem
=
false
;
napi_instanceof
(
env
,
argv
[
0
],
constructor
,
&
isAshmem
);
napi_instanceof
(
env
,
argv
[
ARGV_INDEX_
0
],
constructor
,
&
isAshmem
);
NAPI_ASSERT
(
env
,
isAshmem
==
true
,
"parameter is not instanceof Ashmem"
);
NAPI_ASSERT
(
env
,
isAshmem
==
true
,
"parameter is not instanceof Ashmem"
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
argv
[
0
],
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
0
],
(
void
**
)
&
napiAshmem
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
int32_t
fd
=
napiAshmem
->
GetAshmem
()
->
GetAshmemFd
();
int32_t
fd
=
napiAshmem
->
GetAshmem
()
->
GetAshmemFd
();
uint32_t
size
=
(
uint32_t
)(
napiAshmem
->
GetAshmem
()
->
GetAshmemSize
());
uint32_t
size
=
(
uint32_t
)(
napiAshmem
->
GetAshmem
()
->
GetAshmemSize
());
...
@@ -130,7 +137,7 @@ napi_value NAPIAshmem::Create(napi_env env, napi_callback_info info)
...
@@ -130,7 +137,7 @@ napi_value NAPIAshmem::Create(napi_env env, napi_callback_info info)
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
argcExistingAshmem
=
1
;
size_t
argcExistingAshmem
=
1
;
size_t
argcAshmem
=
2
;
size_t
argcAshmem
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
!
(
argc
==
argcExistingAshmem
||
argc
==
argcAshmem
))
{
if
(
!
(
argc
==
argcExistingAshmem
||
argc
==
argcAshmem
))
{
ZLOGE
(
LOG_LABEL
,
"requires 1 or 2 parameter"
);
ZLOGE
(
LOG_LABEL
,
"requires 1 or 2 parameter"
);
...
@@ -142,26 +149,26 @@ napi_value NAPIAshmem::Create(napi_env env, napi_callback_info info)
...
@@ -142,26 +149,26 @@ napi_value NAPIAshmem::Create(napi_env env, napi_callback_info info)
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_string
)
{
if
(
valueType
!=
napi_string
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
if
(
bufferSize
==
0
)
{
if
(
bufferSize
==
0
)
{
ZLOGE
(
LOG_LABEL
,
"invalid ashmem name"
);
ZLOGE
(
LOG_LABEL
,
"invalid ashmem name"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
int32_t
ashmemSize
=
0
;
int32_t
ashmemSize
=
0
;
napi_get_value_int32
(
env
,
argv
[
1
],
&
ashmemSize
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
ashmemSize
);
if
(
ashmemSize
<=
0
)
{
if
(
ashmemSize
<=
0
)
{
ZLOGE
(
LOG_LABEL
,
"invalid ashmem size"
);
ZLOGE
(
LOG_LABEL
,
"invalid ashmem size"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -196,7 +203,7 @@ napi_value NAPIAshmem::GetAshmemConstructor(napi_env env, napi_value* argv)
...
@@ -196,7 +203,7 @@ napi_value NAPIAshmem::GetAshmemConstructor(napi_env env, napi_value* argv)
napi_value
NAPIAshmem
::
GetAshmemFromExisting
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPIAshmem
::
GetAshmemFromExisting
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
nullptr
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
nullptr
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
nullptr
);
napi_value
global
=
nullptr
;
napi_value
global
=
nullptr
;
napi_status
status
=
napi_get_global
(
env
,
&
global
);
napi_status
status
=
napi_get_global
(
env
,
&
global
);
...
@@ -211,13 +218,13 @@ napi_value NAPIAshmem::GetAshmemFromExisting(napi_env env, napi_callback_info in
...
@@ -211,13 +218,13 @@ napi_value NAPIAshmem::GetAshmemFromExisting(napi_env env, napi_callback_info in
return
nullptr
;
return
nullptr
;
}
}
bool
isAshmem
=
false
;
bool
isAshmem
=
false
;
napi_instanceof
(
env
,
argv
[
0
],
constructor
,
&
isAshmem
);
napi_instanceof
(
env
,
argv
[
ARGV_INDEX_
0
],
constructor
,
&
isAshmem
);
if
(
isAshmem
==
false
)
{
if
(
isAshmem
==
false
)
{
ZLOGE
(
LOG_LABEL
,
"parameter is not instanceof Ashmem"
);
ZLOGE
(
LOG_LABEL
,
"parameter is not instanceof Ashmem"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
argv
[
0
],
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
0
],
(
void
**
)
&
napiAshmem
);
if
(
napiAshmem
==
nullptr
)
{
if
(
napiAshmem
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"napiAshmem is null"
);
ZLOGE
(
LOG_LABEL
,
"napiAshmem is null"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -273,14 +280,14 @@ napi_value NAPIAshmem::MapAshmem(napi_env env, napi_callback_info info)
...
@@ -273,14 +280,14 @@ napi_value NAPIAshmem::MapAshmem(napi_env env, napi_callback_info info)
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
uint32_t
mapType
=
0
;
uint32_t
mapType
=
0
;
napi_get_value_uint32
(
env
,
argv
[
0
],
&
mapType
);
napi_get_value_uint32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
mapType
);
NAPI_ASSERT
(
env
,
mapType
<=
MMAP_PROT_MAX
,
"napiAshmem mapType error"
);
NAPI_ASSERT
(
env
,
mapType
<=
MMAP_PROT_MAX
,
"napiAshmem mapType error"
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
...
@@ -295,20 +302,20 @@ napi_value NAPIAshmem::MapTypedAshmem(napi_env env, napi_callback_info info)
...
@@ -295,20 +302,20 @@ napi_value NAPIAshmem::MapTypedAshmem(napi_env env, napi_callback_info info)
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
1
)
{
if
(
argc
!=
1
)
{
ZLOGE
(
LOG_LABEL
,
"requires 1 parameter"
);
ZLOGE
(
LOG_LABEL
,
"requires 1 parameter"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
uint32_t
mapType
=
0
;
uint32_t
mapType
=
0
;
napi_get_value_uint32
(
env
,
argv
[
0
],
&
mapType
);
napi_get_value_uint32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
mapType
);
if
(
mapType
>
MMAP_PROT_MAX
)
{
if
(
mapType
>
MMAP_PROT_MAX
)
{
ZLOGE
(
LOG_LABEL
,
"napiAshmem mapType error"
);
ZLOGE
(
LOG_LABEL
,
"napiAshmem mapType error"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -387,18 +394,18 @@ napi_value NAPIAshmem::ReadFromAshmem(napi_env env, napi_callback_info info)
...
@@ -387,18 +394,18 @@ napi_value NAPIAshmem::ReadFromAshmem(napi_env env, napi_callback_info info)
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
int64_t
size
=
0
;
int64_t
size
=
0
;
napi_get_value_int64
(
env
,
argv
[
0
],
&
size
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
0
],
&
size
);
int64_t
offset
=
0
;
int64_t
offset
=
0
;
napi_get_value_int64
(
env
,
argv
[
1
],
&
offset
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
1
],
&
offset
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
...
@@ -439,27 +446,27 @@ napi_value NAPIAshmem::ReadAshmem(napi_env env, napi_callback_info info)
...
@@ -439,27 +446,27 @@ napi_value NAPIAshmem::ReadAshmem(napi_env env, napi_callback_info info)
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
argNum
=
2
;
size_t
argNum
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
argNum
)
{
if
(
argc
!=
argNum
)
{
ZLOGE
(
LOG_LABEL
,
"requires 2 parameter"
);
ZLOGE
(
LOG_LABEL
,
"requires 2 parameter"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
int64_t
size
=
0
;
int64_t
size
=
0
;
napi_get_value_int64
(
env
,
argv
[
0
],
&
size
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
0
],
&
size
);
int64_t
offset
=
0
;
int64_t
offset
=
0
;
napi_get_value_int64
(
env
,
argv
[
1
],
&
offset
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
1
],
&
offset
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
if
(
napiAshmem
==
nullptr
)
{
if
(
napiAshmem
==
nullptr
)
{
...
@@ -513,14 +520,14 @@ napi_value NAPIAshmem::SetProtection(napi_env env, napi_callback_info info)
...
@@ -513,14 +520,14 @@ napi_value NAPIAshmem::SetProtection(napi_env env, napi_callback_info info)
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
1
,
"requires 1 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
uint32_t
protectionType
=
0
;
uint32_t
protectionType
=
0
;
napi_get_value_uint32
(
env
,
argv
[
0
],
&
protectionType
);
napi_get_value_uint32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
protectionType
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
...
@@ -535,20 +542,20 @@ napi_value NAPIAshmem::SetProtectionType(napi_env env, napi_callback_info info)
...
@@ -535,20 +542,20 @@ napi_value NAPIAshmem::SetProtectionType(napi_env env, napi_callback_info info)
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
1
;
size_t
argc
=
1
;
size_t
argNum
=
1
;
size_t
argNum
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
argNum
)
{
if
(
argc
!=
argNum
)
{
ZLOGE
(
LOG_LABEL
,
"requires 1 parameter"
);
ZLOGE
(
LOG_LABEL
,
"requires 1 parameter"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
uint32_t
protectionType
=
0
;
uint32_t
protectionType
=
0
;
napi_get_value_uint32
(
env
,
argv
[
0
],
&
protectionType
);
napi_get_value_uint32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
protectionType
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
if
(
napiAshmem
==
nullptr
)
{
if
(
napiAshmem
==
nullptr
)
{
...
@@ -577,30 +584,30 @@ napi_value NAPIAshmem::UnmapAshmem(napi_env env, napi_callback_info info)
...
@@ -577,30 +584,30 @@ napi_value NAPIAshmem::UnmapAshmem(napi_env env, napi_callback_info info)
napi_value
NAPIAshmem
::
WriteToAshmem
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPIAshmem
::
WriteToAshmem
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
3
;
size_t
argc
=
3
;
napi_value
argv
[
3
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
3
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
3
,
"requires 1 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
3
,
"requires 1 parameter"
);
bool
isArray
=
false
;
bool
isArray
=
false
;
napi_is_array
(
env
,
argv
[
0
],
&
isArray
);
napi_is_array
(
env
,
argv
[
ARGV_INDEX_
0
],
&
isArray
);
NAPI_ASSERT
(
env
,
isArray
==
true
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
isArray
==
true
,
"type mismatch for parameter 1"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
napi_typeof
(
env
,
argv
[
2
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
2
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 3"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 3"
);
std
::
vector
<
int32_t
>
array
;
std
::
vector
<
int32_t
>
array
;
uint32_t
arrayLength
=
0
;
uint32_t
arrayLength
=
0
;
napi_get_array_length
(
env
,
argv
[
0
],
&
arrayLength
);
napi_get_array_length
(
env
,
argv
[
ARGV_INDEX_
0
],
&
arrayLength
);
for
(
size_t
i
=
0
;
i
<
arrayLength
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
arrayLength
;
i
++
)
{
bool
hasElement
=
false
;
bool
hasElement
=
false
;
napi_has_element
(
env
,
argv
[
0
],
i
,
&
hasElement
);
napi_has_element
(
env
,
argv
[
ARGV_INDEX_
0
],
i
,
&
hasElement
);
NAPI_ASSERT
(
env
,
hasElement
==
true
,
"parameter check error"
);
NAPI_ASSERT
(
env
,
hasElement
==
true
,
"parameter check error"
);
napi_value
element
=
nullptr
;
napi_value
element
=
nullptr
;
napi_get_element
(
env
,
argv
[
0
],
i
,
&
element
);
napi_get_element
(
env
,
argv
[
ARGV_INDEX_
0
],
i
,
&
element
);
int32_t
value
=
0
;
int32_t
value
=
0
;
napi_get_value_int32
(
env
,
element
,
&
value
);
napi_get_value_int32
(
env
,
element
,
&
value
);
...
@@ -608,9 +615,9 @@ napi_value NAPIAshmem::WriteToAshmem(napi_env env, napi_callback_info info)
...
@@ -608,9 +615,9 @@ napi_value NAPIAshmem::WriteToAshmem(napi_env env, napi_callback_info info)
}
}
int64_t
size
=
0
;
int64_t
size
=
0
;
napi_get_value_int64
(
env
,
argv
[
1
],
&
size
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
1
],
&
size
);
int64_t
offset
=
0
;
int64_t
offset
=
0
;
napi_get_value_int64
(
env
,
argv
[
2
],
&
offset
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
2
],
&
offset
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
NAPI_ASSERT
(
env
,
napiAshmem
!=
nullptr
,
"napiAshmem is null"
);
...
@@ -634,7 +641,7 @@ napi_value NAPIAshmem::WriteToAshmem(napi_env env, napi_callback_info info)
...
@@ -634,7 +641,7 @@ napi_value NAPIAshmem::WriteToAshmem(napi_env env, napi_callback_info info)
napi_value
NAPIAshmem
::
WriteAshmem
(
napi_env
env
,
napi_callback_info
info
)
napi_value
NAPIAshmem
::
WriteAshmem
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
3
;
size_t
argc
=
3
;
napi_value
argv
[
3
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
3
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_value
checkArgsResult
=
CheckWriteAshmemParams
(
env
,
argc
,
argv
);
napi_value
checkArgsResult
=
CheckWriteAshmemParams
(
env
,
argc
,
argv
);
...
@@ -644,18 +651,18 @@ napi_value NAPIAshmem::WriteAshmem(napi_env env, napi_callback_info info)
...
@@ -644,18 +651,18 @@ napi_value NAPIAshmem::WriteAshmem(napi_env env, napi_callback_info info)
std
::
vector
<
int32_t
>
array
;
std
::
vector
<
int32_t
>
array
;
uint32_t
arrayLength
=
0
;
uint32_t
arrayLength
=
0
;
napi_get_array_length
(
env
,
argv
[
0
],
&
arrayLength
);
napi_get_array_length
(
env
,
argv
[
ARGV_INDEX_
0
],
&
arrayLength
);
for
(
size_t
i
=
0
;
i
<
arrayLength
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
arrayLength
;
i
++
)
{
bool
hasElement
=
false
;
bool
hasElement
=
false
;
napi_has_element
(
env
,
argv
[
0
],
i
,
&
hasElement
);
napi_has_element
(
env
,
argv
[
ARGV_INDEX_
0
],
i
,
&
hasElement
);
if
(
hasElement
==
false
)
{
if
(
hasElement
==
false
)
{
ZLOGE
(
LOG_LABEL
,
"parameter check error"
);
ZLOGE
(
LOG_LABEL
,
"parameter check error"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_value
element
=
nullptr
;
napi_value
element
=
nullptr
;
napi_get_element
(
env
,
argv
[
0
],
i
,
&
element
);
napi_get_element
(
env
,
argv
[
ARGV_INDEX_
0
],
i
,
&
element
);
int32_t
value
=
0
;
int32_t
value
=
0
;
napi_get_value_int32
(
env
,
element
,
&
value
);
napi_get_value_int32
(
env
,
element
,
&
value
);
...
@@ -663,9 +670,9 @@ napi_value NAPIAshmem::WriteAshmem(napi_env env, napi_callback_info info)
...
@@ -663,9 +670,9 @@ napi_value NAPIAshmem::WriteAshmem(napi_env env, napi_callback_info info)
}
}
int64_t
size
=
0
;
int64_t
size
=
0
;
napi_get_value_int64
(
env
,
argv
[
1
],
&
size
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
1
],
&
size
);
int64_t
offset
=
0
;
int64_t
offset
=
0
;
napi_get_value_int64
(
env
,
argv
[
2
],
&
offset
);
napi_get_value_int64
(
env
,
argv
[
ARGV_INDEX_
2
],
&
offset
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
napi_unwrap
(
env
,
thisVar
,
(
void
**
)
&
napiAshmem
);
if
(
napiAshmem
==
nullptr
)
{
if
(
napiAshmem
==
nullptr
)
{
...
@@ -695,18 +702,18 @@ napi_value NAPIAshmem::CheckWriteAshmemParams(napi_env env, size_t argc, napi_va
...
@@ -695,18 +702,18 @@ napi_value NAPIAshmem::CheckWriteAshmemParams(napi_env env, size_t argc, napi_va
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
bool
isArray
=
false
;
bool
isArray
=
false
;
napi_is_array
(
env
,
argv
[
0
],
&
isArray
);
napi_is_array
(
env
,
argv
[
ARGV_INDEX_
0
],
&
isArray
);
if
(
isArray
==
false
)
{
if
(
isArray
==
false
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 2"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_typeof
(
env
,
argv
[
2
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
2
],
&
valueType
);
if
(
valueType
!=
napi_number
)
{
if
(
valueType
!=
napi_number
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 4"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 4"
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
OHOS
::
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -767,7 +774,7 @@ napi_value NAPIAshmem::Ashmem_JS_Constructor(napi_env env, napi_callback_info in
...
@@ -767,7 +774,7 @@ napi_value NAPIAshmem::Ashmem_JS_Constructor(napi_env env, napi_callback_info in
{
{
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPIAshmem
*
napiAshmem
=
nullptr
;
NAPIAshmem
*
napiAshmem
=
nullptr
;
if
(
argc
==
0
)
{
if
(
argc
==
0
)
{
...
@@ -775,21 +782,21 @@ napi_value NAPIAshmem::Ashmem_JS_Constructor(napi_env env, napi_callback_info in
...
@@ -775,21 +782,21 @@ napi_value NAPIAshmem::Ashmem_JS_Constructor(napi_env env, napi_callback_info in
}
else
{
}
else
{
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
NAPI_ASSERT
(
env
,
argc
==
2
,
"requires 2 parameter"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 2"
);
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
std
::
string
ashmemName
=
stringValue
;
std
::
string
ashmemName
=
stringValue
;
uint32_t
ashmemSize
=
0
;
uint32_t
ashmemSize
=
0
;
napi_get_value_uint32
(
env
,
argv
[
1
],
&
ashmemSize
);
napi_get_value_uint32
(
env
,
argv
[
ARGV_INDEX_
1
],
&
ashmemSize
);
// new napi Ashmem
// new napi Ashmem
sptr
<
Ashmem
>
nativeAshmem
=
Ashmem
::
CreateAshmem
(
ashmemName
.
c_str
(),
ashmemSize
);
sptr
<
Ashmem
>
nativeAshmem
=
Ashmem
::
CreateAshmem
(
ashmemName
.
c_str
(),
ashmemSize
);
NAPI_ASSERT
(
env
,
nativeAshmem
!=
nullptr
,
"invalid parameters"
);
NAPI_ASSERT
(
env
,
nativeAshmem
!=
nullptr
,
"invalid parameters"
);
...
...
ipc/native/src/napi_common/source/napi_message_parcel.cpp
浏览文件 @
d30c80ff
此差异已折叠。
点击以展开。
ipc/native/src/napi_common/source/napi_message_sequence.cpp
浏览文件 @
d30c80ff
此差异已折叠。
点击以展开。
ipc/native/src/napi_common/source/napi_remote_object.cpp
浏览文件 @
d30c80ff
...
@@ -39,6 +39,11 @@ static const size_t ARGV_INDEX_0 = 0;
...
@@ -39,6 +39,11 @@ static const size_t ARGV_INDEX_0 = 0;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_INDEX_1
=
1
;
static
const
size_t
ARGV_INDEX_2
=
2
;
static
const
size_t
ARGV_INDEX_2
=
2
;
static
const
size_t
ARGV_INDEX_3
=
3
;
static
const
size_t
ARGV_INDEX_3
=
3
;
static
const
size_t
ARGV_INDEX_4
=
4
;
static
const
size_t
ARGV_LENGTH_1
=
1
;
static
const
size_t
ARGV_LENGTH_2
=
2
;
static
const
size_t
ARGV_LENGTH_5
=
5
;
static
const
uint64_t
HITRACE_TAG_RPC
=
(
1ULL
<<
46
);
// RPC and IPC tag.
static
const
uint64_t
HITRACE_TAG_RPC
=
(
1ULL
<<
46
);
// RPC and IPC tag.
static
std
::
atomic
<
int32_t
>
bytraceId
=
1000
;
static
std
::
atomic
<
int32_t
>
bytraceId
=
1000
;
...
@@ -166,7 +171,7 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
...
@@ -166,7 +171,7 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
napi_create_string_utf8
(
env
,
desc
.
c_str
(),
desc
.
length
(),
&
jsDesc
);
napi_create_string_utf8
(
env
,
desc
.
c_str
(),
desc
.
length
(),
&
jsDesc
);
// create a new js remote object
// create a new js remote object
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
jsDesc
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
jsDesc
};
napi_value
jsRemoteObject
=
nullptr
;
napi_value
jsRemoteObject
=
nullptr
;
status
=
napi_new_instance
(
env
,
constructor
,
argc
,
argv
,
&
jsRemoteObject
);
status
=
napi_new_instance
(
env
,
constructor
,
argc
,
argv
,
&
jsRemoteObject
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to construct js RemoteObject when attach"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to construct js RemoteObject when attach"
);
...
@@ -186,20 +191,20 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
...
@@ -186,20 +191,20 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
// new napi remote object
// new napi remote object
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
>=
expectedArgc
,
"requires at least 1 parameters"
);
NAPI_ASSERT
(
env
,
argc
>=
expectedArgc
,
"requires at least 1 parameters"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
std
::
string
descriptor
=
stringValue
;
std
::
string
descriptor
=
stringValue
;
auto
holder
=
new
NAPIRemoteObjectHolder
(
env
,
Str8ToStr16
(
descriptor
),
thisVar
);
auto
holder
=
new
NAPIRemoteObjectHolder
(
env
,
Str8ToStr16
(
descriptor
),
thisVar
);
...
@@ -351,12 +356,12 @@ napi_value NAPIRemoteObject::ThenCallback(napi_env env, napi_callback_info info)
...
@@ -351,12 +356,12 @@ napi_value NAPIRemoteObject::ThenCallback(napi_env env, napi_callback_info info)
{
{
ZLOGI
(
LOG_LABEL
,
"call js onRemoteRequest done"
);
ZLOGI
(
LOG_LABEL
,
"call js onRemoteRequest done"
);
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
nullptr
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
nullptr
};
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
&
data
);
CallbackParam
*
param
=
static_cast
<
CallbackParam
*>
(
data
);
CallbackParam
*
param
=
static_cast
<
CallbackParam
*>
(
data
);
bool
result
=
false
;
bool
result
=
false
;
napi_get_value_bool
(
param
->
env
,
argv
[
0
],
&
result
);
napi_get_value_bool
(
param
->
env
,
argv
[
ARGV_INDEX_
0
],
&
result
);
if
(
!
result
)
{
if
(
!
result
)
{
ZLOGE
(
LOG_LABEL
,
"OnRemoteRequest res:%{public}s"
,
result
?
"true"
:
"false"
);
ZLOGE
(
LOG_LABEL
,
"OnRemoteRequest res:%{public}s"
,
result
?
"true"
:
"false"
);
param
->
result
=
ERR_UNKNOWN_TRANSACTION
;
param
->
result
=
ERR_UNKNOWN_TRANSACTION
;
...
@@ -375,7 +380,7 @@ napi_value NAPIRemoteObject::CatchCallback(napi_env env, napi_callback_info info
...
@@ -375,7 +380,7 @@ napi_value NAPIRemoteObject::CatchCallback(napi_env env, napi_callback_info info
{
{
ZLOGI
(
LOG_LABEL
,
"Async onReomteReuqest's returnVal is rejected"
);
ZLOGI
(
LOG_LABEL
,
"Async onReomteReuqest's returnVal is rejected"
);
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
nullptr
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
nullptr
};
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
nullptr
,
&
data
);
CallbackParam
*
param
=
static_cast
<
CallbackParam
*>
(
data
);
CallbackParam
*
param
=
static_cast
<
CallbackParam
*>
(
data
);
...
@@ -533,7 +538,7 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
...
@@ -533,7 +538,7 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
napi_create_int32
(
param
->
env
,
param
->
option
->
GetFlags
(),
&
flags
);
napi_create_int32
(
param
->
env
,
param
->
option
->
GetFlags
(),
&
flags
);
napi_value
waittime
=
nullptr
;
napi_value
waittime
=
nullptr
;
napi_create_int32
(
param
->
env
,
param
->
option
->
GetWaitTime
(),
&
waittime
);
napi_create_int32
(
param
->
env
,
param
->
option
->
GetWaitTime
(),
&
waittime
);
napi_value
argv
[
2
]
=
{
flags
,
waittime
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
flags
,
waittime
};
napi_new_instance
(
param
->
env
,
jsOptionConstructor
,
argc
,
argv
,
&
jsOption
);
napi_new_instance
(
param
->
env
,
jsOptionConstructor
,
argc
,
argv
,
&
jsOption
);
if
(
jsOption
==
nullptr
)
{
if
(
jsOption
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"new jsOption failed"
);
ZLOGE
(
LOG_LABEL
,
"new jsOption failed"
);
...
@@ -725,7 +730,7 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
...
@@ -725,7 +730,7 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
napi_create_string_utf8
(
env
,
desc
.
c_str
(),
desc
.
length
(),
&
jsDesc
);
napi_create_string_utf8
(
env
,
desc
.
c_str
(),
desc
.
length
(),
&
jsDesc
);
// create a new js remote object
// create a new js remote object
size_t
argc
=
1
;
size_t
argc
=
1
;
napi_value
argv
[
1
]
=
{
jsDesc
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
jsDesc
};
napi_value
jsRemoteObject
=
nullptr
;
napi_value
jsRemoteObject
=
nullptr
;
status
=
napi_new_instance
(
env
,
constructor
,
argc
,
argv
,
&
jsRemoteObject
);
status
=
napi_new_instance
(
env
,
constructor
,
argc
,
argv
,
&
jsRemoteObject
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to construct js RemoteObject"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to construct js RemoteObject"
);
...
@@ -791,20 +796,20 @@ static napi_value NAPI_RemoteObject_queryLocalInterface(napi_env env, napi_callb
...
@@ -791,20 +796,20 @@ static napi_value NAPI_RemoteObject_queryLocalInterface(napi_env env, napi_callb
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 1 parameters"
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 1 parameters"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 1"
);
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
std
::
string
descriptor
=
stringValue
;
std
::
string
descriptor
=
stringValue
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
...
@@ -818,7 +823,7 @@ static napi_value NAPI_RemoteObject_getLocalInterface(napi_env env, napi_callbac
...
@@ -818,7 +823,7 @@ static napi_value NAPI_RemoteObject_getLocalInterface(napi_env env, napi_callbac
{
{
size_t
argc
=
1
;
size_t
argc
=
1
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
napi_value
argv
[
1
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
1
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
if
(
argc
!=
expectedArgc
)
{
if
(
argc
!=
expectedArgc
)
{
...
@@ -826,21 +831,21 @@ static napi_value NAPI_RemoteObject_getLocalInterface(napi_env env, napi_callbac
...
@@ -826,21 +831,21 @@ static napi_value NAPI_RemoteObject_getLocalInterface(napi_env env, napi_callbac
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
if
(
valueType
!=
napi_string
)
{
if
(
valueType
!=
napi_string
)
{
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
ZLOGE
(
LOG_LABEL
,
"type mismatch for parameter 1"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
nullptr
,
0
,
&
bufferSize
);
if
(
bufferSize
>=
maxLen
)
{
if
(
bufferSize
>=
maxLen
)
{
ZLOGE
(
LOG_LABEL
,
"string length too large"
);
ZLOGE
(
LOG_LABEL
,
"string length too large"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
if
(
jsStringLength
!=
bufferSize
)
{
if
(
jsStringLength
!=
bufferSize
)
{
ZLOGE
(
LOG_LABEL
,
"string length wrong"
);
ZLOGE
(
LOG_LABEL
,
"string length wrong"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -938,6 +943,7 @@ void StubExecuteSendRequest(napi_env env, SendRequestParam *param)
...
@@ -938,6 +943,7 @@ void StubExecuteSendRequest(napi_env env, SendRequestParam *param)
napi_delete_reference
(
param
->
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsDataRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsDataRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsOptionRef
);
napi_delete_reference
(
param
->
env
,
param
->
callback
);
napi_delete_reference
(
param
->
env
,
param
->
callback
);
napi_close_handle_scope
(
param
->
env
,
scope
);
napi_close_handle_scope
(
param
->
env
,
scope
);
delete
param
;
delete
param
;
...
@@ -958,6 +964,7 @@ void StubExecuteSendRequest(napi_env env, SendRequestParam *param)
...
@@ -958,6 +964,7 @@ void StubExecuteSendRequest(napi_env env, SendRequestParam *param)
napi_delete_reference
(
param
->
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsCodeRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsDataRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsDataRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsReplyRef
);
napi_delete_reference
(
param
->
env
,
param
->
jsOptionRef
);
napi_close_handle_scope
(
param
->
env
,
scope
);
napi_close_handle_scope
(
param
->
env
,
scope
);
delete
param
;
delete
param
;
delete
work
;
delete
work
;
...
@@ -982,6 +989,7 @@ napi_value StubSendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32
...
@@ -982,6 +989,7 @@ napi_value StubSendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32
.
jsCodeRef
=
nullptr
,
.
jsCodeRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsOptionRef
=
nullptr
,
.
callback
=
nullptr
,
.
callback
=
nullptr
,
.
env
=
env
,
.
env
=
env
,
.
traceId
=
0
,
.
traceId
=
0
,
...
@@ -994,10 +1002,11 @@ napi_value StubSendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32
...
@@ -994,10 +1002,11 @@ napi_value StubSendRequestAsync(napi_env env, sptr<IRemoteObject> target, uint32
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
}
}
}
}
napi_create_reference
(
env
,
argv
[
0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
4
],
1
,
&
sendRequestParam
->
callback
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_3
],
1
,
&
sendRequestParam
->
jsOptionRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_4
],
1
,
&
sendRequestParam
->
callback
);
std
::
thread
t
(
StubExecuteSendRequest
,
env
,
sendRequestParam
);
std
::
thread
t
(
StubExecuteSendRequest
,
env
,
sendRequestParam
);
t
.
detach
();
t
.
detach
();
napi_value
result
=
nullptr
;
napi_value
result
=
nullptr
;
...
@@ -1024,6 +1033,7 @@ napi_value StubSendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint
...
@@ -1024,6 +1033,7 @@ napi_value StubSendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint
.
jsCodeRef
=
nullptr
,
.
jsCodeRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsDataRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsReplyRef
=
nullptr
,
.
jsOptionRef
=
nullptr
,
.
callback
=
nullptr
,
.
callback
=
nullptr
,
.
env
=
env
,
.
env
=
env
,
.
traceId
=
0
,
.
traceId
=
0
,
...
@@ -1036,9 +1046,10 @@ napi_value StubSendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint
...
@@ -1036,9 +1046,10 @@ napi_value StubSendRequestPromise(napi_env env, sptr<IRemoteObject> target, uint
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
StartAsyncTrace
(
HITRACE_TAG_RPC
,
(
sendRequestParam
->
traceValue
).
c_str
(),
sendRequestParam
->
traceId
);
}
}
}
}
napi_create_reference
(
env
,
argv
[
0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_0
],
1
,
&
sendRequestParam
->
jsCodeRef
);
napi_create_reference
(
env
,
argv
[
1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_1
],
1
,
&
sendRequestParam
->
jsDataRef
);
napi_create_reference
(
env
,
argv
[
2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_2
],
1
,
&
sendRequestParam
->
jsReplyRef
);
napi_create_reference
(
env
,
argv
[
ARGV_INDEX_3
],
1
,
&
sendRequestParam
->
jsOptionRef
);
std
::
thread
t
(
StubExecuteSendRequest
,
env
,
sendRequestParam
);
std
::
thread
t
(
StubExecuteSendRequest
,
env
,
sendRequestParam
);
t
.
detach
();
t
.
detach
();
return
promise
;
return
promise
;
...
@@ -1049,31 +1060,31 @@ static napi_value NAPI_RemoteObject_sendRequest(napi_env env, napi_callback_info
...
@@ -1049,31 +1060,31 @@ static napi_value NAPI_RemoteObject_sendRequest(napi_env env, napi_callback_info
size_t
argc
=
4
;
size_t
argc
=
4
;
size_t
argcCallback
=
5
;
size_t
argcCallback
=
5
;
size_t
argcPromise
=
4
;
size_t
argcPromise
=
4
;
napi_value
argv
[
5
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
5
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
argcPromise
||
argc
==
argcCallback
,
"requires 4 or 5 parameters"
);
NAPI_ASSERT
(
env
,
argc
==
argcPromise
||
argc
==
argcCallback
,
"requires 4 or 5 parameters"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_number
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 2"
);
napi_typeof
(
env
,
argv
[
2
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
2
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 3"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 3"
);
napi_typeof
(
env
,
argv
[
3
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
3
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 4"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 4"
);
NAPI_MessageParcel
*
data
=
nullptr
;
NAPI_MessageParcel
*
data
=
nullptr
;
napi_status
status
=
napi_unwrap
(
env
,
argv
[
1
],
(
void
**
)
&
data
);
napi_status
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
1
],
(
void
**
)
&
data
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get data message parcel"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get data message parcel"
);
NAPI_MessageParcel
*
reply
=
nullptr
;
NAPI_MessageParcel
*
reply
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
2
],
(
void
**
)
&
reply
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
2
],
(
void
**
)
&
reply
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get reply message parcel"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get reply message parcel"
);
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
3
],
(
void
**
)
&
option
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
3
],
(
void
**
)
&
option
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get message option"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"failed to get message option"
);
int32_t
code
=
0
;
int32_t
code
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
code
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
code
);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
thisVar
);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
thisVar
);
if
(
argc
==
argcCallback
)
{
if
(
argc
==
argcCallback
)
{
...
@@ -1130,7 +1141,7 @@ static napi_value NAPI_RemoteObject_sendMessageRequest(napi_env env, napi_callba
...
@@ -1130,7 +1141,7 @@ static napi_value NAPI_RemoteObject_sendMessageRequest(napi_env env, napi_callba
size_t
argc
=
4
;
size_t
argc
=
4
;
size_t
argcCallback
=
5
;
size_t
argcCallback
=
5
;
size_t
argcPromise
=
4
;
size_t
argcPromise
=
4
;
napi_value
argv
[
5
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
5
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_value
checkArgsResult
=
NAPI_RemoteObject_checkSendMessageRequestArgs
(
env
,
argc
,
argcCallback
,
argcPromise
,
napi_value
checkArgsResult
=
NAPI_RemoteObject_checkSendMessageRequestArgs
(
env
,
argc
,
argcCallback
,
argcPromise
,
...
@@ -1139,25 +1150,25 @@ static napi_value NAPI_RemoteObject_sendMessageRequest(napi_env env, napi_callba
...
@@ -1139,25 +1150,25 @@ static napi_value NAPI_RemoteObject_sendMessageRequest(napi_env env, napi_callba
return
checkArgsResult
;
return
checkArgsResult
;
}
}
NAPI_MessageSequence
*
data
=
nullptr
;
NAPI_MessageSequence
*
data
=
nullptr
;
napi_status
status
=
napi_unwrap
(
env
,
argv
[
1
],
(
void
**
)
&
data
);
napi_status
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
1
],
(
void
**
)
&
data
);
if
(
status
!=
napi_ok
)
{
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"failed to get data message sequence"
);
ZLOGE
(
LOG_LABEL
,
"failed to get data message sequence"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
NAPI_MessageSequence
*
reply
=
nullptr
;
NAPI_MessageSequence
*
reply
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
2
],
(
void
**
)
&
reply
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
2
],
(
void
**
)
&
reply
);
if
(
status
!=
napi_ok
)
{
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"failed to get data message sequence"
);
ZLOGE
(
LOG_LABEL
,
"failed to get data message sequence"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
MessageOption
*
option
=
nullptr
;
MessageOption
*
option
=
nullptr
;
status
=
napi_unwrap
(
env
,
argv
[
3
],
(
void
**
)
&
option
);
status
=
napi_unwrap
(
env
,
argv
[
ARGV_INDEX_
3
],
(
void
**
)
&
option
);
if
(
status
!=
napi_ok
)
{
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"failed to get message option"
);
ZLOGE
(
LOG_LABEL
,
"failed to get message option"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
napi_get_value_int32
(
env
,
argv
[
0
],
&
code
);
napi_get_value_int32
(
env
,
argv
[
ARGV_INDEX_
0
],
&
code
);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
thisVar
);
sptr
<
IRemoteObject
>
target
=
NAPI_ohos_rpc_getNativeRemoteObject
(
env
,
thisVar
);
if
(
argc
==
argcCallback
)
{
if
(
argc
==
argcCallback
)
{
...
@@ -1177,29 +1188,29 @@ static napi_value NAPI_RemoteObject_attachLocalInterface(napi_env env, napi_call
...
@@ -1177,29 +1188,29 @@ static napi_value NAPI_RemoteObject_attachLocalInterface(napi_env env, napi_call
{
{
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
expectedArgc
=
2
;
size_t
expectedArgc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameters"
);
NAPI_ASSERT
(
env
,
argc
==
expectedArgc
,
"requires 2 parameters"
);
napi_valuetype
valueType
=
napi_null
;
napi_valuetype
valueType
=
napi_null
;
napi_typeof
(
env
,
argv
[
0
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
0
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_object
,
"type mismatch for parameter 1"
);
napi_typeof
(
env
,
argv
[
1
],
&
valueType
);
napi_typeof
(
env
,
argv
[
ARGV_INDEX_
1
],
&
valueType
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 2"
);
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"type mismatch for parameter 2"
);
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
1
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
1
],
nullptr
,
0
,
&
bufferSize
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
NAPI_ASSERT
(
env
,
bufferSize
<
maxLen
,
"string length too large"
);
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
1
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
1
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
std
::
string
descriptor
=
stringValue
;
std
::
string
descriptor
=
stringValue
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
napi_unwrap
(
env
,
thisVar
,
(
void
*
*
)
&
holder
);
napi_unwrap
(
env
,
thisVar
,
(
void
*
*
)
&
holder
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
holder
->
attachLocalInterface
(
argv
[
0
],
descriptor
);
holder
->
attachLocalInterface
(
argv
[
ARGV_INDEX_
0
],
descriptor
);
napi_value
result
=
nullptr
;
napi_value
result
=
nullptr
;
napi_get_undefined
(
env
,
&
result
);
napi_get_undefined
(
env
,
&
result
);
...
@@ -1233,7 +1244,7 @@ napi_value NAPI_RemoteObject_checkModifyLocalInterfaceArgs(napi_env env, size_t
...
@@ -1233,7 +1244,7 @@ napi_value NAPI_RemoteObject_checkModifyLocalInterfaceArgs(napi_env env, size_t
static
napi_value
NAPI_RemoteObject_modifyLocalInterface
(
napi_env
env
,
napi_callback_info
info
)
static
napi_value
NAPI_RemoteObject_modifyLocalInterface
(
napi_env
env
,
napi_callback_info
info
)
{
{
size_t
argc
=
2
;
size_t
argc
=
2
;
napi_value
argv
[
2
]
=
{
0
};
napi_value
argv
[
ARGV_LENGTH_
2
]
=
{
0
};
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
nullptr
);
napi_value
checkArgsResult
=
NAPI_RemoteObject_checkModifyLocalInterfaceArgs
(
env
,
argc
,
argv
);
napi_value
checkArgsResult
=
NAPI_RemoteObject_checkModifyLocalInterfaceArgs
(
env
,
argc
,
argv
);
...
@@ -1242,14 +1253,14 @@ static napi_value NAPI_RemoteObject_modifyLocalInterface(napi_env env, napi_call
...
@@ -1242,14 +1253,14 @@ static napi_value NAPI_RemoteObject_modifyLocalInterface(napi_env env, napi_call
}
}
size_t
bufferSize
=
0
;
size_t
bufferSize
=
0
;
size_t
maxLen
=
40960
;
size_t
maxLen
=
40960
;
napi_get_value_string_utf8
(
env
,
argv
[
1
],
nullptr
,
0
,
&
bufferSize
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
1
],
nullptr
,
0
,
&
bufferSize
);
if
(
bufferSize
>=
maxLen
)
{
if
(
bufferSize
>=
maxLen
)
{
ZLOGE
(
LOG_LABEL
,
"string length too large"
);
ZLOGE
(
LOG_LABEL
,
"string length too large"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
}
}
char
stringValue
[
bufferSize
+
1
];
char
stringValue
[
bufferSize
+
1
];
size_t
jsStringLength
=
0
;
size_t
jsStringLength
=
0
;
napi_get_value_string_utf8
(
env
,
argv
[
1
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
ARGV_INDEX_
1
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
if
(
jsStringLength
!=
bufferSize
)
{
if
(
jsStringLength
!=
bufferSize
)
{
ZLOGE
(
LOG_LABEL
,
"string length wrong"
);
ZLOGE
(
LOG_LABEL
,
"string length wrong"
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
return
napiErr
.
ThrowError
(
env
,
errorDesc
::
CHECK_PARAM_ERROR
);
...
@@ -1262,7 +1273,7 @@ static napi_value NAPI_RemoteObject_modifyLocalInterface(napi_env env, napi_call
...
@@ -1262,7 +1273,7 @@ static napi_value NAPI_RemoteObject_modifyLocalInterface(napi_env env, napi_call
ZLOGE
(
LOG_LABEL
,
"failed to get napi remote object holder"
);
ZLOGE
(
LOG_LABEL
,
"failed to get napi remote object holder"
);
return
nullptr
;
return
nullptr
;
}
}
holder
->
attachLocalInterface
(
argv
[
0
],
descriptor
);
holder
->
attachLocalInterface
(
argv
[
ARGV_INDEX_
0
],
descriptor
);
napi_value
result
=
nullptr
;
napi_value
result
=
nullptr
;
napi_get_undefined
(
env
,
&
result
);
napi_get_undefined
(
env
,
&
result
);
...
...
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
浏览文件 @
d30c80ff
...
@@ -39,7 +39,7 @@ NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16strin
...
@@ -39,7 +39,7 @@ NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16strin
localInterfaceRef_
(
nullptr
),
attachCount_
(
1
),
jsObjectRef_
(
nullptr
)
localInterfaceRef_
(
nullptr
),
attachCount_
(
1
),
jsObjectRef_
(
nullptr
)
{
{
jsThreadId_
=
std
::
this_thread
::
get_id
();
jsThreadId_
=
std
::
this_thread
::
get_id
();
// create weak ref,
do not need to delete
,
// create weak ref,
need call napi_delete_reference to release memory
,
// increase ref count when the JS object will transfer to another thread or process.
// increase ref count when the JS object will transfer to another thread or process.
napi_create_reference
(
env
,
thisVar
,
0
,
&
jsObjectRef_
);
napi_create_reference
(
env
,
thisVar
,
0
,
&
jsObjectRef_
);
...
@@ -52,10 +52,54 @@ NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16strin
...
@@ -52,10 +52,54 @@ NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16strin
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
{
{
if
(
env_
!=
nullptr
)
{
if
(
env_
==
nullptr
)
{
napi_status
status
=
napi_remove_env_cleanup_hook
(
env_
,
OnEnvCleanUp
,
this
);
ZLOGE
(
LOG_LABEL
,
"js env has been destructed"
);
return
;
}
napi_status
status
=
napi_remove_env_cleanup_hook
(
env_
,
OnEnvCleanUp
,
this
);
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"remove cleanup hook failed"
);
}
if
(
localInterfaceRef_
!=
nullptr
)
{
status
=
napi_delete_reference
(
env_
,
localInterfaceRef_
);
if
(
status
!=
napi_ok
)
{
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"remove cleanup hook failed"
);
ZLOGE
(
LOG_LABEL
,
"failed to delete ref"
);
}
}
if
(
jsObjectRef_
!=
nullptr
)
{
if
(
jsThreadId_
==
std
::
this_thread
::
get_id
())
{
status
=
napi_delete_reference
(
env_
,
jsObjectRef_
);
if
(
status
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"failed to delete ref"
);
}
}
else
{
uv_loop_s
*
loop
=
nullptr
;
napi_get_uv_event_loop
(
env_
,
&
loop
);
uv_work_t
*
work
=
new
(
std
::
nothrow
)
uv_work_t
;
if
(
work
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"failed to new work"
);
return
;
}
OperateJsRefParam
*
param
=
new
OperateJsRefParam
{
.
env
=
env_
,
.
thisVarRef
=
jsObjectRef_
};
work
->
data
=
reinterpret_cast
<
void
*>
(
param
);
uv_queue_work
(
loop
,
work
,
[](
uv_work_t
*
work
)
{},
[](
uv_work_t
*
work
,
int
status
)
{
OperateJsRefParam
*
param
=
reinterpret_cast
<
OperateJsRefParam
*>
(
work
->
data
);
napi_handle_scope
scope
=
nullptr
;
napi_open_handle_scope
(
param
->
env
,
&
scope
);
napi_status
napiStatus
=
napi_delete_reference
(
param
->
env
,
param
->
thisVarRef
);
if
(
napiStatus
!=
napi_ok
)
{
ZLOGE
(
LOG_LABEL
,
"failed to delete ref on uv work"
);
}
napi_close_handle_scope
(
param
->
env
,
scope
);
delete
param
;
delete
work
;
});
}
}
}
}
}
}
...
@@ -116,6 +160,9 @@ void NAPIRemoteObjectHolder::attachLocalInterface(napi_value localInterface, std
...
@@ -116,6 +160,9 @@ void NAPIRemoteObjectHolder::attachLocalInterface(napi_value localInterface, std
ZLOGE
(
LOG_LABEL
,
"Js env has been destructed"
);
ZLOGE
(
LOG_LABEL
,
"Js env has been destructed"
);
return
;
return
;
}
}
if
(
localInterfaceRef_
!=
nullptr
)
{
napi_delete_reference
(
env_
,
localInterfaceRef_
);
}
napi_create_reference
(
env_
,
localInterface
,
0
,
&
localInterfaceRef_
);
napi_create_reference
(
env_
,
localInterface
,
0
,
&
localInterfaceRef_
);
descriptor_
=
Str8ToStr16
(
descriptor
);
descriptor_
=
Str8ToStr16
(
descriptor
);
}
}
...
...
ipc/native/test/unittest/common/BUILD.gn
浏览文件 @
d30c80ff
...
@@ -374,12 +374,33 @@ ohos_unittest("IPCSoDlcloseTest") {
...
@@ -374,12 +374,33 @@ ohos_unittest("IPCSoDlcloseTest") {
resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml"
resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml"
}
}
ohos_unittest("IPCBlockThreadTest") {
module_out_path = MODULE_OUTPUT_PATH
include_dirs = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
"$SUBSYSTEM_DIR/utils/include",
]
sources = [ "ipc_block_thread_unittest.cpp" ]
deps = [
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [ "ipc:ipc_single" ]
resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml"
}
###############################################################################
###############################################################################
group("unittest") {
group("unittest") {
testonly = true
testonly = true
deps = [
deps = [
":BinderConnectorTest",
":BinderConnectorTest",
":BinderInvokerUnitTest",
":BinderInvokerUnitTest",
":IPCBlockThreadTest",
":IPCCInterfaceUnitTest",
":IPCCInterfaceUnitTest",
":IPCFileDescOpsTest",
":IPCFileDescOpsTest",
":IPCHiTraceUnitTest",
":IPCHiTraceUnitTest",
...
...
ipc/native/test/unittest/common/ipc_block_thread_unittest.cpp
0 → 100644
浏览文件 @
d30c80ff
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "ipc_skeleton.h"
using
namespace
testing
::
ext
;
using
namespace
OHOS
;
class
IpcBlockThreadTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
);
static
void
TearDownTestCase
(
void
);
void
SetUp
();
void
TearDown
();
};
void
IpcBlockThreadTest
::
SetUpTestCase
()
{
}
void
IpcBlockThreadTest
::
TearDownTestCase
()
{
}
void
IpcBlockThreadTest
::
SetUp
()
{
}
void
IpcBlockThreadTest
::
TearDown
()
{
}
/**
* @tc.name: BlockUntilThreadAvailableTest001
* @tc.desc: Verify the BlockUntilThreadAvailable function
* @tc.type: FUNC
*/
HWTEST_F
(
IpcBlockThreadTest
,
BlockUntilThreadAvailableTest001
,
TestSize
.
Level1
)
{
bool
test
=
false
;
if
(
!
test
)
{
IPCDfx
::
BlockUntilThreadAvailable
();
test
=
true
;
}
EXPECT_EQ
(
test
,
true
);
}
\ No newline at end of file
ipc/native/test/unittest/common/message_parcel_unittest.cpp
浏览文件 @
d30c80ff
...
@@ -279,7 +279,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest004, TestSize.Level1)
...
@@ -279,7 +279,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest004, TestSize.Level1)
parcel
.
rawDataSize_
=
1
;
parcel
.
rawDataSize_
=
1
;
parcel
.
writeRawDataFd_
=
0
;
parcel
.
writeRawDataFd_
=
0
;
auto
ret
=
parcel
.
ReadRawData
(
1
);
auto
ret
=
parcel
.
ReadRawData
(
1
);
ASSERT_TRUE
(
ret
=
=
nullptr
);
ASSERT_TRUE
(
ret
!
=
nullptr
);
}
}
/**
/**
...
@@ -327,7 +327,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest007, TestSize.Level1)
...
@@ -327,7 +327,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest007, TestSize.Level1)
parcel
.
writeRawDataFd_
=
0
;
parcel
.
writeRawDataFd_
=
0
;
parcel
.
rawData_
=
std
::
make_shared
<
char
>
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
parcel
.
rawData_
=
std
::
make_shared
<
char
>
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
auto
ret
=
parcel
.
ReadRawData
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
auto
ret
=
parcel
.
ReadRawData
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
ASSERT_TRUE
(
ret
=
=
nullptr
);
ASSERT_TRUE
(
ret
!
=
nullptr
);
}
}
/**
/**
...
@@ -342,7 +342,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest008, TestSize.Level1)
...
@@ -342,7 +342,7 @@ HWTEST_F(MessageParcelTest, ReadRawDataTest008, TestSize.Level1)
parcel
.
rawData_
=
std
::
make_shared
<
char
>
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
parcel
.
rawData_
=
std
::
make_shared
<
char
>
(
MessageParcel
::
MIN_RAWDATA_SIZE
+
1
);
parcel
.
writeRawDataFd_
=
0
;
parcel
.
writeRawDataFd_
=
0
;
auto
ret
=
parcel
.
ReadRawData
(
MessageParcel
::
MIN_RAWDATA_SIZE
);
auto
ret
=
parcel
.
ReadRawData
(
MessageParcel
::
MIN_RAWDATA_SIZE
);
ASSERT_TRUE
(
ret
=
=
nullptr
);
ASSERT_TRUE
(
ret
!
=
nullptr
);
}
}
/**
/**
...
...
ipc/native/test/unittest/js/BUILD.gn
浏览文件 @
d30c80ff
...
@@ -17,7 +17,8 @@ module_output_path = "ipc/"
...
@@ -17,7 +17,8 @@ module_output_path = "ipc/"
ohos_js_unittest("IPCjsTest") {
ohos_js_unittest("IPCjsTest") {
module_out_path = module_output_path
module_out_path = module_output_path
hap_profile = "./config.json"
hap_profile = "./config.json"
certificate_profile = "//test/developertest/signature/openharmony_sx.p7b"
certificate_profile =
"//test/testfwk/developer_test/signature/openharmony_sx.p7b"
}
}
group("unittest") {
group("unittest") {
...
...
ipc/native/test/unittest/rust/client/src/main.rs
浏览文件 @
d30c80ff
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
#![allow(clippy::needless_borrow)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::bool_assert_comparison)]
#![allow(clippy::bool_assert_comparison)]
#![allow(non_snake_case)]
#![allow(non_snake_case)]
extern
crate
ipc_rust
;
extern
crate
ipc_rust
;
...
@@ -28,6 +28,7 @@ use ipc_rust::{
...
@@ -28,6 +28,7 @@ use ipc_rust::{
get_self_token_id
,
get_calling_pid
,
get_calling_uid
,
IMsgParcel
,
IpcResult
,
get_self_token_id
,
get_calling_pid
,
get_calling_uid
,
IMsgParcel
,
IpcResult
,
RawData
,
set_max_work_thread
,
reset_calling_identity
,
set_calling_identity
,
RawData
,
set_max_work_thread
,
reset_calling_identity
,
set_calling_identity
,
is_local_calling
,
get_local_device_id
,
get_calling_device_id
,
IpcStatusCode
,
is_local_calling
,
get_local_device_id
,
get_calling_device_id
,
IpcStatusCode
,
RemoteObj
,
};
};
use
ipc_rust
::{
Serialize
,
Deserialize
,
BorrowedMsgParcel
,
Ashmem
};
use
ipc_rust
::{
Serialize
,
Deserialize
,
BorrowedMsgParcel
,
Ashmem
};
...
@@ -806,4 +807,16 @@ fn test_get_interface_descriptor() {
...
@@ -806,4 +807,16 @@ fn test_get_interface_descriptor() {
let
descriptor
=
String16
::
new
(
TestProxy
::
get_descriptor
());
let
descriptor
=
String16
::
new
(
TestProxy
::
get_descriptor
());
let
ret
=
remote
.interface_descriptor
()
.expect
(
"get interface descriptor failed"
);
let
ret
=
remote
.interface_descriptor
()
.expect
(
"get interface descriptor failed"
);
assert_eq!
(
descriptor
.get_string
(),
ret
);
assert_eq!
(
descriptor
.get_string
(),
ret
);
}
}
\ No newline at end of file
#[test]
fn
test_get_interface_descriptor_002
()
{
let
remote
=
get_service
(
IPC_TEST_SERVICE_ID
)
.expect
(
"get itest service failed"
);
// SAFETY:
let
remote
=
unsafe
{
RemoteObj
::
from_raw_ciremoteobj
(
remote
.as_raw_ciremoteobj
())
.unwrap
()
};
let
descriptor
=
String16
::
new
(
TestProxy
::
get_descriptor
());
let
ret
=
remote
.interface_descriptor
()
.expect
(
"get interface descriptor failed"
);
assert_eq!
(
descriptor
.get_string
(),
ret
);
}
ipc/native/test/unittest/rust/server/src/main.rs
浏览文件 @
d30c80ff
...
@@ -136,7 +136,7 @@ fn main() {
...
@@ -136,7 +136,7 @@ fn main() {
// create stub
// create stub
let
service
=
TestStub
::
new_remote_stub
(
TestService
)
.expect
(
"create TestService success"
);
let
service
=
TestStub
::
new_remote_stub
(
TestService
)
.expect
(
"create TestService success"
);
add_service
(
&
service
.as_object
()
.expect
(
"get ITest service failed"
),
add_service
(
&
service
.as_object
()
.expect
(
"get ITest service failed"
),
IPC_TEST_SERVICE_ID
)
.expect
(
"add server to samgr failed"
);
IPC_TEST_SERVICE_ID
)
.expect
(
"add server to samgr failed"
);
println!
(
"join to ipc work thread"
);
println!
(
"join to ipc work thread"
);
join_work_thread
();
join_work_thread
();
}
}
\ No newline at end of file
services/dbinder/dbinder_service/include/dbinder_remote_listener.h
浏览文件 @
d30c80ff
...
@@ -66,7 +66,7 @@ private:
...
@@ -66,7 +66,7 @@ private:
static
constexpr
int
SEND_MSG_TIMEOUT_MS
=
200
;
static
constexpr
int
SEND_MSG_TIMEOUT_MS
=
200
;
DISALLOW_COPY_AND_MOVE
(
DBinderRemoteListener
);
DISALLOW_COPY_AND_MOVE
(
DBinderRemoteListener
);
std
::
mutex
busManager
Mutex_
;
std
::
mutex
resource
Mutex_
;
std
::
mutex
serverSessionMutex_
;
std
::
mutex
serverSessionMutex_
;
std
::
mutex
deviceMutex_
;
std
::
mutex
deviceMutex_
;
std
::
shared_ptr
<
ISessionService
>
softbusManager_
;
std
::
shared_ptr
<
ISessionService
>
softbusManager_
;
...
...
services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp
浏览文件 @
d30c80ff
...
@@ -36,7 +36,7 @@ DBinderRemoteListener::~DBinderRemoteListener()
...
@@ -36,7 +36,7 @@ DBinderRemoteListener::~DBinderRemoteListener()
bool
DBinderRemoteListener
::
StartListener
(
std
::
shared_ptr
<
DBinderRemoteListener
>
&
listener
)
bool
DBinderRemoteListener
::
StartListener
(
std
::
shared_ptr
<
DBinderRemoteListener
>
&
listener
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManager
Mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
resource
Mutex_
);
softbusManager_
=
ISessionService
::
GetInstance
();
softbusManager_
=
ISessionService
::
GetInstance
();
if
(
softbusManager_
==
nullptr
)
{
if
(
softbusManager_
==
nullptr
)
{
DBINDER_LOGE
(
LOG_LABEL
,
"fail to get softbus service"
);
DBINDER_LOGE
(
LOG_LABEL
,
"fail to get softbus service"
);
...
@@ -59,8 +59,7 @@ bool DBinderRemoteListener::StartListener(std::shared_ptr<DBinderRemoteListener>
...
@@ -59,8 +59,7 @@ bool DBinderRemoteListener::StartListener(std::shared_ptr<DBinderRemoteListener>
bool
DBinderRemoteListener
::
StopListener
()
bool
DBinderRemoteListener
::
StopListener
()
{
{
ClearDeviceLock
();
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
resourceMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManagerMutex_
);
if
(
softbusManager_
==
nullptr
)
{
if
(
softbusManager_
==
nullptr
)
{
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
return
false
;
return
false
;
...
@@ -154,8 +153,7 @@ bool DBinderRemoteListener::SendDataReply(const std::string &deviceId, const str
...
@@ -154,8 +153,7 @@ bool DBinderRemoteListener::SendDataReply(const std::string &deviceId, const str
bool
DBinderRemoteListener
::
CloseDatabusSession
(
const
std
::
string
&
deviceId
)
bool
DBinderRemoteListener
::
CloseDatabusSession
(
const
std
::
string
&
deviceId
)
{
{
EraseDeviceLock
(
deviceId
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
resourceMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManagerMutex_
);
if
(
softbusManager_
==
nullptr
)
{
if
(
softbusManager_
==
nullptr
)
{
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
return
false
;
return
false
;
...
@@ -175,23 +173,16 @@ bool DBinderRemoteListener::CloseDatabusSession(const std::string &deviceId)
...
@@ -175,23 +173,16 @@ bool DBinderRemoteListener::CloseDatabusSession(const std::string &deviceId)
std
::
shared_ptr
<
Session
>
DBinderRemoteListener
::
OpenSoftbusSession
(
const
std
::
string
&
peerDeviceId
)
std
::
shared_ptr
<
Session
>
DBinderRemoteListener
::
OpenSoftbusSession
(
const
std
::
string
&
peerDeviceId
)
{
{
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
resourceMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManagerMutex_
);
if
(
softbusManager_
==
nullptr
)
{
if
(
softbusManager_
==
nullptr
)
{
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
DBINDER_LOGE
(
LOG_LABEL
,
"softbus manager is null"
);
return
nullptr
;
}
auto
it
=
clientSessionMap_
.
find
(
peerDeviceId
);
if
(
it
!=
clientSessionMap_
.
end
())
{
return
it
->
second
;
}
}
std
::
shared_ptr
<
DeviceLock
>
lockInfo
=
QueryOrNewDeviceLock
(
peerDeviceId
);
if
(
lockInfo
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
}
// OpenSession is not thread-safe
auto
it
=
clientSessionMap_
.
find
(
peerDeviceId
);
std
::
lock_guard
<
std
::
mutex
>
lock_unique
(
lockInfo
->
mutex
);
if
(
it
!=
clientSessionMap_
.
end
())
{
return
it
->
second
;
}
std
::
shared_ptr
<
Session
>
session
=
softbusManager_
->
OpenSession
(
OWN_SESSION_NAME
,
PEER_SESSION_NAME
,
std
::
shared_ptr
<
Session
>
session
=
softbusManager_
->
OpenSession
(
OWN_SESSION_NAME
,
PEER_SESSION_NAME
,
peerDeviceId
,
std
::
string
(
""
),
Session
::
TYPE_BYTES
);
peerDeviceId
,
std
::
string
(
""
),
Session
::
TYPE_BYTES
);
if
(
session
==
nullptr
)
{
if
(
session
==
nullptr
)
{
...
@@ -199,10 +190,8 @@ std::shared_ptr<Session> DBinderRemoteListener::OpenSoftbusSession(const std::st
...
@@ -199,10 +190,8 @@ std::shared_ptr<Session> DBinderRemoteListener::OpenSoftbusSession(const std::st
DBinderService
::
ConvertToSecureDeviceID
(
peerDeviceId
).
c_str
());
DBinderService
::
ConvertToSecureDeviceID
(
peerDeviceId
).
c_str
());
return
nullptr
;
return
nullptr
;
}
}
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManagerMutex_
);
clientSessionMap_
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
Session
>>
(
peerDeviceId
,
session
));
clientSessionMap_
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
Session
>>
(
peerDeviceId
,
session
));
}
return
session
;
return
session
;
}
}
...
@@ -249,8 +238,7 @@ void DBinderRemoteListener::OnSessionClosed(std::shared_ptr<Session> session)
...
@@ -249,8 +238,7 @@ void DBinderRemoteListener::OnSessionClosed(std::shared_ptr<Session> session)
}
}
}
}
}
else
{
}
else
{
EraseDeviceLock
(
session
->
GetPeerDeviceId
());
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
resourceMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
busManagerMutex_
);
for
(
auto
it
=
clientSessionMap_
.
begin
();
it
!=
clientSessionMap_
.
end
();
it
++
)
{
for
(
auto
it
=
clientSessionMap_
.
begin
();
it
!=
clientSessionMap_
.
end
();
it
++
)
{
if
(
it
->
second
->
GetChannelId
()
==
session
->
GetChannelId
())
{
if
(
it
->
second
->
GetChannelId
()
==
session
->
GetChannelId
())
{
clientSessionMap_
.
erase
(
it
);
clientSessionMap_
.
erase
(
it
);
...
...