change capi interface

Signed-off-by: hubin <hubin29@huawei.com>
This commit is contained in:
hubin 2024-05-07 20:12:09 +08:00
parent ff9b7ddc8d
commit c19d0632bb
15 changed files with 53 additions and 47 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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/"

View File

@ -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
*/

View File

@ -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
}

View File

@ -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框架tokenIdPID/UID线C接口.
*
* @library libipc_ndk.so
* @library libipc_capi.so
* @since 12
*/

View File

@ -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
*/

View File

@ -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"

View File

@ -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",

View File

@ -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" },

View File

@ -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;

View File

@ -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",
]

View File

@ -55,7 +55,7 @@ struct PerformanceResult {
uint32_t average{ 0 };
};
using time_point = std::chrono::time_point<std::chrono::steady_clock>;
using TimePoint = std::chrono::time_point<std::chrono::steady_clock>;
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<uint32_t>(std::chrono::duration_cast<std::chrono::microseconds>(duration).count());

View File

@ -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);

View File

@ -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",