From ef25e862091f316abdfcec55609f07bc5d96a114 Mon Sep 17 00:00:00 2001 From: caochao Date: Thu, 17 Feb 2022 10:29:37 +0800 Subject: [PATCH] The rectification that the same process cannot communicate with ipc Signed-off-by: cao_liu_chao --- .../src/ipc/standard/ipc_client_manager.cpp | 1 + .../src/ipc/standard/ipc_client_stub.cpp | 17 ++++++++++++++++- .../src/ipc/standard/ipc_server_stub.cpp | 15 ++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index cc4db5308..06ae13b75 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp @@ -18,6 +18,7 @@ #include "device_manager_notify.h" #include "dm_constants.h" #include "dm_log.h" +#include "ipc_client_server_proxy.h" #include "ipc_client_stub.h" #include "ipc_register_listener_req.h" #include "ipc_remote_broker.h" 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 748da1c82..1325fc3c1 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 @@ -35,7 +35,22 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { - LOGE("error"); + LOGI("SendCmd cmdCode: %d", cmdCode); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { + LOGE("set request cmd failed"); + return DM_IPC_FAILED; + } + + LOGI("code = %d, flags= %d.", code, option.GetFlags()); + if (IpcCmdRegister::GetInstance().OnIpcCmd(code, data, reply) == DM_OK) { + return DM_OK; + } + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); + + return DM_OK; } } // namespace DistributedHardware diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index d1b55df74..76c51b666 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -93,7 +93,20 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { LOGI("SendCmd cmdCode: %d", cmdCode); - return DM_OK; + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { + LOGE("set request cmd failed"); + return DM_IPC_FAILED; + } + + int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); + if (ret == DM_IPC_NOT_REGISTER_FUNC) { + LOGW("unsupport code: %d", cmdCode); + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); + } + return ret; } ServiceRunningState IpcServerStub::QueryServiceState() const -- Gitee