oh-interfaces-ipc-to-service
你是一名高级图形图像开发工程师,现在将在Openharmony graphic_2d仓的rs_interfaces.cpp/.h文件中,新增一个透传接口 考虑到这一类需求有的依赖于硬件底层实现,有的不依赖,所以统一将透传通路开辟到rs_screen.cpp/.h这一层即可,并在rs_screen.cpp的新增接口实现中,适当留空供用户实现底层调用逻辑 该工作通常包含以下几个步骤:
-
询问用户接口声明:用户传入期望新增的接口声明。注意,当用户传入的接口声明不符合C++语法时,需要告知用户并询问正确的接口声明
-
询问用户接口更多信息:询问用户期望接口具有 @System鉴权还是@Foundation鉴权,这两个信息后面代码生成要用到
-
明晰参考接口:重点参考rs_interfaces.cpp/.h中的SetDualScreenState()接口和GetPanelPowerStatus()接口的调用链
-
新增透传通路:Client侧:由于graphic_2d仓的接口通路采用C/S架构,因此,在Client侧,通常需要在rs_interfaces.cpp/.h、rs_render_service_client.cpp/.h中新增接口
-
新增透传通路:Service侧:在Service侧,通常需要在rs_client_to_service_connection.cpp/.h,rs_screen_manager.cpp/.h,rs_screen.cpp/.h中新增接口
-
新增透传通路:IPC:在graphic_2d仓中,Client侧到Service侧通过IPC实现,你需要在rs_iclient_to_service_connection.h这个抽象类中添加新接口的声明,在rs_client_to_service_connection_proxy.cpp/.h根据接口的形参列表和返回值调用MessageParcel和SendRequest的能力,在rs_client_to_service_connection_stub.cpp的OnRemoteRequest()函数中添加一个case用于响应proxy的请求,包括读取MessageParcel,调用rs_client_to_service_connection.cpp的新增接口,并将调用结果通过MessageParcel写回给Client侧。此外,有一个注意点: 1)case有个专门的枚举值存储在rs_iclient_to_service_connection_ipc_interface_code.h中,当需要新增接口时,你需要同步在这个文件中添加新枚举;
-
新增透传通路:鉴权相关事项:对于rs_iclient_to_service_connection_ipc_interface_code.h中新增的枚举值,还有两个地方会使用到: 1)在rs_client_to_service_connection_stub.cpp的descriptorCheckList中,需要新增这个枚举值; 2)在rs_irender_service_connection_ipc_interface_code_access_verifier.cpp的IsExclusiveVerificat函数中,需要新增一个case,根据用户期望的鉴权方式,调用IsSystemCalling或IsFoundationCalling进行鉴权
-
检查代码:最后,你需要检查代码修改是否严格遵循C++ 17的语法,以及是否和已有代码保持高度风格一致(例如函数名双驼峰,变量名单驼峰)
More from openharmonyinsight/openharmony-skills
openharmony-security-review
Use when reviewing OpenHarmony C++ system service code for security vulnerabilities, particularly IPC handlers, multithreaded components, or code handling sensitive user data
77openharmony-cpp
Expert coding guide for OpenHarmony C++ development. Use this skill when writing, refactoring, or reviewing C++ code for OpenHarmony projects. It enforces strict project-specific conventions (naming, formatting, headers) and critical security requirements (input validation, memory safety).
76oh-ut-generator
|
65cpp-core-guidelines-review
Parallel C++ Core Guidelines code review using multiple specialized sub-agents. Use when reviewing C++ code, modules, or files against C++ Core Guidelines to identify violations. Each sub-agent reviews against a specific guideline section (Functions, Classes, Resource Management, etc.) and outputs findings to separate markdown files in the review/ directory, followed by a consolidated summary.
59openharmony-build
This skill should be used when the user asks to "编译 OpenHarmony", "build OpenHarmony", "编译完整代码", "执行编译", "编译 OpenHarmony 代码", "快速编译", "跳过gn编译", "fast-build", "编译测试", "编译测试用例", "build ace_engine_test", "编译 sdk", "编译 SDK", "build sdk", "build SDK", "编译 ohos-sdk", "编译测试列表", "build test list", "按列表编译测试", "编译指定测试", or mentions building the full OpenHarmony system, fast rebuild, test compilation, SDK compilation, or building tests from a target list. Handles complete build process including build execution, success verification, and failure log analysis with primary focus on out/{product}/build.log.
55ohos-chromium-security-review
|
55