From c7762953833916416f98e15c20c0056bc3837323 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 2cf9531c..89000da9 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 c81222fb..8d7a92f8 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 a20ed410..32e764ba 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) { From 562cb096f508c7adef8f86d5c0fa057d3536c171 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 32e764ba..53128106 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"); From 9a83a0655fa82fb4efcf4a7a0b36739c37efef54 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 8d7a92f8..973ce115 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 9cacbbf9..aa022b55 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 53128106..71b0bbab 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) { From d00af9d7e8cc8631bebe5b2b680d0236bce647b2 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 973ce115..345243a1 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;