diff --git a/BUILD.gn b/BUILD.gn index 35a7f5f8..6acccebf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -20,7 +20,7 @@ SUBSYSTEM_DIR = "//foundation/communication/ipc" group("ipc_components") { if (os_level == "standard") { deps = [ - "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_ndk", + "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi", "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core:ipc_core", "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_single:ipc_single", "$SUBSYSTEM_DIR/ipc/native/src/core:ipc_common", diff --git a/bundle.json b/bundle.json index d48242b9..ecd36d30 100644 --- a/bundle.json +++ b/bundle.json @@ -134,7 +134,7 @@ } }, { - "name": "//foundation/communication/ipc/interfaces/innerkits/c_api:ipc_ndk", + "name": "//foundation/communication/ipc/interfaces/innerkits/c_api:ipc_capi", "header": { "header_files": [ "ipc_cparcel.h", diff --git a/interfaces/innerkits/c_api/BUILD.gn b/interfaces/innerkits/c_api/BUILD.gn index d53e142f..a1636ff7 100644 --- a/interfaces/innerkits/c_api/BUILD.gn +++ b/interfaces/innerkits/c_api/BUILD.gn @@ -17,11 +17,11 @@ import("../../../config.gni") SUBSYSTEM_DIR = "../../.." IPC_CORE_ROOT = "$SUBSYSTEM_DIR/ipc/native" -config("libipc_ndk_private_config") { +config("libipc_capi_private_config") { cflags_cc = [ "-O2" ] } -ohos_shared_library("ipc_ndk") { +ohos_shared_library("ipc_capi") { include_dirs = [ "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", "$SUBSYSTEM_DIR/interfaces/innerkits/c_api/include", @@ -41,7 +41,7 @@ ohos_shared_library("ipc_ndk") { configs = [ "$SUBSYSTEM_DIR/config:ipc_util_config", - ":libipc_ndk_private_config", + ":libipc_capi_private_config", ] public_configs = [ "$SUBSYSTEM_DIR/config:ipc_util_config" ] @@ -60,7 +60,7 @@ ohos_shared_library("ipc_ndk") { "sasdk", ] - symlink_target_name = [ "libipc_ndk.so" ] + symlink_target_name = [ "libipc_capi.so" ] relative_install_dir = "./ndk/" diff --git a/interfaces/innerkits/c_api/include/ipc_cparcel.h b/interfaces/innerkits/c_api/include/ipc_cparcel.h index b00985b5..10a3123a 100644 --- a/interfaces/innerkits/c_api/include/ipc_cparcel.h +++ b/interfaces/innerkits/c_api/include/ipc_cparcel.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NDK_INCLUDE_IPC_CPARCEL_H -#define NDK_INCLUDE_IPC_CPARCEL_H +#ifndef CAPI_INCLUDE_IPC_CPARCEL_H +#define CAPI_INCLUDE_IPC_CPARCEL_H /** * @addtogroup OHIPCParcel @@ -31,7 +31,7 @@ * * @brief 提供IPC序列化/反序列化C接口. * - * @library libipc_ndk.so + * @library libipc_capi.so * @since 12 */ diff --git a/interfaces/innerkits/c_api/include/ipc_cremote_object.h b/interfaces/innerkits/c_api/include/ipc_cremote_object.h index d59b2e51..1f56c1ea 100644 --- a/interfaces/innerkits/c_api/include/ipc_cremote_object.h +++ b/interfaces/innerkits/c_api/include/ipc_cremote_object.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NDK_INCLUDE_IPC_CREMOTE_OBJECT_H -#define NDK_INCLUDE_IPC_CREMOTE_OBJECT_H +#ifndef CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H +#define CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H /** * @addtogroup OHIPCRemoteObject @@ -31,7 +31,7 @@ * * @brief 提供远端对象创建、销毁、数据发送、远端对象死亡状态监听等功能C接口. * - * @library libipc_ndk.so + * @library libipc_capi.so * @since 12 */ @@ -157,7 +157,7 @@ struct OH_IPC_MessageOption { * 其它返回{@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR}或用户自定义错误码. * @since 12 */ -int OH_IPC_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, +int OH_IPCRemoteProxy_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, OHIPCParcel *reply, const OH_IPC_MessageOption *option); /** @@ -176,7 +176,7 @@ int OH_IPC_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPC * 序列化读失败返回{@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR}. * @since 12 */ -int OH_IPC_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, +int OH_IPCRemoteProxy_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, OH_IPC_MemAllocator allocator); /** @@ -253,7 +253,7 @@ int OH_IPCRemoteProxy_RemoveDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRe * @return 远端OHIPCRemoteStub对象死亡返回1; 否则,返回0. 参数非法时,说明其远端OHIPCRemoteStub对象不存在,返回1. * @since 12 */ -int OH_IPC_IsRemoteDead(const OHIPCRemoteProxy *proxy); +int OH_IPCRemoteProxy_IsRemoteDead(const OHIPCRemoteProxy *proxy); #ifdef __cplusplus } diff --git a/interfaces/innerkits/c_api/include/ipc_cskeleton.h b/interfaces/innerkits/c_api/include/ipc_cskeleton.h index 6a36cec7..f79f64a4 100644 --- a/interfaces/innerkits/c_api/include/ipc_cskeleton.h +++ b/interfaces/innerkits/c_api/include/ipc_cskeleton.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NDK_INCLUDE_IPC_CSKELETON_H -#define NDK_INCLUDE_IPC_CSKELETON_H +#ifndef CAPI_INCLUDE_IPC_CSKELETON_H +#define CAPI_INCLUDE_IPC_CSKELETON_H /** * @addtogroup OHIPCSkeleton @@ -31,7 +31,7 @@ * * @brief 提供IPC框架tokenId、凭据、PID/UID、线程池配置等功能C接口. * - * @library libipc_ndk.so + * @library libipc_capi.so * @since 12 */ diff --git a/interfaces/innerkits/c_api/include/ipc_error_code.h b/interfaces/innerkits/c_api/include/ipc_error_code.h index 9b910d19..213c4d09 100644 --- a/interfaces/innerkits/c_api/include/ipc_error_code.h +++ b/interfaces/innerkits/c_api/include/ipc_error_code.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NDK_INCLUDE_IPC_ERROR_CODE_H -#define NDK_INCLUDE_IPC_ERROR_CODE_H +#ifndef CAPI_INCLUDE_IPC_ERROR_CODE_H +#define CAPI_INCLUDE_IPC_ERROR_CODE_H /** * @addtogroup OHIPCErrorCode @@ -31,7 +31,7 @@ * * @brief Provides IPC error code define. * - * @library libipc_ndk.so + * @library libipc_capi.so * @since 12 */ diff --git a/interfaces/innerkits/c_api/include/ipc_kit.h b/interfaces/innerkits/c_api/include/ipc_kit.h index 9530c3a3..0befe523 100644 --- a/interfaces/innerkits/c_api/include/ipc_kit.h +++ b/interfaces/innerkits/c_api/include/ipc_kit.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NDK_INCLUDE_IPC_KIT_H -#define NDK_INCLUDE_IPC_KIT_H +#ifndef CAPI_INCLUDE_IPC_KIT_H +#define CAPI_INCLUDE_IPC_KIT_H #include "ipc_error_code.h" #include "ipc_cparcel.h" diff --git a/interfaces/kits/ndk/BUILD.gn b/interfaces/kits/ndk/BUILD.gn index 9605d2df..3b2f595f 100644 --- a/interfaces/kits/ndk/BUILD.gn +++ b/interfaces/kits/ndk/BUILD.gn @@ -16,7 +16,7 @@ import("//build/ohos/ndk/ndk.gni") SUBSYSTEM_DIR = "../../.." -ohos_ndk_headers("ipc_ndk_header") { +ohos_ndk_headers("ipc_capi_header") { dest_dir = "$ndk_headers_out_dir/IPCKit" sources = [ "$SUBSYSTEM_DIR/interfaces/innerkits/c_api/include/ipc_cparcel.h", @@ -27,10 +27,10 @@ ohos_ndk_headers("ipc_ndk_header") { ] } -ohos_ndk_library("libipc_ndk") { - output_name = "ipc_ndk" +ohos_ndk_library("libipc_capi") { + output_name = "ipc_capi" output_extension = "so" - ndk_description_file = "./libipc_ndk.json" + ndk_description_file = "./libipc_capi.json" system_capability = "SystemCapability.Communication.IPC.Core" system_capability_headers = [ "IPCKit/ipc_cparcel.h", diff --git a/interfaces/kits/ndk/libipc_ndk.json b/interfaces/kits/ndk/libipc_capi.json similarity index 92% rename from interfaces/kits/ndk/libipc_ndk.json rename to interfaces/kits/ndk/libipc_capi.json index 91f58d0a..211f5b3c 100644 --- a/interfaces/kits/ndk/libipc_ndk.json +++ b/interfaces/kits/ndk/libipc_capi.json @@ -8,17 +8,19 @@ { "name": "OH_IPCSkeleton_GetCallingUid" }, { "name": "OH_IPCSkeleton_IsLocalCalling" }, { "name": "OH_IPCSkeleton_SetMaxWorkThreadNum" }, - { "name": "OH_IPCSkeleton_SetCallingIdentity" }, { "name": "OH_IPCSkeleton_ResetCallingIdentity" }, + { "name": "OH_IPCSkeleton_SetCallingIdentity" }, { "name": "OH_IPCSkeleton_IsHandlingTransaction" }, { "name": "OH_IPCRemoteStub_Create" }, { "name": "OH_IPCRemoteStub_Destroy" }, - { "name": "OH_IPC_SendRequest" }, + { "name": "OH_IPCRemoteProxy_Destroy" }, + { "name": "OH_IPCRemoteProxy_SendRequest" }, + { "name": "OH_IPCRemoteProxy_GetInterfaceDescriptor" }, { "name": "OH_IPCDeathRecipient_Create" }, { "name": "OH_IPCDeathRecipient_Destroy" }, { "name": "OH_IPCRemoteProxy_AddDeathRecipient" }, { "name": "OH_IPCRemoteProxy_RemoveDeathRecipient" }, - { "name": "OH_IPC_IsRemoteDead" }, + { "name": "OH_IPCRemoteProxy_IsRemoteDead" }, { "name": "OH_IPCParcel_Create" }, { "name": "OH_IPCParcel_Destroy" }, { "name": "OH_IPCParcel_GetDataSize" }, diff --git a/ipc/native/src/c_api/source/ipc_cremote_object.cpp b/ipc/native/src/c_api/source/ipc_cremote_object.cpp index 8c0e8a46..b0a812bf 100644 --- a/ipc/native/src/c_api/source/ipc_cremote_object.cpp +++ b/ipc/native/src/c_api/source/ipc_cremote_object.cpp @@ -121,7 +121,7 @@ static bool IsCodeValid(uint32_t code) return (code >= MIN_SEND_REQUEST_CODE) && (code <= MAX_SEND_REQUEST_CODE); } -int OH_IPC_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, +int OH_IPCRemoteProxy_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, OHIPCParcel *reply, const OH_IPC_MessageOption *option) { if (!IsIPCRemoteProxyValid(proxy, __func__) @@ -149,7 +149,7 @@ int OH_IPC_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPC return ConvertSendRequestError(ret); } -int OH_IPC_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, +int OH_IPCRemoteProxy_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, OH_IPC_MemAllocator allocator) { if (!IsIPCRemoteProxyValid(proxy, __func__) @@ -231,7 +231,7 @@ int OH_IPCRemoteProxy_RemoveDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRe return proxy->remote->RemoveDeathRecipient(recipient->recipient) ? OH_IPC_SUCCESS : OH_IPC_INNER_ERROR; } -int OH_IPC_IsRemoteDead(const OHIPCRemoteProxy *proxy) +int OH_IPCRemoteProxy_IsRemoteDead(const OHIPCRemoteProxy *proxy) { if (!IsIPCRemoteProxyValid(proxy, __func__)) { return 1; diff --git a/ipc/native/test/unittest/common/BUILD.gn b/ipc/native/test/unittest/common/BUILD.gn index 09081ce1..f9f8aa7c 100644 --- a/ipc/native/test/unittest/common/BUILD.gn +++ b/ipc/native/test/unittest/common/BUILD.gn @@ -373,7 +373,7 @@ ohos_unittest("IpcCApiUnitTest") { deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance", - "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_ndk", + "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] diff --git a/ipc/native/test/unittest/common/ipc_capi_parcel_unittest.cpp b/ipc/native/test/unittest/common/ipc_capi_parcel_unittest.cpp index a958bec4..8b50782b 100644 --- a/ipc/native/test/unittest/common/ipc_capi_parcel_unittest.cpp +++ b/ipc/native/test/unittest/common/ipc_capi_parcel_unittest.cpp @@ -55,7 +55,7 @@ struct PerformanceResult { uint32_t average{ 0 }; }; -using time_point = std::chrono::time_point; +using TimePoint = std::chrono::time_point; class IpcCApiParcelUnitTest : public testing::Test { public: @@ -64,7 +64,7 @@ public: void SetUp(); void TearDown(); - uint32_t CalcSpendTime(time_point &start, time_point &end); + uint32_t CalcSpendTime(TimePoint &start, TimePoint &end); void ReadWriteStringPerformance(PerformanceResult &writeResult, PerformanceResult &readResult); void ReadWriteStringCppPerformance(PerformanceResult &writeResult, PerformanceResult &readResult); void ReadWriteBufferPerformance(PerformanceResult &writeResult, PerformanceResult &readResult); @@ -113,7 +113,7 @@ void IpcCApiParcelUnitTest::SetUp() {} void IpcCApiParcelUnitTest::TearDown() {} -uint32_t IpcCApiParcelUnitTest::CalcSpendTime(time_point& start, time_point& end) +uint32_t IpcCApiParcelUnitTest::CalcSpendTime(TimePoint& start, TimePoint& end) { auto duration = end - start; return static_cast(std::chrono::duration_cast(duration).count()); diff --git a/ipc/native/test/unittest/common/ipc_capi_remote_object_unittest.cpp b/ipc/native/test/unittest/common/ipc_capi_remote_object_unittest.cpp index 309d82d8..eceba745 100644 --- a/ipc/native/test/unittest/common/ipc_capi_remote_object_unittest.cpp +++ b/ipc/native/test/unittest/common/ipc_capi_remote_object_unittest.cpp @@ -203,16 +203,20 @@ HWTEST_F(IpcCApiRemoteObjectUnitTest, SendRequestSync_001, TestSize.Level1) OHIPCParcel *replyParcel = OH_IPCParcel_Create(); OH_IPC_MessageOption option = {OH_IPC_REQUEST_MODE_SYNC, 0}; - int ret = OH_IPC_SendRequest(nullptr, TestCommand::TEST_CMD_GET_FOO_SERVICE, dataParcel, replyParcel, &option); + int ret = OH_IPCRemoteProxy_SendRequest(nullptr, TestCommand::TEST_CMD_GET_FOO_SERVICE, + dataParcel, replyParcel, &option); EXPECT_EQ(ret, OH_IPC_CHECK_PARAM_ERROR); - ret = OH_IPC_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, nullptr, replyParcel, &option); + ret = OH_IPCRemoteProxy_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, + nullptr, replyParcel, &option); EXPECT_EQ(ret, OH_IPC_CHECK_PARAM_ERROR); - ret = OH_IPC_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, dataParcel, nullptr, &option); + ret = OH_IPCRemoteProxy_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, + dataParcel, nullptr, &option); EXPECT_EQ(ret, OH_IPC_CHECK_PARAM_ERROR); - ret = OH_IPC_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, dataParcel, replyParcel, &option); + ret = OH_IPCRemoteProxy_SendRequest(remoteProxy, TestCommand::TEST_CMD_GET_FOO_SERVICE, + dataParcel, replyParcel, &option); EXPECT_EQ(ret, OH_IPC_SUCCESS); auto *fooProxy = OH_IPCParcel_ReadRemoteProxy(replyParcel); EXPECT_NE(fooProxy, nullptr); @@ -314,11 +318,11 @@ HWTEST_F(IpcCApiRemoteObjectUnitTest, IsRemoteDead_001, TestSize.Level1) auto *remoteProxy = CreateIPCRemoteProxy(objectServer); ASSERT_NE(remoteProxy, nullptr); - int ret = OH_IPC_IsRemoteDead(remoteProxy); + int ret = OH_IPCRemoteProxy_IsRemoteDead(remoteProxy); EXPECT_FALSE(ret); res = helper.StopTestApp(IPCTestHelper::IPC_TEST_SERVER); ASSERT_TRUE(res); - ret = OH_IPC_IsRemoteDead(remoteProxy); + ret = OH_IPCRemoteProxy_IsRemoteDead(remoteProxy); EXPECT_TRUE(ret); OH_IPCRemoteProxy_Destroy(remoteProxy); @@ -340,7 +344,7 @@ HWTEST_F(IpcCApiRemoteObjectUnitTest, GetInterfaceDescriptor_001, TestSize.Level char *descriptor = nullptr; int32_t len = 0; - int ret = OH_IPC_GetInterfaceDescriptor(remoteProxy, &descriptor, &len, MemAllocator); + int ret = OH_IPCRemoteProxy_GetInterfaceDescriptor(remoteProxy, &descriptor, &len, MemAllocator); EXPECT_EQ(ret, 0); EXPECT_EQ(strlen(descriptor) + 1, len); EXPECT_GE(len, 0); diff --git a/ipc/test/auxiliary/native/BUILD.gn b/ipc/test/auxiliary/native/BUILD.gn index d224b159..868c5f55 100644 --- a/ipc/test/auxiliary/native/BUILD.gn +++ b/ipc/test/auxiliary/native/BUILD.gn @@ -33,7 +33,7 @@ ohos_shared_library("ipc_test_helper") { "$SUBSYSTEM_DIR/config:ipc_util_config", ] - deps = [ "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_ndk" ] + deps = [ "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi" ] external_deps = [ "access_token:libnativetoken", @@ -82,7 +82,7 @@ ohos_executable("ipc_client_test") { deps = [ ":ipc_test_helper", - "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_ndk", + "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi", ] external_deps = [ @@ -117,7 +117,7 @@ ohos_shared_library("ipc_test_helper_extra") { "$SUBSYSTEM_DIR/config:ipc_util_config", ] - deps = [ "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_ndk" ] + deps = [ "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi" ] external_deps = [ "access_token:libnativetoken",