From 616664441dfcbe5237b4f26741d518d129951c63 Mon Sep 17 00:00:00 2001 From: wuqi0105 Date: Wed, 2 Mar 2022 18:39:56 +0800 Subject: [PATCH 1/2] test Signed-off-by: wuqi0105 --- common/include/dm_constants.h | 1 + .../native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp | 5 +++++ .../src/ipc/standard/ipc_server_stub.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 2cf9531cc..89000da93 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -73,6 +73,7 @@ enum { DM_IPC_SEND_REQUEST_FAILED, DM_IPC_NOT_REGISTER_FUNC, DM_IPC_RESPOND_ERROR, + DM_IPC_WRITE_TOKEN_ERROR, DM_DISCOVERY_REPEATED, DM_AUTH_NOT_SUPPORT, DM_AUTH_BUSINESS_BUSY, diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp index c81222fb8..8d7a92f8b 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp @@ -33,6 +33,11 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageParcel data; MessageParcel reply; MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + LOGE("WriteInterfaceToken fail!"); + return DM_IPC_WRITE_TOKEN_ERROR; + } + LOGE("WriteInterfaceToken success!"); if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { return DM_IPC_SEND_REQUEST_FAILED; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index a20ed4109..32e764ba9 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -81,6 +81,12 @@ void IpcServerStub::OnStop() int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { LOGI("code = %d, flags= %d.", code, option.GetFlags()); + auto remoteDescriptor = data.ReadInterfaceToken(); + if (GetDescriptor() != remoteDescriptor) { + LOGI("ReadInterfaceToken fail"); + return ERR_INVALID_STATE; + } + LOGI("ReadInterfaceToken success"); int32_t ret = DM_OK; ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply); if (ret == DM_IPC_NOT_REGISTER_FUNC) { -- Gitee From bce658d2aa2b97e5d9d5b114d3cc8716ce057d95 Mon Sep 17 00:00:00 2001 From: wuqi0105 Date: Wed, 2 Mar 2022 19:25:39 +0800 Subject: [PATCH 2/2] test1 Signed-off-by: wuqi0105 --- .../devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 32e764ba9..531281063 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -83,7 +83,7 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa LOGI("code = %d, flags= %d.", code, option.GetFlags()); auto remoteDescriptor = data.ReadInterfaceToken(); if (GetDescriptor() != remoteDescriptor) { - LOGI("ReadInterfaceToken fail"); + LOGI("ReadInterfaceToken fail"); return ERR_INVALID_STATE; } LOGI("ReadInterfaceToken success"); -- Gitee