diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index 739a92f..d353981 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -116,6 +116,8 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_STOP_FAIL = -67026; constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_IS_START_INPUT_FAIL = -67027; constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL = -67028; + constexpr int32_t ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL = -67029; + constexpr int32_t ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL = -67030; // Hidump Helper error code constexpr int32_t ERR_DH_INPUT_HIDUMP_INVALID_ARGS = -68000; diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp index 43134ce..5857096 100644 --- a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "add_white_list_infos_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,11 +41,16 @@ void AddWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId, const MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IAddWhiteListInfosCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("AddWhiteListInfosCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(deviceId)) { + DHLOGE("AddWhiteListInfosCallbackProxy write deviceId failed"); return; } if (!data.WriteString(strJson)) { + DHLOGE("AddWhiteListInfosCallbackProxy write strJson failed"); return; } remote->SendRequest(static_cast(IAddWhiteListInfosCallback::Message::RESULT), data, reply, option); diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp index 41d9a82..1fab102 100644 --- a/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp +++ b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "add_white_list_infos_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ AddWhiteListInfosCallbackStub::~AddWhiteListInfosCallbackStub() int32_t AddWhiteListInfosCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IAddWhiteListInfosCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("AddWhiteListInfosCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IAddWhiteListInfosCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp index 8004c43..273763d 100644 --- a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "del_white_list_infos_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,8 +41,12 @@ void DelWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId) MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IDelWhiteListInfosCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DelWhiteListInfosCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(deviceId)) { + DHLOGE("DelWhiteListInfosCallbackProxy write deviceId failed"); return; } remote->SendRequest(static_cast(IDelWhiteListInfosCallback::Message::RESULT), data, reply, option); diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp index a659100..f8935d9 100644 --- a/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp +++ b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "del_white_list_infos_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ DelWhiteListInfosCallbackStub::~DelWhiteListInfosCallbackStub() int32_t DelWhiteListInfosCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IDelWhiteListInfosCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("DelWhiteListInfosCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IDelWhiteListInfosCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/distributed_input_sink_proxy.cpp b/interfaces/ipc/src/distributed_input_sink_proxy.cpp index 8f3dfaa..c7e3002 100644 --- a/interfaces/ipc/src/distributed_input_sink_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_sink_proxy.cpp @@ -15,6 +15,8 @@ #include "distributed_input_sink_proxy.h" +#include "distributed_hardware_log.h" + #include "dinput_errcode.h" namespace OHOS { @@ -31,6 +33,10 @@ int32_t DistributedInputSinkProxy::Init() { MessageParcel data; MessageParcel reply; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSinkProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } int32_t result = ERR_DH_INPUT_SINK_PROXY_INIT_FAIL; bool ret = SendRequest(IDistributedSinkInput::MessageCode::INIT, data, reply); if (ret) { @@ -43,6 +49,10 @@ int32_t DistributedInputSinkProxy::Release() { MessageParcel data; MessageParcel reply; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSinkProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } int32_t result = ERR_DH_INPUT_SINK_PROXY_RELEASE_FAIL; bool ret = SendRequest(IDistributedSinkInput::MessageCode::RELEASE, data, reply); if (ret) { @@ -55,11 +65,17 @@ int32_t DistributedInputSinkProxy::IsStartDistributedInput( const uint32_t& inputType, sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSinkProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteUint32(inputType)) { - return static_cast(DInputServerType::NULL_SERVER_TYPE); + DHLOGE("DistributedInputSinkProxy write inputType failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return static_cast(DInputServerType::NULL_SERVER_TYPE); + DHLOGE("DistributedInputSinkProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SINK_PROXY_IS_START_INPUT_FAIL; diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 7b546d7..0ea4372 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -15,6 +15,8 @@ #include "distributed_input_sink_stub.h" +#include "distributed_hardware_log.h" + #include "constants_dinput.h" #include "dinput_errcode.h" @@ -30,11 +32,16 @@ DistributedInputSinkStub::~DistributedInputSinkStub() int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("DistributedInputSinkStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; + } switch (code) { case static_cast(IDistributedSinkInput::MessageCode::INIT): { int32_t ret = Init(); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SINK_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub init write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } break; } @@ -42,7 +49,8 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & case static_cast(IDistributedSinkInput::MessageCode::RELEASE): { int32_t ret = Release(); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SINK_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub release write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } break; } @@ -53,7 +61,8 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & iface_cast(data.ReadRemoteObject()); int32_t ret = IsStartDistributedInput(inputType, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SINK_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub isStartDistributedInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } break; } diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 49e6418..bdbda45 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -15,6 +15,8 @@ #include "distributed_input_source_proxy.h" +#include "distributed_hardware_log.h" + #include "dinput_errcode.h" namespace OHOS { @@ -31,6 +33,10 @@ int32_t DistributedInputSourceProxy::Init() { MessageParcel data; MessageParcel reply; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } int32_t result = ERR_DH_INPUT_SOURCE_PROXY_INIT_FAIL; bool ret = SendRequest(IDistributedSourceInput::MessageCode::INIT, data, reply); if (ret) { @@ -44,6 +50,10 @@ int32_t DistributedInputSourceProxy::Release() MessageParcel data; MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_RELEASE_FAIL; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } bool ret = SendRequest(IDistributedSourceInput::MessageCode::RELEASE, data, reply); if (ret) { result = reply.ReadInt32(); @@ -55,17 +65,25 @@ int32_t DistributedInputSourceProxy::RegisterDistributedHardware(const std::stri const std::string& parameters, sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(devId)) { - return ERR_DH_INPUT_SOURCE_PROXY_REGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write devId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteString(dhId)) { - return ERR_DH_INPUT_SOURCE_PROXY_REGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write dhId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteString(parameters)) { - return ERR_DH_INPUT_SOURCE_PROXY_REGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write parameters failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_REGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_REGISTER_FAIL; @@ -80,14 +98,21 @@ int32_t DistributedInputSourceProxy::UnregisterDistributedHardware(const std::st sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(devId)) { - return ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write devId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteString(dhId)) { - return ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write dhId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_FAIL; @@ -103,14 +128,21 @@ int32_t DistributedInputSourceProxy::PrepareRemoteInput( sptr addWhiteListCallback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(deviceId)) { - return ERR_DH_INPUT_SOURCE_PROXY_PREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write deviceId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_PREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(addWhiteListCallback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_PREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write addWhiteListCallback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_PREPARE_FAIL; @@ -126,14 +158,21 @@ int32_t DistributedInputSourceProxy::UnprepareRemoteInput( sptr delWhiteListCallback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(deviceId)) { - return ERR_DH_INPUT_SOURCE_PROXY_UNPREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write deviceId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_UNPREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(delWhiteListCallback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_UNPREPARE_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write delWhiteListCallback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_UNPREPARE_FAIL; @@ -148,14 +187,21 @@ int32_t DistributedInputSourceProxy::StartRemoteInput( const std::string& deviceId, const uint32_t& inputTypes, sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(deviceId)) { - return ERR_DH_INPUT_SOURCE_PROXY_START_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write deviceId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteUint32(inputTypes)) { - return ERR_DH_INPUT_SOURCE_PROXY_START_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write inputTypes failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_START_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_START_FAIL; @@ -170,14 +216,21 @@ int32_t DistributedInputSourceProxy::StopRemoteInput( const std::string& deviceId, const uint32_t& inputTypes, sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteString(deviceId)) { - return ERR_DH_INPUT_SOURCE_PROXY_STOP_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write deviceId failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteUint32(inputTypes)) { - return ERR_DH_INPUT_SOURCE_PROXY_STOP_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write inputTypes failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return ERR_DH_INPUT_SOURCE_PROXY_STOP_WRITE_MSG_FAIL; + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_STOP_FAIL; @@ -192,11 +245,17 @@ int32_t DistributedInputSourceProxy::IsStartDistributedInput( const uint32_t& inputType, sptr callback) { MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("DistributedInputSourceProxy write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } if (!data.WriteUint32(inputType)) { - return static_cast(DInputServerType::NULL_SERVER_TYPE); + DHLOGE("DistributedInputSourceProxy write inputType failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } if (!data.WriteRemoteObject(callback->AsObject())) { - return static_cast(DInputServerType::NULL_SERVER_TYPE); + DHLOGE("DistributedInputSourceProxy write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } MessageParcel reply; int32_t result = ERR_DH_INPUT_SOURCE_PROXY_IS_START_INPUT_FAIL; diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 5cec346..7641643 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -15,6 +15,8 @@ #include "distributed_input_source_stub.h" +#include "distributed_hardware_log.h" + #include "constants_dinput.h" #include "dinput_errcode.h" @@ -31,7 +33,8 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel { int32_t ret = Init(); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub Init write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -40,7 +43,8 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc { int32_t ret = Release(); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub release write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -53,7 +57,8 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub registerDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -65,7 +70,8 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub unregisterDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -79,7 +85,8 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data iface_cast(data.ReadRemoteObject()); int32_t ret = PrepareRemoteInput(deviceId, callback, addCallback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub prepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -93,7 +100,8 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da iface_cast(data.ReadRemoteObject()); int32_t ret = UnprepareRemoteInput(deviceId, callback, delCallback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub unprepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -105,7 +113,8 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub startRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -117,7 +126,8 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub stopRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -128,7 +138,8 @@ int32_t DistributedInputSourceStub::HandleIsStartDistributedInput(MessageParcel sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = IsStartDistributedInput(inputType, callback); if (!reply.WriteInt32(ret)) { - return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL; + DHLOGE("DistributedInputSourceStub isStartDistributedInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; } @@ -136,6 +147,10 @@ int32_t DistributedInputSourceStub::HandleIsStartDistributedInput(MessageParcel int32_t DistributedInputSourceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("DistributedInputSourceStub read token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } switch (code) { case static_cast(IDistributedSourceInput::MessageCode::INIT): { return HandleInitDistributedHardware(reply); diff --git a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp index b4f8642..71fec32 100644 --- a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp @@ -15,6 +15,8 @@ #include "prepare_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" + #include "ipc_types.h" #include "parcel.h" @@ -40,7 +42,10 @@ void PrepareDInputCallbackProxy::OnResult(const std::string& deviceId, const int MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IPrepareDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("PrepareDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(deviceId)) { return; } diff --git a/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp index ea2c7e4..1425182 100644 --- a/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "prepare_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ PrepareDInputCallbackStub::~PrepareDInputCallbackStub() int32_t PrepareDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IPrepareDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("PrepareDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IPrepareDInputCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp index 7a876ea..d5af399 100644 --- a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "register_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,7 +41,10 @@ void RegisterDInputCallbackProxy::OnResult(const std::string& devId, const std:: MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IRegisterDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("RegisterDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(devId)) { return; } diff --git a/interfaces/ipc/src/register_d_input_call_back_stub.cpp b/interfaces/ipc/src/register_d_input_call_back_stub.cpp index 2a27581..1612719 100644 --- a/interfaces/ipc/src/register_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/register_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "register_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ RegisterDInputCallbackStub::~RegisterDInputCallbackStub() int32_t RegisterDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IRegisterDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("RegisterDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IRegisterDInputCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp index e7b5f44..0aafdca 100644 --- a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "start_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,14 +41,20 @@ void StartDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IStartDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("StartDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(devId)) { + DHLOGE("StartDInputCallbackProxy write devId failed"); return; } if (!data.WriteUint32(inputTypes)) { + DHLOGE("StartDInputCallbackProxy write inputTypes failed"); return; } if (!data.WriteInt32(status)) { + DHLOGE("StartDInputCallbackProxy write status failed"); return; } int32_t ret = remote->SendRequest( diff --git a/interfaces/ipc/src/start_d_input_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_call_back_stub.cpp index 31ba8dd..959a34a 100644 --- a/interfaces/ipc/src/start_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/start_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "start_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ StartDInputCallbackStub::~StartDInputCallbackStub() int32_t StartDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IStartDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("StartDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IStartDInputCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp index 4c9ffb7..246a1d2 100644 --- a/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "start_d_input_server_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,11 +41,16 @@ void StartDInputServerCallbackProxy::OnResult(const int32_t& status, const uint3 MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IStartDInputServerCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("StartDInputServerCallbackProxy write token valid failed"); + return; + } if (!data.WriteInt32(status)) { + DHLOGE("StartDInputServerCallbackProxy write status failed"); return; } if (!data.WriteUint32(inputTypes)) { + DHLOGE("StartDInputServerCallbackProxy write inputTypes failed"); return; } int32_t ret = remote->SendRequest( diff --git a/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp index 8667ee1..fd03ae5 100644 --- a/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp +++ b/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "start_d_input_server_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ StartDInputServerCallbackStub::~StartDInputServerCallbackStub() int32_t StartDInputServerCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IStartDInputServerCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("StartDInputServerCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IStartDInputServerCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp index 1d303eb..fa5c425 100644 --- a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "stop_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,14 +41,20 @@ void StopDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t& MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IStopDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("StopDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(devId)) { + DHLOGE("StopDInputCallbackProxy write devId failed"); return; } if (!data.WriteUint32(inputTypes)) { + DHLOGE("StopDInputCallbackProxy write inputTypes failed"); return; } if (!data.WriteInt32(status)) { + DHLOGE("StopDInputCallbackProxy write status failed"); return; } int32_t ret = remote->SendRequest( diff --git a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp index 6581dfa..d33340d 100644 --- a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "stop_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ StopDInputCallbackStub::~StopDInputCallbackStub() int32_t StopDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IStopDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("StopDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IStopDInputCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp index 396aa58..59913c6 100644 --- a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "unprepare_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,11 +41,16 @@ void UnprepareDInputCallbackProxy::OnResult(const std::string& deviceId, const i MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IUnprepareDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("UnprepareDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(deviceId)) { + DHLOGE("UnprepareDInputCallbackProxy write deviceId failed"); return; } if (!data.WriteInt32(status)) { + DHLOGE("UnprepareDInputCallbackProxy write status failed"); return; } int32_t ret = remote->SendRequest( diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp index c17a6b1..3df5e16 100644 --- a/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "unprepare_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ UnprepareDInputCallbackStub::~UnprepareDInputCallbackStub() int32_t UnprepareDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IUnprepareDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("UnprepareDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IUnprepareDInputCallback::Message msgCode = static_cast(code); switch (msgCode) { diff --git a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp index 4b7848a..ded082e 100644 --- a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp @@ -15,6 +15,7 @@ #include "unregister_d_input_call_back_proxy.h" +#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" @@ -40,14 +41,20 @@ void UnregisterDInputCallbackProxy::OnResult(const std::string& devId, const std MessageParcel data; MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(IUnregisterDInputCallback::GetDescriptor()); + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("UnregisterDInputCallbackProxy write token valid failed"); + return; + } if (!data.WriteString(devId)) { + DHLOGE("UnregisterDInputCallbackProxy write devId failed"); return; } if (!data.WriteString(dhId)) { + DHLOGE("UnregisterDInputCallbackProxy write dhId failed"); return; } if (!data.WriteInt32(status)) { + DHLOGE("UnregisterDInputCallbackProxy write status failed"); return; } int32_t ret = remote->SendRequest( diff --git a/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp index e891e50..6257c9e 100644 --- a/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp @@ -15,6 +15,7 @@ #include "unregister_d_input_call_back_stub.h" +#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" @@ -34,9 +35,9 @@ UnregisterDInputCallbackStub::~UnregisterDInputCallbackStub() int32_t UnregisterDInputCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IUnregisterDInputCallback::GetDescriptor()) { - return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("UnRegisterDInputCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; } IUnregisterDInputCallback::Message msgCode = static_cast(code); switch (msgCode) {