diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index f7d1ba5..9115425 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -138,11 +138,11 @@ int32_t DistributedInputSinkStub::NotifyStopDScreenInner(MessageParcel &data, Me int32_t DistributedInputSinkStub::RegisterSharingDhIdListenerInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("RegisterSharingDhIdListenerInner failed, data.ReadRemoteObject is nullptr."); + sptr listener = iface_cast(data.ReadRemoteObject()); + if (listener == nullptr) { + DHLOGE("RegisterSharingDhIdListenerInner failed, listener is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr listener = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterSharingDhIdListener(listener); if (!reply.WriteInt32(ret)) { DHLOGE("RegisterSharingDhIdListenerInner write ret failed, ret = %d", ret); @@ -155,12 +155,12 @@ int32_t DistributedInputSinkStub::RegisterSharingDhIdListenerInner(MessageParcel int32_t DistributedInputSinkStub::RegisterGetSinkScreenInfosInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("RegisterGetSinkScreenInfosInner failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("RegisterGetSinkScreenInfosInner failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = RegisterGetSinkScreenInfosCallback(callback); if (!reply.WriteInt32(ret)) { DHLOGE("write ret failed, ret = %d", ret); diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 38d69d9..ff474b3 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -51,17 +51,17 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleRegisterDistributedHardware failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string devId = data.ReadString(); std::string dhId = data.ReadString(); std::string params = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub registerDistributedHardware write ret failed"); + DHLOGE("HandleRegisterDistributedHardware write ret failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; @@ -69,16 +69,16 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleUnregisterDistributedHardware failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string devId = data.ReadString(); std::string dhId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnregisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub unregisterDistributedHardware write ret failed"); + DHLOGE("HandleUnregisterDistributedHardware write ret failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } return DH_SUCCESS; @@ -86,12 +86,12 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandlePrepareRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string deviceId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = PrepareRemoteInput(deviceId, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandlePrepareRemoteInput write ret failed"); @@ -102,12 +102,12 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleUnprepareRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string deviceId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = UnprepareRemoteInput(deviceId, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleUnprepareRemoteInput write ret failed"); @@ -118,16 +118,16 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStartRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string deviceId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub startRemoteInput write ret failed"); + DHLOGE("HandleStartRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } return DH_SUCCESS; @@ -135,16 +135,16 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStopRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string deviceId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub stopRemoteInput write ret failed"); + DHLOGE("HandleStopRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } return DH_SUCCESS; @@ -152,17 +152,17 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStartRelayTypeRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub write ret failed"); + DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } return DH_SUCCESS; @@ -170,17 +170,17 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStopRelayTypeRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub write ret failed"); + DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } return DH_SUCCESS; @@ -188,13 +188,13 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandlePrepareRelayRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = PrepareRemoteInput(srcId, sinkId, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); @@ -205,13 +205,13 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleUnprepareRelayRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = UnprepareRemoteInput(srcId, sinkId, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); @@ -222,10 +222,6 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStartDhidRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string sinkId = data.ReadString(); std::vector tempVector; @@ -245,6 +241,10 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da } sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StartRemoteInput(sinkId, tempVector, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleStartDhidRemoteInput write ret failed"); @@ -255,10 +255,6 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStopDhidRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string sinkId = data.ReadString(); std::vector tempVector; @@ -278,6 +274,10 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat } sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StopRemoteInput(sinkId, tempVector, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleStopDhidRemoteInput write ret failed"); @@ -288,10 +288,6 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStartRelayDhidRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -312,6 +308,10 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce } sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StartRemoteInput(srcId, sinkId, tempVector, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); @@ -322,10 +322,6 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleStopRelayDhidRemoteInput failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -346,6 +342,10 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel } sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; + } int32_t ret = StopRemoteInput(srcId, sinkId, tempVector, callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); @@ -370,11 +370,11 @@ int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandleRegisterAddWhiteListCallback(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleRegisterAddWhiteListCallback failed, data.ReadRemoteObject is nullptr."); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterAddWhiteListCallback failed, callback is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterAddWhiteListCallback(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleRegisterAddWhiteListCallback write ret failed"); @@ -385,15 +385,11 @@ int32_t DistributedInputSourceStub::HandleRegisterAddWhiteListCallback(MessagePa int32_t DistributedInputSourceStub::HandleRegisterDelWhiteListCallback(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleRegisterDelWhiteListCallback failed, data.ReadRemoteObject is nullptr."); - return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; - } sptr callback = iface_cast(data.ReadRemoteObject()); if (callback == nullptr) { - DHLOGI("HandleRegisterDelWhiteListCallback callback is null"); + DHLOGE("HandleRegisterDelWhiteListCallback failed, callback is nullptr."); + return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - int32_t ret = RegisterDelWhiteListCallback(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleRegisterDelWhiteListCallback write ret failed"); @@ -404,11 +400,11 @@ int32_t DistributedInputSourceStub::HandleRegisterDelWhiteListCallback(MessagePa int32_t DistributedInputSourceStub::HandleRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleRegisterInputNodeListener failed, data.ReadRemoteObject is nullptr."); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterInputNodeListener failed, callback is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterInputNodeListener(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleRegisterInputNodeListener write ret failed"); @@ -420,11 +416,11 @@ int32_t DistributedInputSourceStub::HandleRegisterInputNodeListener(MessageParce int32_t DistributedInputSourceStub::HandleUnRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleUnRegisterInputNodeListener failed, data.ReadRemoteObject is nullptr."); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnRegisterInputNodeListener failed, callback is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterInputNodeListener(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleUnRegisterInputNodeListener write ret failed"); @@ -436,11 +432,11 @@ int32_t DistributedInputSourceStub::HandleUnRegisterInputNodeListener(MessagePar int32_t DistributedInputSourceStub::HandleRegisterSimulationEventListener(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleRegisterSimulationEventListener failed, data.ReadRemoteObject is nullptr."); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterSimulationEventListener failed, callback is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = RegisterSimulationEventListener(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleRegisterSimulationEventListener write ret failed, ret = %d", ret); @@ -452,11 +448,11 @@ int32_t DistributedInputSourceStub::HandleRegisterSimulationEventListener(Messag int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply) { - if (data.ReadRemoteObject() == nullptr) { - DHLOGE("HandleUnregisterSimulationEventListener failed, data.ReadRemoteObject is nullptr."); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnregisterSimulationEventListener failed, callback is nullptr."); return ERR_DH_INPUT_NULLPTR_NOT_VERIFY; } - sptr callback = iface_cast(data.ReadRemoteObject()); int32_t ret = UnregisterSimulationEventListener(callback); if (!reply.WriteInt32(ret)) { DHLOGE("HandleUnregisterSimulationEventListener write ret failed, ret = %d", ret);