From 1208312d951642167b7c34c82af3e614f8628034 Mon Sep 17 00:00:00 2001 From: lixiangpeng5 Date: Thu, 10 Nov 2022 14:43:39 +0800 Subject: [PATCH] =?UTF-8?q?miscdevice=5Fservice=5Fproxy=E4=B8=ADread?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E6=B7=BB=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixiangpeng5 Change-Id: Ib3e57abe8cdf0415cbe2a98b9a2ac103f1929f80 --- .../src/miscdevice_service_proxy.cpp | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/frameworks/native/miscdevice/src/miscdevice_service_proxy.cpp b/frameworks/native/miscdevice/src/miscdevice_service_proxy.cpp index 7ac5555..80bf113 100644 --- a/frameworks/native/miscdevice/src/miscdevice_service_proxy.cpp +++ b/frameworks/native/miscdevice/src/miscdevice_service_proxy.cpp @@ -53,7 +53,12 @@ bool MiscdeviceServiceProxy::IsAbilityAvailable(MiscdeviceDeviceId groupID) MISC_HILOGE("sendRequest failed, ret : %{public}d", ret); return false; } - return reply.ReadBool(); + bool isAbilityAvailable; + if (!reply.ReadBool(isAbilityAvailable)) { + MISC_HILOGE("Parcel read failed"); + return false; + } + return isAbilityAvailable; } bool MiscdeviceServiceProxy::IsVibratorEffectAvailable(int32_t vibratorId, const std::string &effectType) @@ -82,7 +87,12 @@ bool MiscdeviceServiceProxy::IsVibratorEffectAvailable(int32_t vibratorId, const MISC_HILOGE("SendRequest failed, ret : %{public}d", ret); return false; } - return reply.ReadBool(); + bool isVibratorEffectAvailable; + if (!reply.ReadBool(isVibratorEffectAvailable)) { + MISC_HILOGE("Parcel read failed"); + return false; + } + return isVibratorEffectAvailable; } std::vector MiscdeviceServiceProxy::GetVibratorIdList() @@ -107,7 +117,11 @@ std::vector MiscdeviceServiceProxy::GetVibratorIdList() MISC_HILOGE("SendRequest failed, ret : %{public}d", ret); return idVec; } - uint32_t setCount = reply.ReadUint32(); + uint32_t setCount; + if (!reply.ReadUint32(setCount)) { + MISC_HILOGE("Parcel read failed"); + return idVec; + } if (setCount == 0 || setCount > MAX_VIBRATOR_COUNT) { MISC_HILOGE("setCount: %{public}d is invalid", setCount); return idVec; @@ -329,7 +343,12 @@ std::string MiscdeviceServiceProxy::GetVibratorParameter(int32_t vibratorId, con MISC_HILOGE("ret : %{public}d", ret); return ""; } - return reply.ReadString(); + std::string vibratorParameter; + if (!reply.ReadString(vibratorParameter)) { + MISC_HILOGE("Parcel read failed"); + return ""; + } + return vibratorParameter; } std::vector MiscdeviceServiceProxy::GetLightSupportId() @@ -353,7 +372,11 @@ std::vector MiscdeviceServiceProxy::GetLightSupportId() HiSysEvent::EventType::FAULT, "PKG_NAME", "GetLightSupportId", "ERROR_CODE", ret); MISC_HILOGE("sendRequest failed, ret : %{public}d", ret); } - uint32_t setCount = reply.ReadUint32(); + uint32_t setCount; + if (!reply.ReadUint32(setCount)) { + MISC_HILOGE("Parcel read failed"); + return idVec; + } if (setCount == 0 || setCount > MAX_LIGHT_COUNT) { MISC_HILOGE("setCount: %{public}d is invalid", setCount); return idVec; @@ -389,7 +412,12 @@ bool MiscdeviceServiceProxy::IsLightEffectSupport(int32_t lightId, const std::st MISC_HILOGE("sendRequest failed, ret : %{public}d", ret); return false; } - return reply.ReadBool(); + bool isLightEffectSupport; + if (!reply.ReadBool(isLightEffectSupport)) { + MISC_HILOGE("Parcel read failed"); + return false; + } + return isLightEffectSupport; } int32_t MiscdeviceServiceProxy::Light(int32_t id, uint64_t brightness, uint32_t timeOn, uint32_t timeOff) -- Gitee