diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 2cf9531cc937758c692bf980ce93f782e45661f3..89000da936f8a2844bc90fd0a3d215f7d1832361 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 c81222fb8eb66db6633a35cc25a19db4ef250579..8d7a92f8b6c6e9dba4f564ec1febf2ad0fa9d01e 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 a20ed41098730de36c3d605e8df187d564d1a33e..5312810632804e19f06cd8f539f7a5303e5c8a6d 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) {