diff --git a/frameworks/native/light/include/light_client.h b/frameworks/native/light/include/light_client.h index ba86858fe4ae97dc1fd9fe14035b74935f9af382..13b25ee1054fac5371ab2e94490e780d9f961987 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 1ae3ffa0100618b8f23637e2a7e1a010129b4437..ca9c65882119b441e3a2c9a69dc2dd5b3327238c 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 34d33e3aba5db1e70facb09a73ebe11a5bb37f7b..9b5d1c56b52c40ce908b205f99d3eb574106d85c 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 b967d47ea798241267890e901d4c682aca486afd..92528086c3505aba0590c0beaa09f8e3ed480852 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