From 14bb4661e7d8ac93aa0abb7146e777778ab0206e Mon Sep 17 00:00:00 2001 From: shenpeixing Date: Tue, 11 Mar 2025 20:13:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8E=9Fproxy.cpp=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=89=93=E7=82=B9=E4=BF=A1=E6=81=AF=E7=A7=BB?= =?UTF-8?q?=E5=88=B0client=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenpeixing --- .../native/light/include/light_client.h | 1 + frameworks/native/light/src/light_client.cpp | 29 ++++++- .../include/vibrator_service_client.h | 2 + .../vibrator/src/vibrator_service_client.cpp | 84 ++++++++++++++++++- 4 files changed, 113 insertions(+), 3 deletions(-) diff --git a/frameworks/native/light/include/light_client.h b/frameworks/native/light/include/light_client.h index ba86858..13b25ee 100644 --- a/frameworks/native/light/include/light_client.h +++ b/frameworks/native/light/include/light_client.h @@ -39,6 +39,7 @@ private: int32_t InitLightClient(); bool IsLightAnimationValid(const LightAnimation &animation); bool IsLightIdValid(int32_t lightId); + void WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret); std::mutex lightInfosMutex_; LightInfo *lightInfos_ {nullptr}; int32_t lightInfoCount_ {-1}; diff --git a/frameworks/native/light/src/light_client.cpp b/frameworks/native/light/src/light_client.cpp index 1ae3ffa..ca9c658 100644 --- a/frameworks/native/light/src/light_client.cpp +++ b/frameworks/native/light/src/light_client.cpp @@ -94,6 +94,27 @@ bool LightClient::IsLightIdValid(int32_t lightId) return false; } +void LightClient::WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret) +{ +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + if (ret != NO_ERROR) { + switch (code) { + case IMiscdeviceServiceIpcCode::COMMAND_TURN_ON: + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOn", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_TURN_OFF: + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOff", "ERROR_CODE", ret); + break; + default: + MISC_HILOGW("Code does not exist, code:%{public}d", static_cast(code)); + break; + } + } +#endif // HIVIEWDFX_HISYSEVENT_ENABLE +} + int32_t LightClient::GetLightList(LightInfo **lightInfo, int32_t &count) { CALL_LOG_ENTER; @@ -149,7 +170,9 @@ int32_t LightClient::TurnOn(int32_t lightId, const LightColor &color, const Ligh animationIPC.SetMode(animation.mode); animationIPC.SetOnTime(animation.onTime); animationIPC.SetOffTime(animation.offTime); - return miscdeviceProxy_->TurnOn(lightId, color.singleColor, animationIPC); + int32_t ret = miscdeviceProxy_->TurnOn(lightId, color.singleColor, animationIPC); + WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_TURN_ON, ret); + return ret; } int32_t LightClient::TurnOff(int32_t lightId) @@ -161,7 +184,9 @@ int32_t LightClient::TurnOff(int32_t lightId) } std::lock_guard clientLock(clientMutex_); CHKPR(miscdeviceProxy_, ERROR); - return miscdeviceProxy_->TurnOff(lightId); + int32_t ret = miscdeviceProxy_->TurnOff(lightId); + WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_TURN_OFF, ret); + return ret; } void LightClient::ProcessDeathObserver(wptr object) diff --git a/frameworks/native/vibrator/include/vibrator_service_client.h b/frameworks/native/vibrator/include/vibrator_service_client.h index 34d33e3..9b5d1c5 100644 --- a/frameworks/native/vibrator/include/vibrator_service_client.h +++ b/frameworks/native/vibrator/include/vibrator_service_client.h @@ -88,6 +88,8 @@ private: void ConvertVibratorPattern(const VibratorPattern &vibratorPattern, VibratePattern &vibratePattern); bool SkipEventAndConvertVibratorEvent(const VibratorEvent &vibratorEvent, VibratePattern &vibratePattern, int32_t patternStartTime, VibrateEvent &vibrateEvent); + void WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret); + void WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret); sptr serviceDeathObserver_ = nullptr; sptr miscdeviceProxy_ = nullptr; sptr vibratorClient_ = nullptr; diff --git a/frameworks/native/vibrator/src/vibrator_service_client.cpp b/frameworks/native/vibrator/src/vibrator_service_client.cpp index b967d47..9252808 100644 --- a/frameworks/native/vibrator/src/vibrator_service_client.cpp +++ b/frameworks/native/vibrator/src/vibrator_service_client.cpp @@ -116,6 +116,7 @@ int32_t VibratorServiceClient::TransferClientRemoteObject() StartTrace(HITRACE_TAG_SENSORS, "TransferClientRemoteObject"); #endif // HIVIEWDFX_HITRACE_ENABLE int32_t ret = miscdeviceProxy_->TransferClientRemoteObject(remoteObject); + WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_TRANSFER_CLIENT_REMOTE_OBJECT, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -136,6 +137,7 @@ int32_t VibratorServiceClient::Vibrate(int32_t vibratorId, int32_t timeOut, int3 StartTrace(HITRACE_TAG_SENSORS, "VibrateTime"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->Vibrate(vibratorId, timeOut, usage, systemUsage); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_VIBRATE, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -161,6 +163,7 @@ int32_t VibratorServiceClient::Vibrate(int32_t vibratorId, const std::string &ef StartTrace(HITRACE_TAG_SENSORS, "VibrateEffect"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->PlayVibratorEffect(vibratorId, effect, loopCount, usage, systemUsage); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_PLAY_VIBRATOR_EFFECT, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -192,6 +195,7 @@ int32_t VibratorServiceClient::PlayVibratorCustom(int32_t vibratorId, const RawF vibateParameter.frequency = parameter.frequency; ret = miscdeviceProxy_->PlayVibratorCustom(vibratorId, rawFd.fd, rawFd.offset, rawFd.length, usage, systemUsage, vibateParameter); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_PLAY_VIBRATOR_CUSTOM, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -216,6 +220,7 @@ int32_t VibratorServiceClient::StopVibrator(int32_t vibratorId, const std::strin StartTrace(HITRACE_TAG_SENSORS, "StopVibratorByMode"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->StopVibratorByMode(vibratorId, mode); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_STOP_VIBRATOR_BY_MODE, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -239,6 +244,7 @@ int32_t VibratorServiceClient::StopVibrator(int32_t vibratorId) StartTrace(HITRACE_TAG_SENSORS, "StopVibratorAll"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->StopVibrator(vibratorId); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_STOP_VIBRATOR, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -273,6 +279,7 @@ int32_t VibratorServiceClient::IsSupportEffect(const std::string &effect, bool & StartTrace(HITRACE_TAG_SENSORS, "VibrateEffect"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->IsSupportEffect(effect, state); + WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_IS_SUPPORT_EFFECT, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -370,6 +377,7 @@ int32_t VibratorServiceClient::GetDelayTime(int32_t &delayTime) StartTrace(HITRACE_TAG_SENSORS, "GetDelayTime"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->GetDelayTime(delayTime); + WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_GET_DELAY_TIME, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -415,7 +423,9 @@ int32_t VibratorServiceClient::InitPlayPattern(const VibratorPattern &pattern, i vibateParameter.frequency = parameter.frequency; std::lock_guard clientLock(clientMutex_); CHKPR(miscdeviceProxy_, ERROR); - return miscdeviceProxy_->PlayPattern(vibratePattern, usage, systemUsage, vibateParameter); + int32_t ret = miscdeviceProxy_->PlayPattern(vibratePattern, usage, systemUsage, vibateParameter); + WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_PLAY_PATTERN, ret); + return ret; } int32_t VibratorServiceClient::PlayPattern(const VibratorPattern &pattern, int32_t usage, @@ -538,6 +548,7 @@ int32_t VibratorServiceClient::PlayPrimitiveEffect(int32_t vibratorId, const std StartTrace(HITRACE_TAG_SENSORS, "PlayPrimitiveEffect"); #endif // HIVIEWDFX_HITRACE_ENABLE ret = miscdeviceProxy_->PlayPrimitiveEffect(vibratorId, effect, intensity, usage, systemUsage, count); + WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_PLAY_PRIMITIVE_EFFECT, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -555,6 +566,7 @@ int32_t VibratorServiceClient::GetVibratorCapacity() StartTrace(HITRACE_TAG_SENSORS, "GetVibratorCapacity"); #endif // HIVIEWDFX_HITRACE_ENABLE int32_t ret = miscdeviceProxy_->GetVibratorCapacity(capacity_); + WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_GET_VIBRATOR_CAPACITY, ret); #ifdef HIVIEWDFX_HITRACE_ENABLE FinishTrace(HITRACE_TAG_SENSORS); #endif // HIVIEWDFX_HITRACE_ENABLE @@ -668,5 +680,75 @@ bool VibratorServiceClient::SkipEventAndConvertVibratorEvent(const VibratorEvent } return false; } + +void VibratorServiceClient::WriteVibratorHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret) +{ +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + if (ret != NO_ERROR) { + switch (code) { + case IMiscdeviceServiceIpcCode::COMMAND_VIBRATE: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "Vibrate", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_STOP_VIBRATOR: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "StopVibrator", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_PLAY_VIBRATOR_EFFECT: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayVibratorEffect", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_STOP_VIBRATOR_BY_MODE: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "StopVibratorByMode", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_PLAY_VIBRATOR_CUSTOM: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayVibratorCustom", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_GET_VIBRATOR_CAPACITY: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "GetVibratorCapacity", "ERROR_CODE", ret); + break; + default: + MISC_HILOGW("Code does not exist, code:%{public}d", static_cast(code)); + break; + } + } +#endif // HIVIEWDFX_HISYSEVENT_ENABLE +} + +void VibratorServiceClient::WriteOtherHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret) +{ +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + if (ret != NO_ERROR) { + switch (code) { + case IMiscdeviceServiceIpcCode::COMMAND_IS_SUPPORT_EFFECT: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "IsSupportEffect", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_GET_DELAY_TIME: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "GetDelayTime", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_PLAY_PATTERN: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayPattern", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_TRANSFER_CLIENT_REMOTE_OBJECT: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "TransferClientRemoteObject", "ERROR_CODE", ret); + break; + case IMiscdeviceServiceIpcCode::COMMAND_PLAY_PRIMITIVE_EFFECT: + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayPrimitiveEffect", "ERROR_CODE", ret); + break; + default: + MISC_HILOGW("Code does not exist, code:%{public}d", static_cast(code)); + break; + } + } +#endif // HIVIEWDFX_HISYSEVENT_ENABLE +} } // namespace Sensors } // namespace OHOS -- Gitee