From 616664441dfcbe5237b4f26741d518d129951c63 Mon Sep 17 00:00:00 2001 From: wuqi0105 Date: Wed, 2 Mar 2022 18:39:56 +0800 Subject: [PATCH 1/4] 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/4] 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 From 46295773e6720d1265a0fc9758c9410b7b6f4e66 Mon Sep 17 00:00:00 2001 From: wuqi0105 Date: Mon, 7 Mar 2022 11:33:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?InterfaceToken=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuqi0105 --- .../native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp | 3 +-- .../native_cpp/src/ipc/standard/ipc_client_stub.cpp | 6 ++++++ .../src/ipc/standard/ipc_server_stub.cpp | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) 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 8d7a92f8b..973ce1152 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 @@ -35,9 +35,8 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { LOGE("WriteInterfaceToken fail!"); - return DM_IPC_WRITE_TOKEN_ERROR; + 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/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index 9cacbbf9c..aa022b55f 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -26,6 +26,12 @@ namespace DistributedHardware { int32_t IpcClientStub::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; + } + if (IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply) == DM_OK) { LOGE("on ipc cmd success"); return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 531281063..71b0bbabf 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -83,10 +83,10 @@ 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"); + int32_t ret = DM_OK; ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply); if (ret == DM_IPC_NOT_REGISTER_FUNC) { -- Gitee From 3c9a66668a00cd4f5ecf850c56ca3507e42aded1 Mon Sep 17 00:00:00 2001 From: wuqi0105 Date: Mon, 7 Mar 2022 14:54:13 +0800 Subject: [PATCH 4/4] =?UTF-8?q?InterfaceToken=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuqi0105 --- .../native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 973ce1152..345243a15 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 @@ -35,7 +35,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { LOGE("WriteInterfaceToken fail!"); - return DM_IPC_WRITE_TOKEN_ERROR; + return DM_IPC_WRITE_TOKEN_ERROR; } if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { return DM_IPC_SEND_REQUEST_FAILED; -- Gitee